public ucHoaDonDatHang() { InitializeComponent(); _NhaCungCapBUS = new NhaCungCapBUS(); _MatHangBUS = new MatHangBUS(); _HoaDonDatHangBUS = new HoaDonDatHangBUS(); _ChiTietHoaDonDatHangBUS = new ChiTietHoaDonDatHangBUS(); _ThamSoBUS = new ThamSoBUS(); ThamSo ts =new ThamSo(); ts.TenThamSo = "SoSanPhamTonToiDaDeDatHang"; QuyDinhSoSanPhamToiThieu = (int)Convert.ToDecimal(_ThamSoBUS.LayGiaTriThamSo(ts)); leftselection = -1; rightselection = -1; tongtien = 0; TenNhanVienLap = StaticVariables.nhanVien.TenNhanVien; }
private void sbThem_Click(object sender, EventArgs e) { if (!txtSoLuong.Text.Equals("")) { this.soLuong = Convert.ToInt32(txtSoLuong.Text); } else this.soLuong = 1; //////////Kiểm tra quy định. ThamSo thamso = new ThamSo(); thamso.TenThamSo = "SoSanPhamKhuyenMaiToiDa"; Object o = new ThamSoBUS().LayGiaTriThamSo(thamso); decimal slQD = 0; if (o != null) { slQD = Convert.ToDecimal(new ThamSoBUS().LayGiaTriThamSo(thamso)); if (slQD < this.soLuong) { MessageBox.Show("Số lượng sản phẩm vượt quá quy định cho phép!", "Thông báo lỗi", MessageBoxButtons.OK); return; } } if (this.maSP.Equals("")) return; Decimal sluong = Convert.ToDecimal(this.gridViewSp.GetRowCellValue(this.gridViewSp.FocusedRowHandle, "Số lượng").ToString()); if (sluong < this.soLuong) { MessageBox.Show("Số lượng sản phẩm qúa lớn!", "Thông báo lỗi", MessageBoxButtons.OK); return; } int numRows = gridSpMua.RowCount; bool isAddExistRow = false; int index = 0; int slTemp = 0; for (int j = 0; j < numRows; j++) { String mspTemp = gridSpMua.GetRowCellValue(j, "Mã sản phẩm").ToString(); slTemp = Convert.ToInt32(gridSpMua.GetRowCellValue(j, "Số lượng")); if (!maSP.Equals(mspTemp)) { isAddExistRow = false; } else { if (sluong < this.soLuong) { MessageBox.Show("Số lượng sản phẩm qúa lớn!", "Thông báo lỗi", MessageBoxButtons.OK); return; } isAddExistRow = true; index = j; break; } } //Tính % tiền để gửi Decimal phanTram = this.teGiaKhuyenMai.Text == "" ? 0 : Convert.ToDecimal(this.teGiaKhuyenMai.Text); if (phanTram == 100) phanTram = this.tienSP; else { phanTram = phanTram / 100; phanTram = phanTram * this.tienSP; } ///////////kiểm tra % giảm giá theo quy định. thamso.TenThamSo = "PhanTramGiamGia"; o = new ThamSoBUS().LayGiaTriThamSo(thamso); slQD = 0; //Vinh, m co lam rang buoc cac khuuyen mai trùng nhau khong???, vi du 1 ngay co 10 cai khuyen mai thi sao// chua làm rồi ngay mai cai nay nguy hiem nhat, gio sua loi hien tai di if (o != null) { string s = new ThamSoBUS().LayGiaTriThamSo(thamso); //convert qua decimal slQD = Convert.ToDecimal(s); if (slQD < (this.teGiaKhuyenMai.Text == "" ? 0 : Convert.ToDecimal(this.teGiaKhuyenMai.Text))) { MessageBox.Show("% giảm giá không vượt quá quy định cho phép!", "Thông báo lỗi", MessageBoxButtons.OK); return; } } if (isAddExistRow) { gridSpMua.SetRowCellValue(index, "Số lượng", this.soLuong); Decimal x = new Decimal(3); x = this.tienSP - phanTram; gridSpMua.SetRowCellValue(index, "Giá bán", Math.Round(x, 3)); } else { this.addRow(phanTram); } if (gridSpMua.RowCount == 0) { this.addRow(phanTram); } }
public FormThayDoiQuyDinh() { InitializeComponent(); _ThamSoBUS = new ThamSoBUS(); }