예제 #1
0
        /// <summary>
        /// Load dữ liệu lên Grid
        /// </summary>
        private void LoadGrid(int stype)
        {
            try
            {
                HuyDongVonProcess huyDongVonProcess = new HuyDongVonProcess();

                AutoComboBox  auto        = new AutoComboBox();
                List <string> lstDieuKien = new List <string>();
                lstDieuKien.Add(AppConfig.LoginedUser.UserName);
                lstDieuKien.Add(AppConfig.LoginedUser.MaDonVi);
                lstDieuKien.Add(DatabaseConstant.ToChucDonVi.PGD.getValue());

                auto.GenAutoSoure(ref lstSourceDonVi, DatabaseConstant.DanhSachTruyVan.COMBOBOX_DONVI_THEOPVI.getValue(), lstDieuKien, AppConfig.LoginedUser.MaDonViGiaoDich);
                lstDieuKien.Clear();


                #region Điều kiện tìm kiếm
                string sMaDonVi = "";
                sMaDonVi = "(";
                string maChon = cmbDonVi.SelectedItem.Value;// lstSourceDonVi.ElementAt(cmbDonVi.SelectedIndex).KeywordStrings.ElementAt(0);
                string donVi  = "";
                foreach (AutoCompleteEntry item in lstSourceDonVi)
                {
                    donVi = item.KeywordStrings.ElementAt(0);
                    if (donVi.Contains(maChon))
                    {
                        sMaDonVi += "''" + donVi + "'',";
                    }
                }
                sMaDonVi  = sMaDonVi.Substring(0, sMaDonVi.Length - 1);
                sMaDonVi += ")";

                string sTrangThaiNVu = "";
                string sSoTGui = "%";
                string sTenSoTGui = "%";
                string sTuNgayMoSo = "%";
                string sDenNgayMoSo = "%";
                string sTuNgayDHan = "%";
                string sDenNgayDHan = "%";
                string soDuTu = "%";
                string soDuDen = "%";
                string iKyHanTu = "%";
                string iKyHanDen = "%";
                string sKyHanDonVi = "%";
                string sMaKH = "%";
                string sTenKH = "%";
                string sSoCMND = "%";
                string sSDT = "%";
                string sEmail = "%";
                string sNgayDC = "%";
                string sSanPham = "%", sIDNhom = "%", sCBQL = "%";

                if (cbChoduyet.Checked)
                {
                    sTrangThaiNVu = sTrangThaiNVu + "''" + cbChoduyet.Value + "'',";
                }
                if (cbDaduyet.Checked)
                {
                    sTrangThaiNVu = sTrangThaiNVu + "''" + cbDaduyet.Value + "'',";
                }
                if (cbThoaiduyet.Checked)
                {
                    sTrangThaiNVu = sTrangThaiNVu + "''" + cbThoaiduyet.Value + "'',";
                }
                if (cbTuchoi.Checked)
                {
                    sTrangThaiNVu = sTrangThaiNVu + "''" + cbTuchoi.Value + "'',";
                }
                if (sTrangThaiNVu != "")
                {
                    sTrangThaiNVu = "(" + sTrangThaiNVu.Substring(0, sTrangThaiNVu.Length - 1) + ")";
                }

                if (!txtSoSoTG.Text.IsNullOrEmpty())
                {
                    sSoTGui = txtSoSoTG.Text;
                }

                if (!raddtNgayMoSoTu.Text.IsNullOrEmpty())
                {
                    sTuNgayMoSo = LDateTime.StringToDate(raddtNgayMoSoTu.Text, "dd/MM/yyyy").ToString("yyyyMMdd");
                }

                if (!raddtNgayMoSoDen.Text.IsNullOrEmpty())
                {
                    sDenNgayMoSo = LDateTime.StringToDate(raddtNgayMoSoDen.Text, "dd/MM/yyyy").ToString("yyyyMMdd");
                }

                if (!raddtNgayDaoHanTu.Text.IsNullOrEmpty())
                {
                    sTuNgayDHan = LDateTime.StringToDate(raddtNgayDaoHanTu.Text, "dd/MM/yyyy").ToString("yyyyMMdd");
                }

                if (!raddtNgayDaoHanDen.Text.IsNullOrEmpty())
                {
                    sDenNgayDHan = LDateTime.StringToDate(raddtNgayDaoHanDen.Text, "dd/MM/yyyy").ToString("yyyyMMdd");
                }

                if (numSoDuTu.Text != "")
                {
                    soDuTu = numSoDuTu.Text.Replace(",", "").ToString();
                }

                if (numSoDuDen.Text != "")
                {
                    soDuDen = numSoDuDen.Text.Replace(",", "").ToString();
                }

                if (numKyHanTu.Text != "")
                {
                    iKyHanTu = numKyHanTu.Text.Replace(",", "").ToString();
                }

                if (numKyHanDen.Text != "")
                {
                    iKyHanDen = numKyHanDen.Text.Replace(",", "").ToString();
                }

                if (cmbKyHanTu.SelectedIndex >= 0)
                {
                    sKyHanDonVi = cmbKyHanTu.SelectedItem.Value;
                }

                if (!txtKhachHang.Text.IsNullOrEmptyOrSpace())
                {
                    sMaKH = txtKhachHang.Text;
                }

                if (!txtTenKhachHang.Text.IsNullOrEmptyOrSpace())
                {
                    sTenKH = txtTenKhachHang.Text;
                }
                //}

                #endregion
                // Phân trang
                int StartRow       = 1;
                int EndRow         = 999999999 * stype; // ClientInformation.SoLuongBanGhi;
                int CurrentPagging = 1;
                int PaggingSize    = 999999999;         // ClientInformation.SoLuongBanGhi;

                DataSet ds = huyDongVonProcess.GetDanhSachSoTGuiNhom(sMaDonVi, sSanPham, sIDNhom, sCBQL, sTrangThaiNVu, sSoTGui,
                                                                     sTenSoTGui, sTuNgayMoSo, sDenNgayMoSo, sTuNgayDHan, sDenNgayDHan,
                                                                     soDuTu, soDuDen, iKyHanTu, iKyHanDen, sKyHanDonVi,
                                                                     sMaKH, sTenKH, sSoCMND, sSDT, sEmail, sNgayDC, StartRow.ToString(), EndRow.ToString());
                if (ds != null && ds.Tables.Count > 0)
                {
                    //foreach (DataRow dr in ds.Tables[0].Rows)
                    //{
                    //    dr["TTHAI_NVU"] = BusinessConstant.layNgonNguNghiepVu(dr["TTHAI_NVU"].ToString());
                    //    if (!dr["KY_HAN_DVI_TINH"].IsNullOrEmpty() && !dr["KY_HAN_TGIAN"].IsNullOrEmpty() && !dr["KY_HAN"].IsNullOrEmpty())
                    //    {
                    //        if (!dr["KY_HAN_TGIAN"].ToString().Equals("0") && !dr["KY_HAN_DVI_TINH"].ToString().Equals(""))
                    //            dr["KY_HAN"] = dr["KY_HAN_TGIAN"] + " " + BusinessConstant.layNgonNguTuGiaTri(dr["KY_HAN_DVI_TINH"].ToString(), "TAN_SUAT");
                    //    }
                    //}

                    DataTable serverDataTable = ds.Tables[0];
                    int       totalRecord     = Int32.Parse(ds.Tables[1].Rows[0][0].ToString());
                    //DataTable clientDataTable = ds.Tables[0].Copy() ;// CommonFunction.BuildClientDataTable(serverDataTable, CurrentPagging, PaggingSize, totalRecord);

                    //dtSoTGui = ds.Tables[0];
                    //grSoTienGuiDS.DataContext = dtSoTGui.DefaultView;
                    dtSoTGui = serverDataTable;
                    grSoTienGuiDS.DataSource = serverDataTable;
                    grSoTienGuiDS.DataBind();

                    int     soSoTgui     = 0;
                    decimal tongSoDu     = 0;
                    decimal soDuBinhQuan = 0;
                    decimal tongSoDuGoc  = Decimal.Parse(ds.Tables[2].Rows[0][0].ToString());
                    decimal tongSoDuLai  = Decimal.Parse(ds.Tables[2].Rows[0][1].ToString());

                    if (totalRecord > 0)
                    {
                        soSoTgui = totalRecord;
                        for (int i = 0; i < dtSoTGui.Rows.Count; i++)
                        {
                            tongSoDu += Convert.ToDecimal(dtSoTGui.Rows[i]["SO_DU"]);
                        }
                        soDuBinhQuan = tongSoDu / soSoTgui;
                    }

                    lblSumSoSo.Text    = String.Format("{0:#,#}", soSoTgui);
                    lblSumSoDu.Text    = String.Format("{0:#,#}", tongSoDu);
                    lblSoDuBQ.Text     = String.Format("{0:#,#}", soDuBinhQuan);
                    lblSumSoDuGoc.Text = String.Format("{0:#,#}", tongSoDuGoc);
                    lblSumSoDuLai.Text = String.Format("{0:#,#}", tongSoDuLai);
                }
                else
                {
                    dtSoTGui.Rows.Clear();
                    grSoTienGuiDS.DataSource = dtSoTGui.DefaultView;
                    grSoTienGuiDS.DataBind();
                }
            }
            catch (Exception ex)
            {
                // LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex);
            }
        }
        private void LoadGrid()
        {
            try
            {
                HuyDongVonProcess huyDongVonProcess = new HuyDongVonProcess();
                DataSet           ds = null;
                if (function == DatabaseConstant.Function.HDV_LAI_NHAP_GOC_THEO_SO || function == DatabaseConstant.Function.HDV_LAI_NHAP_GOC_THEO_DANH_SACH)
                {
                    ds = huyDongVonProcess.GetDanhSachSoLNG(ClientInformation.MaDonViGiaoDich, sSanPham, sIDNhom, ClientInformation.NgayLamViecHienTai);
                }
                else if (function == DatabaseConstant.Function.HDV_RUT_BOT_GOC || function == DatabaseConstant.Function.HDV_RUT_GOC_THEO_DANH_SACH)
                {
                    ds = huyDongVonProcess.GetDanhSachSoRutGocNhom(ClientInformation.MaDonViGiaoDich, sSanPham, sIDNhom, ClientInformation.NgayLamViecHienTai);
                }
                else if (function == DatabaseConstant.Function.HDV_DU_CHI)
                {
                    ds = huyDongVonProcess.GetDanhSachSoDuChi(ClientInformation.MaDonViGiaoDich, sSanPham, sIDNhom, ClientInformation.NgayLamViecHienTai);
                }
                else if (function == DatabaseConstant.Function.HDV_TRA_LAI || function == DatabaseConstant.Function.HDV_TRA_LAI_THEO_DANH_SACH)
                {
                    ds = huyDongVonProcess.GetDanhSachSoTraLaiNhom(ClientInformation.MaDonViGiaoDich, sSanPham, sIDNhom, ClientInformation.NgayLamViecHienTai);
                }
                else if (function == DatabaseConstant.Function.HDV_TAT_TOAN || function == DatabaseConstant.Function.HDV_TAT_TOAN_THEO_DANH_SACH)
                {
                    ds = huyDongVonProcess.GetDanhSachSoTatToanNhom(ClientInformation.MaDonViGiaoDich, sSanPham, sIDNhom, ClientInformation.NgayLamViecHienTai);
                }
                else if (function == DatabaseConstant.Function.HDV_DIEU_CHINH_LS)
                {
                    ds = huyDongVonProcess.GetDanhSachSoThayDoiLS(ClientInformation.MaDonViGiaoDich, sSanPham, sIDNhom, ClientInformation.NgayLamViecHienTai);
                }
                else
                {
                    ds = huyDongVonProcess.GetDanhSachSoTGuiNhom(ClientInformation.MaDonViGiaoDich, sSanPham, sIDNhom);
                }

                if (ds != null)
                {
                    dtSoTGui = ds.Tables[0];
                    grSoTienGuiDS.ItemsSource = dtSoTGui;

                    int     soSoTgui     = 0;
                    decimal tongSoDu     = 0;
                    decimal soDuBinhQuan = 0;
                    if (dtSoTGui.Rows.Count > 0)
                    {
                        soSoTgui = dtSoTGui.Rows.Count;
                        for (int i = 0; i < dtSoTGui.Rows.Count; i++)
                        {
                            tongSoDu += Convert.ToDecimal(dtSoTGui.Rows[i]["SO_DU"]);
                        }
                        soDuBinhQuan = tongSoDu / soSoTgui;
                    }

                    lblSumSoSo.Content = String.Format("{0:#,#}", soSoTgui);
                    lblSumSoDu.Content = String.Format("{0:#,#}", tongSoDu);
                    lblSoDuBQ.Content  = String.Format("{0:#,#}", soDuBinhQuan);
                }
                else
                {
                    dtSoTGui.Rows.Clear();
                    grSoTienGuiDS.ItemsSource = dtSoTGui;
                }
            }
            catch (Exception ex)
            {
                LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex);
                throw ex;
            }
        }