示例#1
0
 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);
     }
 }
示例#2
0
 public bool AddNewCraft(T_Crafts craft)
 {
     using (MEMSContext db = new MEMSContext())
     {
         db.Entry(craft).State = EntityState.Added;
         return db.SaveChanges() > 0 ? true : false;
     }
 }
示例#3
0
 public bool DeleteCraft(T_Crafts craft)
 {
     using (MEMSContext db = new MEMSContext())
     {
         db.Entry(craft).State = EntityState.Deleted;
         return(db.SaveChanges() > 0 ? true : false);
     }
 }
示例#4
0
 public bool DeleteCraft(T_Crafts craft)
 {
     try
     {
         ph = new ProductHelper();
         return(ph.DeleteCraft(craft));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#5
0
        public bool AddNewCraft(T_Crafts craft)
        {
            try
            {
                ph = new ProductHelper();
                return ph.AddNewCraft(craft);
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
示例#6
0
 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;
     }
 }
示例#7
0
 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);
             }
         }
     }
 }
示例#8
0
 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;
     }
 }
示例#9
0
 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;
             }
         }
     }
 }