i use 3-Tiers Application. I have created Data acces layer and Business Layer. How can i bind this with my Datagrid on View layer?
public partial class Magasinier : Form
{
Magasinier_BL oMag_BL = new Magasinier_BL();
public Magasinier()
{
InitializeComponent();
GetDataOrdre();
}
public void GetDataOrdre()
{
dataGridView_Mag.DataSource = oMag_BL.Get_All_Magasinier_BL();
dataGridView_Mag.DataMember = "MagTable";
}
}
private void Del_Mag(object sender, DataGridViewRowCancelEventArgs e)
{
if (!e.Row.IsNewRow)
{
DialogResult res = MessageBox.Show("Etes-vous sûr de vouloir supprimer cette ligne ?", "confirmation suppression",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (res == DialogResult.No)
{
e.Cancel = true;
}
else
{
oMag_BL.DelMag_BL(e.Row.Cells["CODE_MAG"].Value.ToString());
}
}
}
i have done the Read and Delete, but not Create and Update.
How can i cable these Create and Update to my businnes layer, by the way, how can i retrive NEW row value or CHANGE row value.
these what i did in ASP.NET: Create
protected void Insrting_Obj_ClientMag(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
{
Pers_Magasinier oPersMag = new Pers_Magasinier();
oPersMag.NoClient = Id;
oPersMag.CodeMag = e.NewValues["CODE_MAG"].ToString();
oPersMag.NomUsr = e.NewValues["NOM"].ToString();
oPersMag.PrenomUsr = e.NewValues["PRENOM"].ToString();
oPersMag.MemoMag = e.NewValues["MEMO"].ToString();
oMag_BL.InstUpdtMag_BL(oPersMag, true);
//To Stop processing Gridview
ASPxGridView_Mag.CancelEdit();
e.Cancel = true;
//Rebind donne
GetDataMags();
}
and Update:
protected void Updting_Obj_ClientMag(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
{
Pers_Magasinier oPersMag = new Pers_Magasinier();
oPersMag.NoClient = Id;
oPersMag.CodeMag = e.NewValues["CODE_MAG"].ToString();
oPersMag.NomUsr = e.NewValues["NOM"].ToString();
oPersMag.PrenomUsr = e.NewValues["PRENOM"].ToString();
oPersMag.MemoMag = e.NewValues["MEMO"].ToString();
oMag_BL.InstUpdtMag_BL(oPersMag, false);
ASPxGridView_Mag.CancelEdit();
e.Cancel = true;
GetDataMags();
}
Now how can i do that in WinForm?
Thanks you in advance
Update: To get Create/Update working, you usually use Grid RowEditTemplate control (which basically is another WinForm which allows you to do extra validation and create/update existing values). Infragistics got good one.
you might need to fix your tags, because you are talking about ASP and not WinForms.
I am using Telerik's Grid with ASP MVC 2 atm. Helps a lot with serializing your data into the ViewModel and you work with ViewModel in your Controllers (dont have to mess around with Request.Params most of the time).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.