private void btnGhiTheKho_Click(object sender, EventArgs e) { if (fgQD.Row < 0) { BaseMessages.ShowInformationMessage("Chưa chọn quyết định."); return; } if (int.Parse(fgQD[fgQD.Row, "TrangThai"].ToString()) == 5) { clsTheKho cls = new clsTheKho(); cls.ID_PhieuNhap = Convert.ToInt32(fgQD.GetDataDisplay(fgQD.Row, "ID_QuyetDinh")); cls.TonTai = true; for (int i = fgChiTiet.Rows.Fixed; i < fgChiTiet.Rows.Count; i++) { if (fgChiTiet.GetBoolValue(i, "Chon")) { cls.ID_VatTu = fgChiTiet.GetIntValue(i, "ID_VatTu"); cls.ID_Kho = fgChiTiet.GetIntValue(i, "ID_Kho"); cls.SoLuong_BanDau = cls.SoLuong_HienTai = fgChiTiet.GetIntValue(i, "SoLuong"); cls.Insert(); } } Duyet("Bạn có chắc chắn muốn ghi thẻ kho?", 6, "Ghi thành công!"); //BaseMessages.ShowInformationMessage("Cập nhật thành công!"); Loadfg(); } else { BaseMessages.ShowWarningMessage("Phiếu chưa được phê duyệt"); return; } }
private void LoadfgChiTietPhieuXuat(int ID_Kho) { fgChiTietXuat.BeginUpdate(); clsTheKho cls = new clsTheKho(); DataTable dt = cls.SelectVatTuWithID_Xuat(ID_Kho); int iSTT = 1; int sum = 0; fgChiTietXuat.Rows.Count = fgChiTietXuat.Rows.Fixed + 1; fgChiTietXuat[fgChiTietXuat.Rows.Count - 1, "Ten_VatTu"] = "Tổng"; fgChiTietXuat[fgChiTietXuat.Rows.Count - 1, "SoLuongXuat"] = 0; fgChiTietXuat.Rows[fgChiTietXuat.Rows.Count - 1].Style = cs; foreach (DataRow dr in dt.Rows) { Row fgRow = fgChiTietXuat.Rows.Add(); fgRow["STT"] = iSTT; iSTT++; fgRow["ID_VatTu"] = dr["ID_VatTu"]; fgRow["Ten_VatTu"] = dr["Ten_VatTu"]; fgRow["SoLuongHienTai"] = dr["SoLuongHienTai"]; fgRow["SoLuongXuat"] = 0; sum += int.Parse(dr["SoLuongHienTai"].ToString()); fgChiTietXuat.SetCellStyle(iSTT, 4, cs1); } fgChiTietXuat[fgChiTietXuat.Rows.Fixed, "SoLuongHienTai"] = sum; fgChiTietXuat.EndUpdate(); }
private void LoadTheKhoSoLuongKhac() { int sum = 0; clsTheKho clss = new clsTheKho(); DataTable dtt = clss.SelectSoLuongPhieuKhac(int.Parse(fgChiTietXuat[fgChiTietXuat.Row, "ID_VatTu"].ToString()), int.Parse(cboKhoXuat.EditValue.ToString())); foreach (DataRow dr in dtt.Rows) { for (int j = fgChiTietTheKho.Rows.Fixed + 1; j < fgChiTietTheKho.Rows.Count; j++) { if (int.Parse(dr["ID_TheKho"].ToString()) == int.Parse(fgChiTietTheKho.GetDataDisplay(j, "ID_TheKho"))) { if (GlobalVariables.m_Flag == 0 || m_iTrangThai == (int)GlobalVariables.TrangThai.GhiTheKho) { fgChiTietTheKho[j, "SoLuongKhac"] = dr["SoLuongXuatOPhieuKhac"]; } else { fgChiTietTheKho[j, "SoLuongKhac"] = int.Parse(dr["SoLuongXuatOPhieuKhac"].ToString()) - int.Parse(fgChiTietTheKho[j, "SoLuongXuat"].ToString()); } sum += int.Parse(fgChiTietTheKho[j, "SoLuongKhac"].ToString()); } } } fgChiTietTheKho[fgChiTietTheKho.Rows.Fixed, "SoLuongKhac"] = sum; }
private void LoadTheKho() { var cbo = cboTheKho; cbo.Tag = 0; clsTheKho cls = new clsTheKho(); DataTable dt = cls.SelectAll(); dt = dt.DefaultView.ToTable(); cbo.Properties.DataSource = dt; cbo.Properties.DisplayMember = "ID_TheKho"; cbo.Properties.ValueMember = "ID_TheKho"; cbo.Tag = 1; }
private void LoadFgTheKho() { DataTable dt = new DataTable(); if (GlobalVariables.m_Flag == 0) { clsTheKho cls = new clsTheKho(); dt = cls.SelectVatTuWithID_XuatTheKho(int.Parse(fgChiTietXuat[fgChiTietXuat.Row, "ID_VatTu"].ToString()), int.Parse(cboKhoXuat.EditValue.ToString())); } else { clsTheKho cls = new clsTheKho(); cls.ID_VatTu = int.Parse(fgChiTietXuat[fgChiTietXuat.Row, "ID_VatTu"].ToString()); cls.ID_Kho = m_iID_Kho; dt = cls.Select_TheKho_PX_PhieuNhap_SoLuong(m_iID_PX); } int iSTT = 1; fgChiTietTheKho.Rows.Count = fgChiTietTheKho.Rows.Fixed + 1; fgChiTietTheKho[fgChiTietTheKho.Rows.Count - 1, "ID_TheKho"] = "Tổng"; fgChiTietTheKho.Rows[fgChiTietTheKho.Rows.Count - 1].Style = cs; foreach (DataRow dr in dt.Rows) { Row fgRow = fgChiTietTheKho.Rows.Add(); fgRow["STT"] = iSTT; iSTT++; fgRow["ID_TheKho"] = dr["ID_TheKho"]; fgRow["ID_PhieuNhap"] = dr["ID_PhieuNhap"]; fgRow["So_PhieuNhap"] = dr["So_QuyetDinh"]; fgRow["SoLuongTrongKho"] = dr["SoLuong_HienTai"]; fgRow["Ngay_NhapKho"] = dr["Ngay_QuyetDinh"]; fgRow["SoLuongXuat"] = 0; fgRow["SoLuongKhac"] = 0; if (GlobalVariables.m_Flag != 0) { fgRow["SoLuongXuat"] = dr["SoLuong"]; } fgChiTietTheKho.SetCellStyle(iSTT, 7, cs1); } }
private void fgChiTietTheKho_AfterEdit(object sender, RowColEventArgs e) { int sl = 0; if (fgChiTietTheKho[fgChiTietTheKho.Row, "SoLuongXuat"] != null) { DataRow dr = m_dtTmp.NewRow(); ThemMoiDataTableTmp(dr); m_dtTmp.Rows.Add(dr); UpdateSoLuongDataTableTmp(dr); // update số lượng vật tư trong thẻ kho khi thay đổi số lượng } clsTheKho cls = new clsTheKho(); DataTable dt = cls.SelectVatTuWithID_XuatTheKho(int.Parse(fgChiTietXuat[fgChiTietXuat.Row, "ID_VatTu"].ToString()), m_iID_Kho); for (int i = fgChiTietTheKho.Rows.Fixed + 1; i < fgChiTietTheKho.Rows.Count; i++) { if (fgChiTietTheKho[i, "SoLuongXuat"] != null) { sl += int.Parse(fgChiTietTheKho[i, "SoLuongXuat"].ToString()); } } UpdateFgPhieuXuatChiTiet(sl); UpdateFgPhieuXuat(sl); }