private void btnInPhieu_Click(object sender, EventArgs e) { try { if (grvDanhSach.FocusedRowHandle < 0 || grvDanhSach.RowCount == 0) { MessageBox.Show("Không có bản ghi nào được lựa chọn", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } List <VnsKhNganSach> tmp = new List <VnsKhNganSach>(); List <RpChiTietNganSach> lstRp = new List <RpChiTietNganSach>(); foreach (VnsCtNganSach tmpd in objChungTu.LstNganSach) { RpChiTietNganSach rp = new RpChiTietNganSach(objChungTu, tmpd); lstRp.Add(rp); } lstRp.Sort(ComparePhieuByKhoanChi); string KhoanChi = ""; decimal STT = 0; foreach (RpChiTietNganSach tmpd in lstRp) { if (tmpd.KhoanChi != KhoanChi) { KhoanChi = tmpd.KhoanChi; STT++; } tmpd.STT = STT; } List <Info> TempLstThamSo = new List <Info>(); TempLstThamSo = General.lstThamSo.ToList(); Info objThamSo = new Info(); objThamSo.Ma = "p_SoTienBangChu"; objThamSo.GiaTri = ReportHelper.DocTienBangChu((long)GetSoTien(), " đồng"); TempLstThamSo.Add(objThamSo); objThamSo = new Info(); objThamSo.Ma = "p_NgayBaoCao"; objThamSo.GiaTri = "Hà Nội, ngày " + DateTime.Now.Day.ToString() + " tháng " + DateTime.Now.Month.ToString() + " năm " + DateTime.Now.Year.ToString(); TempLstThamSo.Add(objThamSo); objThamSo = new Info(); objThamSo.Ma = "p_TieuDe"; objThamSo.GiaTri = objLoaiChungTu.Ten.ToUpper(); TempLstThamSo.Add(objThamSo); frmInPhieu frmIn = new frmInPhieu(TempLstThamSo, lstRp); frmIn.ShowDialog(); } catch (Exception ex) { Commons.Message_Error(ex); } }
private void btnInPhieu_Click(object sender, EventArgs e) { try { List <VnsKhNganSach> tmp = new List <VnsKhNganSach>(); List <RpChiTietNganSach> lstRp = new List <RpChiTietNganSach>(); foreach (VnsCtNganSach tmpd in lstGiaoDich) { RpChiTietNganSach rp = new RpChiTietNganSach(objChungTu, tmpd); lstRp.Add(rp); } lstRp.Sort(ComparePhieuByKhoanChi); string KhoanChi = ""; decimal STT = 0; foreach (RpChiTietNganSach tmpd in lstRp) { if (tmpd.KhoanChi != KhoanChi) { KhoanChi = tmpd.KhoanChi; STT++; } tmpd.STT = STT; } List <Info> TempLstThamSo = new List <Info>(); TempLstThamSo = General.lstThamSo.ToList(); Info objThamSo = new Info(); objThamSo.Ma = "p_SoTienBangChu"; objThamSo.GiaTri = ReportHelper.DocTienBangChu((long)GetSoTien(), " đồng"); TempLstThamSo.Add(objThamSo); objThamSo = new Info(); objThamSo.Ma = "p_NgayBaoCao"; objThamSo.GiaTri = "Hà Nội, ngày " + DateTime.Now.Day.ToString() + " tháng " + DateTime.Now.Month.ToString() + " năm " + DateTime.Now.Year.ToString(); TempLstThamSo.Add(objThamSo); objThamSo = new Info(); objThamSo.Ma = "p_TieuDe"; objThamSo.GiaTri = objLoaiChungTu.Ten.ToUpper(); TempLstThamSo.Add(objThamSo); //tmp.Add(objChungTu); frmInPhieu frmIn = new frmInPhieu(TempLstThamSo, lstRp); frmIn.ShowDialog(); } catch (Exception ex) { Commons.Message_Error(ex); } }
private int ComparePhieuByKhoanChi(RpChiTietNganSach x, RpChiTietNganSach y) { if (x == null) { if (y == null) { // If x is null and y is null, they're // equal. return(0); } else { // If x is null and y is not null, y // is greater. return(-1); } } else { // If x is not null... // if (y == null) // ...and y is null, x is greater. { return(1); } else { // ...and y is not null, compare the // lengths of the two strings. // int retvalDoanDienID = 0; return(retvalDoanDienID = x.KhoanChi.CompareTo(y.KhoanChi)); } } }
public IList <RpChiTietNganSach> GetBangKeChiTiet(DateTime TuNgay, DateTime DenNgay, String MaCt, Guid DonViId) { ICriteria isearch = NHibernateSession.CreateCriteria <VnsChungTu>().CreateAlias("LstGiaoDich", "d"); if (!string.IsNullOrEmpty(MaCt)) { isearch.Add(Restrictions.Eq("MaCt", MaCt)); } isearch.Add(Restrictions.Le("NgayCt", VnsConvert.CEndOfDate(DenNgay))); isearch.Add(Restrictions.Ge("NgayCt", VnsConvert.CStartOfDate(TuNgay))); if (!VnsCheck.IsNullGuid(DonViId)) { isearch.Add(Restrictions.Eq("DonViId", DonViId)); } isearch.AddOrder(new Order("NgayCt", true)); IList <VnsChungTu> lst = new List <VnsChungTu>(); isearch.SetResultTransformer(Transformers.DistinctRootEntity); lst = isearch.List <VnsChungTu>(); IList <RpChiTietNganSach> lstRp = new List <RpChiTietNganSach>(); foreach (VnsChungTu tmph in lst) { foreach (VnsGiaoDich tmpd in tmph.LstGiaoDich) { RpChiTietNganSach rp = new RpChiTietNganSach(tmph, tmpd); lstRp.Add(rp); } } return(lstRp); }
private int CompareReport(RpChiTietNganSach x, RpChiTietNganSach y) { if (x == null) { if (y == null) { // If x is null and y is null, they're // equal. return(0); } else { // If x is null and y is not null, y // is greater. return(-1); } } else { // If x is not null... // if (y == null) // ...and y is null, x is greater. { return(1); } else { // ...and y is not null, compare the // lengths of the two strings. // int retvalMaLoaiKhoan = 0; return(retvalMaLoaiKhoan = x.MaLoaiKhoan.CompareTo(y.MaLoaiKhoan)); } } }
private void btnIn_Click(object sender, EventArgs e) { List <VnsKhNganSach> tmp = new List <VnsKhNganSach>(); List <RpChiTietNganSach> lstRp = new List <RpChiTietNganSach>(); RpChiTietNganSach rp = new RpChiTietNganSach(); int vonglap = 5; if (_lstGiaoDich.Count > 5) { vonglap = _lstGiaoDich.Count; } for (int i = 0; i < vonglap; i++) { if (5 > i) //neu nho hon 5 dong thi lay binh thuong { if (_lstGiaoDich.Count > i) { rp = new RpChiTietNganSach(objChungTu, _lstGiaoDich[i]); } else { rp = new RpChiTietNganSach(); } lstRp.Add(rp); } else { lstRp[4].SoTien += _lstGiaoDich[i].SoTien; lstRp[4].NoiDung = "Tổng hợp"; } } //foreach (VnsGiaoDich tmpd in lstGiaoDich) //{ // i++; //} lstRp.Sort(RpChiTietNganSach.ComparePhieuByKhoanChi); string KhoanChi = ""; decimal STT = 0; foreach (RpChiTietNganSach tmpd in lstRp) { if (tmpd.KhoanChi != KhoanChi) { KhoanChi = tmpd.KhoanChi; STT++; } tmpd.STT = STT; } Report.InUyNhiemChi rpPhieu = new Report.InUyNhiemChi(); Report.InUyNhiemChi_N2017 rpPhieu_2017 = new Report.InUyNhiemChi_N2017(); int ind = cboUyNhiemChi.SelectedIndex; objChungTu.NgayHt = (DateTime)txtNgayLap.EditValue; if (ind == 0) { rpPhieu.ObjVnsChungTu = objChungTu; rpPhieu.ObjVnsDmDonvi = objChungTu.ObjDmDonVi; ReportHelper.SetParamValue(General.lstThamSo, rpPhieu.Parameters); rpPhieu.Parameters["p_SoUNC"].Value = txtSoUNC.Text; rpPhieu.DataSource = lstRp; rpPhieu.ShowPreviewDialog(); } else { rpPhieu_2017.ObjVnsChungTu = objChungTu; rpPhieu_2017.ObjVnsDmDonvi = objChungTu.ObjDmDonVi; ReportHelper.SetParamValue(General.lstThamSo, rpPhieu_2017.Parameters); rpPhieu_2017.Parameters["p_SoUNC"].Value = txtSoUNC.Text; rpPhieu_2017.DataSource = lstRp; rpPhieu_2017.ShowPreviewDialog(); } }
public IList <RpChiTietNganSach> GetNganSachTongHop(DateTime TuNgay, DateTime DenNgay, Guid DonViId) { List <RpChiTietNganSach> lst = new List <RpChiTietNganSach>(GetBangKeChiTiet(TuNgay, DenNgay, "", DonViId)); lst.Sort(CompareBangKeByKhoanChi); List <RpChiTietNganSach> lstthem = new List <RpChiTietNganSach>(); string malk = String.Empty; RpChiTietNganSach tmpCapTong = new RpChiTietNganSach(); RpChiTietNganSach tmpConLai = new RpChiTietNganSach(); IList <String> dsLoaiChungTu = new List <String>(); dsLoaiChungTu.Add("CP"); dsLoaiChungTu.Add("KH_DN"); dsLoaiChungTu.Add("KH_SD"); dsLoaiChungTu.Add("KH_BX"); foreach (RpChiTietNganSach tmp in lst) { if (malk != tmp.MaLoaiKhoan) { tmpCapTong = new RpChiTietNganSach(); tmpCapTong.MaCt = "KH"; tmpCapTong.Loai = tmp.Loai; tmpCapTong.Khoan = tmp.Khoan; tmpConLai = new RpChiTietNganSach(); tmpConLai.MaCt = "CN"; tmpConLai.Loai = tmp.Loai; tmpConLai.Khoan = tmp.Khoan; lstthem.Add(tmpCapTong); lstthem.Add(tmpConLai); foreach (String tmplct in dsLoaiChungTu) { RpChiTietNganSach draff = new RpChiTietNganSach(); draff.MaCt = tmplct; draff.Loai = tmp.Loai; draff.Khoan = tmp.Khoan; lstthem.Add(draff); } malk = tmp.MaLoaiKhoan; } if (tmp.MaCt.StartsWith("KH")) { tmpCapTong.NDV_HC += tmp.NDV_HC; tmpCapTong.NDV_XB += tmp.NDV_XB; tmpCapTong.NDV_T += tmp.NDV_T; tmpCapTong.NDV_K += tmp.NDV_K; tmpConLai.NDV_HC += tmp.NDV_HC; tmpConLai.NDV_XB += tmp.NDV_XB; tmpConLai.NDV_T += tmp.NDV_T; tmpConLai.NDV_K += tmp.NDV_K; } else { tmpConLai.NDV_HC -= tmp.NDV_HC; tmpConLai.NDV_XB -= tmp.NDV_XB; tmpConLai.NDV_T -= tmp.NDV_T; tmpConLai.NDV_K -= tmp.NDV_K; } tmpCapTong.SoTien = tmpCapTong.NDV_HC + tmpCapTong.NDV_XB + tmpCapTong.NDV_T + tmpCapTong.NDV_K; tmpConLai.SoTien = tmpConLai.NDV_HC + tmpConLai.NDV_XB + tmpConLai.NDV_T + tmpConLai.NDV_K; } lst.AddRange(lstthem); return(lst); }