示例#1
0
        private void button2_Click(object sender, EventArgs e)
        {
            using (SSLsEntities db = new SSLsEntities())
            {
                if (_Id == 0)
                {
                    // add new
                    ProductGroups obj = new ProductGroups();
                    obj.Code        = textBoxCode.Text;
                    obj.Name        = textBoxName.Text;
                    obj.Description = textBoxDesc.Text;
                    obj.CreateDate  = DateTime.Now;
                    obj.CreateBy    = Singleton.SingletonAuthen.Instance().Id;
                    obj.Enable      = true;
                    obj.UpdateBy    = Singleton.SingletonAuthen.Instance().Id;
                    obj.UpdateDate  = DateTime.Now;
                    db.ProductGroups.Add(obj);
                }
                else
                {
                    // edit
                    var obj = db.ProductGroups.SingleOrDefault(w => w.Id == _Id);
                    obj.UpdateDate  = DateTime.Now;
                    obj.UpdateBy    = Singleton.SingletonAuthen.Instance().Id;
                    obj.Code        = textBoxCode.Text;
                    obj.Name        = textBoxName.Text;
                    obj.Description = textBoxDesc.Text;
                    if (radioButton1.Checked)
                    {
                        obj.Enable = true;
                    }
                    else
                    {
                        obj.Enable = false;
                    }
                    db.Entry(obj).State = EntityState.Modified;
                }
                db.SaveChanges();
                Singleton.SingletonPriority1.SetInstance();
                //Singleton.SingletonPriority1.Instance();

                dataGrid();
                //this.Dispose();
                //_Id = 0;
            }
        }
示例#2
0
 public void BinddingProGroupChoose(ProductGroups send)
 {
     _GroupId = send.Id;
     textBoxProGroupCode.Text = send.Code;
     textBoxProGroupName.Text = send.Name;
 }