private void btndel_Click(object sender, EventArgs e) { try { if (gvcraft.DataRowCount > 0) { var ds = (List <T_Crafts>) this.gvcraft.DataSource; int idx = (int)gvcraft.GetFocusedRowCellValue("id"); var craftid = gvcraft.FocusedRowHandle; if (idx <= 0) { ds.RemoveAt(craftid); gvcraft.RefreshData(); } else { if (XtraMessageBox.Show("是否删除已保存的工序", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK) { T_Crafts crafts = ds.Find(c => c.id == idx); m_client.DeleteCraft(crafts); ds.RemoveAt(craftid); gvcraft.RefreshData(); } } gvcraft.FocusedRowHandle = ds.Count - 1; } } catch (Exception ex) { XtraMessageBox.Show(ex.Message); } }
public bool AddNewCraft(T_Crafts craft) { using (MEMSContext db = new MEMSContext()) { db.Entry(craft).State = EntityState.Added; return db.SaveChanges() > 0 ? true : false; } }
public bool DeleteCraft(T_Crafts craft) { using (MEMSContext db = new MEMSContext()) { db.Entry(craft).State = EntityState.Deleted; return(db.SaveChanges() > 0 ? true : false); } }
public bool DeleteCraft(T_Crafts craft) { try { ph = new ProductHelper(); return(ph.DeleteCraft(craft)); } catch (Exception ex) { throw ex; } }
public bool AddNewCraft(T_Crafts craft) { try { ph = new ProductHelper(); return ph.AddNewCraft(craft); } catch (Exception ex) { throw ex; } }
private void btnadd_Click(object sender, EventArgs e) { if (gvcraft.DataRowCount > 0) { var ds = (List <T_Crafts>) this.gvcraft.DataSource; var newcraft = new T_Crafts(); newcraft.pid = m_pid; newcraft.processindex = ds.Count + 1; modifycraftlst.Add(newcraft); ds.Add(newcraft); gvcraft.RefreshData(); gvcraft.FocusedRowHandle = ds.Count - 1; } else { List <T_Crafts> craftlst = new List <T_Crafts>(); var newcraft = new T_Crafts(); newcraft.pid = m_pid; newcraft.processindex = 1; craftlst.Add(newcraft); gccraft.DataSource = craftlst; } }
private static int comparecraft(T_Crafts up, T_Crafts down) { if (up == null) { if (down == null) { return(0); } else { return(-1); } } else { if (down == null) { return(1); } else { if (up.processindex.Value > down.processindex.Value) { return(1); } else if (up.processindex.Value == down.processindex.Value) { return(0); } else// if (up.colpos.Value < down.colpos.Value) { return(-1); } } } }
private void btnadd_Click(object sender, EventArgs e) { if (gvcraft.DataRowCount > 0) { var ds = (List<T_Crafts>)this.gvcraft.DataSource; var newcraft = new T_Crafts(); newcraft.pid = m_pid; modifycraftlst.Add(newcraft); ds.Add(newcraft); gvcraft.RefreshData(); gvcraft.FocusedRowHandle = ds.Count - 1; } else { List<T_Crafts> craftlst = new List<T_Crafts>(); var newcraft = new T_Crafts(); newcraft.pid = m_pid; craftlst.Add(newcraft); gccraft.DataSource = craftlst; } }
private static int comparecraft(T_Crafts up, T_Crafts down) { if (up == null) { if (down == null) { return 0; } else { return -1; } } else { if (down == null) { return 1; } else { if (up.processindex.Value > down.processindex.Value) { return 1; } else if (up.processindex.Value == down.processindex.Value) { return 0; } else// if (up.colpos.Value < down.colpos.Value) { return -1; } } } }