コード例 #1
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            tblPro pro = new tblPro();

            setGridViewToData(ref pro);
            setDataToControl(pro);
        }
コード例 #2
0
 public void setGridViewToData(ref tblPro pro)
 {
     pro.ProID          = Convert.ToInt32(dataGridView1.CurrentRow.Cells["col_ProID"].Value.ToString());
     pro.ProName        = dataGridView1.CurrentRow.Cells["col_ProName"].Value.ToString();
     pro.ProDescription = dataGridView1.CurrentRow.Cells["col_ProDescription"].Value.ToString();
     pro.ProStatus      = Convert.ToInt32(dataGridView1.CurrentRow.Cells["col_ProStatus"].Value.ToString());
     pro.CatID          = Convert.ToInt32(dataGridView1.CurrentRow.Cells["col_CatID"].Value.ToString());
 }
コード例 #3
0
 public void setControlToData(ref tblPro pro)
 {
     bll                = new BLL_QuanLySP();
     pro.ProID          = Convert.ToInt32(lbl_masp.Text);
     pro.ProName        = txt_Name.Text;
     pro.ProDescription = txt_Des.Text;
     pro.CatID          = bll.GetCatID(cbo_DanhMuc.SelectedItem.ToString());
 }
コード例 #4
0
 public bool Edit(tblPro pro)
 {
     try
     {
         var model = db.tblProes.Find(pro.ProID);
         model.ProName        = pro.ProName;
         model.ProDescription = pro.ProDescription;
         model.CatID          = pro.CatID;
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
コード例 #5
0
        private void btn_capNhat_Click(object sender, EventArgs e)
        {
            bll = new BLL_QuanLySP();
            tblPro pro = new tblPro();

            setControlToData(ref pro);
            bool result = bll.Edit(pro);

            if (result)
            {
                MessageBox.Show("Thêm thành công");
                cbo_DanhMuc_SelectedIndexChanged(sender, e);
            }
            else
            {
                MessageBox.Show("Thêm không thành công");
            }
        }
コード例 #6
0
        private void btn_them_Click(object sender, EventArgs e)
        {
            bll = new BLL_QuanLySP();
            tblPro pro = new tblPro();

            pro.ProStatus = 1;
            setControlToData(ref pro);
            int result = bll.AddProduct(pro);

            if (result > 0)
            {
                MessageBox.Show("Thêm thành công");
                cbo_DanhMuc_SelectedIndexChanged(sender, e);
            }
            else
            {
                MessageBox.Show("Thêm không thành công");
            }
        }
コード例 #7
0
 public void setDataToControl(tblPro pro)
 {
     txt_Name.Text = pro.ProName;
     txt_Des.Text  = pro.ProDescription;
     lbl_masp.Text = pro.ProID.ToString();
 }
コード例 #8
0
 public int AddProduct(tblPro pro)
 {
     db.tblProes.Add(pro);
     db.SaveChanges();
     return(pro.ProID);
 }