private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { tblPro pro = new tblPro(); setGridViewToData(ref pro); setDataToControl(pro); }
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()); }
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()); }
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); } }
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"); } }
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"); } }
public void setDataToControl(tblPro pro) { txt_Name.Text = pro.ProName; txt_Des.Text = pro.ProDescription; lbl_masp.Text = pro.ProID.ToString(); }
public int AddProduct(tblPro pro) { db.tblProes.Add(pro); db.SaveChanges(); return(pro.ProID); }