public void SetDTOToControl(DTO_Pro pro) { lbl_ProID.Text = pro.ProID.ToString(); txt_name.Text = pro.ProName; txt_des.Text = pro.proDescription; cbo_dm.SelectedItem = pro.CatName; }
public DTO_Pro setControlToDTO(ref DTO_Pro pro, BLL_QuanLySP bll) { pro.CatID = Convert.ToInt32(bll.GetCatIDWithCatName(ref err, cbo_dm.SelectedItem.ToString())); pro.ProName = txt_name.Text; pro.proDescription = txt_des.Text; pro.ProID = Convert.ToInt32(lbl_ProID.Text); return(pro); }
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { DTO_Pro pro = new DTO_Pro(); pro.ProID = Convert.ToInt32(dataGridView1.CurrentRow.Cells["col_ProID"].Value); pro.ProName = dataGridView1.CurrentRow.Cells["col_ProName"].Value.ToString(); pro.proDescription = dataGridView1.CurrentRow.Cells["col_ProDescription"].Value.ToString(); pro.CatID = Convert.ToInt32(dataGridView1.CurrentRow.Cells["col_CatID"].Value); pro.CatName = dataGridView1.CurrentRow.Cells["col_CatID"].Value.ToString(); SetDTOToControl(pro); }
private void btn_add_Click(object sender, EventArgs e) { bll = new BLL_QuanLySP(); DTO_Pro pro = new DTO_Pro(); setControlToDTO(ref pro, bll); if (bll.AddProduct(ref err, pro.ProName, pro.proDescription, pro.CatID)) { MessageBox.Show("Đã thêm thành công"); cbo_dm_SelectedIndexChanged(sender, e); } else { MessageBox.Show("Không thêm đuọc"); } }