protected void GRID_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { ASPxGridView grid = (ASPxGridView)sender; ASPxTextBox txtNombre = (ASPxTextBox)grid.FindEditFormTemplateControl("ASPxNombre"); ASPxListBox cmbMateriales = (ASPxListBox)grid.FindEditFormTemplateControl("ASPxListBox"); MATERIAL newKit = new MATERIAL(); newKit.M_NOMBRE = txtNombre.Text; newKit.M_TIPO = "Kit"; newKit.M_MEDIDA_COMPRA = 1; newKit.M_MEDIDA_DISTRIBUCION = 1; newKit.M_STOCK_BAJO = 1; newKit.M_STOCK_IDEAL = 100; newKit.M_STOCK_REAL = 0; CRUD_Material.Create(newKit); int kit_id = CRUD_Material.Read(newKit.M_NOMBRE); foreach (ListEditItem item in cmbMateriales.Items) { MATERIAL_KIT mat = new MATERIAL_KIT(); mat.M_ID = kit_id; mat.MAT_M_ID = CRUD_Material.Read(item.Value.ToString()); mat.MK_CANTIDAD = 1; CRUD_Kit.Create(mat); } e.Cancel = true; grid.CancelEdit(); }
public static void Create(MATERIAL_KIT mat_new) { using (BODEXDataContext ctx = new BODEXDataContext()) { ctx.ListaMaterialKit.InsertOnSubmit(mat_new); ctx.SubmitChanges(); } }
partial void UpdateMATERIAL_KIT(MATERIAL_KIT instance);
partial void DeleteMATERIAL_KIT(MATERIAL_KIT instance);
partial void InsertMATERIAL_KIT(MATERIAL_KIT instance);