/// <summary> /// Thay đổi nhà cung cấp thực phẩm /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cbSuplier_SelectedIndexChanged(object sender, EventArgs e) { XoaTatCaToolStripMenuItem_Click(this, new EventArgs()); NhaCungCapDTO nhacc = (NhaCungCapDTO)cbSuplier.SelectedItem; if (nhacc == null) { return; } if (ckbIsBelow.Checked == true) { ThucPhamSource.DataSource = ThucPhamDAO.Instance.getListThucPhamDuoiMucNhap(nhacc.MANCC); } else { ThucPhamSource.DataSource = ThucPhamDAO.Instance.getListThucPham(nhacc.MANCC); } if (cbNameMaterial.SelectedItem == null) { txbGia.Text = "0"; return; } ThucPhamDTO tp = (ThucPhamDTO)cbNameMaterial.SelectedItem; txbGia.Text = tp.GiaTP.ToString(); }
/// <summary> /// lấy thực phảm theo matp /// </summary> /// <param name="MATP"></param> /// <returns></returns> public ThucPhamDTO getThucPhambyMATP(string MATP) { ThucPhamDTO result = null; string query = "getThucPhambyMATP @matp"; DataTable data = DataProvider.Instance.ExecuteQuery(query, new object[] { MATP }); foreach (DataRow item in data.Rows) { result = new ThucPhamDTO(item); } return(result); }
/// <summary> /// Lấy giá thực phẩm /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cbNameMaterial_SelectedIndexChanged(object sender, EventArgs e) { if (cbNameMaterial.SelectedItem == null) { if (cbNameMaterial.SelectedItem == null) { txbGia.Text = "0"; return; } return; } ThucPhamDTO tp = (ThucPhamDTO)cbNameMaterial.SelectedItem; txbGia.Text = tp.GiaTP.ToString(); }
/// <summary> /// Them vao cthdn /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ptbAdd_Click(object sender, EventArgs e) { if (cbNameMaterial.SelectedItem == null) { fMessageBoxOK.Show("Chưa chọn thực phẩm!"); return; } if (cbSuplier.SelectedItem == null) { fMessageBoxOK.Show("Chưa chọn nhà cung cấp!"); return; } ThucPhamDTO tp = ((ThucPhamDTO)cbNameMaterial.SelectedItem); float SoLuong = 0; float.TryParse(txbSoLuong.Text, out SoLuong); if (SoLuong == 0) { fMessageBoxOK.Show("Vui lòng nhập số lượng!"); return; } double ThanhTien = SoLuong * tp.GiaTP; List <CTHDNdto> listnew = new List <CTHDNdto>(); bool isTrung = false; foreach (CTHDNdto item in listCTHDN) { if (tp.MATP == item.MATP) { item.SoLuongThucPham += SoLuong; item.ThanhTien = item.SoLuongThucPham * tp.GiaTP; isTrung = true; } listnew.Add(item); } if (!isTrung) { listnew.Add(new CTHDNdto(null, tp.MATP, SoLuong, ThanhTien)); } listCTHDN.Clear(); listCTHDN = listnew; dtgvCTHDN.DataSource = listCTHDN; loadTongTien(); }
/// <summary> /// thực hiện gửi thông tin thực phẩm gửi về form trước đó /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAccept_Click(object sender, EventArgs e) { float KhoiLuong = 0; float.TryParse(StaticClass.xoakhoangtrang(txbKhoiLuongTP.Text), out KhoiLuong); if (KhoiLuong == 0) { fMessageBoxOK.Show("Bạn chưa nhập khối lượng thực phẩm!"); return; } if (cbThucPham.SelectedItem == null) { fMessageBoxOK.Show("Bạn chưa chọn thực phẩm nào!"); return; } ThucPhamDTO thucPham = (ThucPhamDTO)cbThucPham.SelectedItem; if (_eventAccept != null) { _eventAccept(this, new EventThemThucPham(KhoiLuong, thucPham)); } }
public EventThemThucPham(float KhoiLuong, ThucPhamDTO thucpham) { this.KhoiLuong = KhoiLuong; this.ThucPham = thucpham; }