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 mat_new) { using (BODEXDataContext ctx = new BODEXDataContext()) { mat_new.M_STOCK_IDEAL = 100; mat_new.M_STOCK_BAJO = 1; mat_new.M_STOCK_REAL = 0; ctx.ListaMaterial.InsertOnSubmit(mat_new); ctx.SubmitChanges(); } }
public static void Delete(MATERIAL mat_del) { using (BODEXDataContext ctx = new BODEXDataContext()) { MATERIAL borrar = (from mat in ctx.ListaMaterial where mat.M_ID.Equals(mat_del.M_ID) select mat).First<MATERIAL>(); ctx.ListaMaterial.DeleteOnSubmit(borrar); ctx.SubmitChanges(); } }
public static void Update(MATERIAL mat_upd) { using (BODEXDataContext ctx = new BODEXDataContext()) { MATERIAL material = (from mat in ctx.ListaMaterial where mat.M_ID.Equals(mat_upd.M_ID) select mat).First<MATERIAL>(); material.M_NOMBRE = mat_upd.M_NOMBRE; material.M_DESCRIPCION = mat_upd.M_DESCRIPCION; material.M_TIPO = mat_upd.M_TIPO; material.M_MEDIDA_DISTRIBUCION = mat_upd.M_MEDIDA_DISTRIBUCION; material.M_MEDIDA_COMPRA = mat_upd.M_MEDIDA_COMPRA; ctx.SubmitChanges(); } }
public static void DeleteKit(MATERIAL mat_del) { using (BODEXDataContext ctx = new BODEXDataContext()) { MATERIAL_KIT material; try { material = (from mat in ctx.ListaMaterialKit where mat.M_ID.Equals(mat_del.M_ID) select mat).First<MATERIAL_KIT>(); } catch (Exception e) { material = null; } while (material != null) { ctx.ListaMaterialKit.DeleteOnSubmit(material); ctx.SubmitChanges(); try { material = (from mat in ctx.ListaMaterialKit where mat.M_ID.Equals(mat_del.M_ID) select mat).First<MATERIAL_KIT>(); } catch (Exception e) { material = null; } } MATERIAL borrar = (from mat in ctx.ListaMaterial where mat.M_ID.Equals(mat_del.M_ID) select mat).First<MATERIAL>(); ctx.ListaMaterial.DeleteOnSubmit(borrar); ctx.SubmitChanges(); } }
partial void DeleteMATERIAL(MATERIAL instance);
partial void UpdateMATERIAL(MATERIAL instance);
partial void InsertMATERIAL(MATERIAL instance);