Ejemplo n.º 1
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     dtpTuNgay.SelectedDate  = DateTime.Now.AddMonths(-1);//DateTime.Parse("01/01/" + DateTime.Now.AddYears(-1).ToString("yyyy"));
     dtpDenNgay.SelectedDate = DateTime.Now.AddDays(-1);
     try
     {
         cls.ClsConnect();
         string sql   = "select PO_MA,PO_TEN from DMPOS order by PO_MA";
         var    dtpos = cls.LoadDataText(sql);
         for (int i = 0; i < dtpos.Rows.Count; i++)
         {
             CboPos.Items.Add(dtpos.Rows[i][0] + " | " + dtpos.Rows[i][1]);
         }
         CboPos.SelectedIndex = 0;
         var dtng = cls.LoadDataText("select MAX(convert(date,NGAYKU,105)) as NGMAX from U_HSTD");
         dtpNgay.SelectedDate = DateTime.Parse(dtng.Rows[0]["NGMAX"].ToString());
     }
     catch (Exception ex)
     {
         MessageBox.Show("Tiếp tục" + ex.Message, "Mess");
     }
     cls.DongKetNoi();
 }
Ejemplo n.º 2
0
 private void WpfNHNN_OnLoaded(object sender, RoutedEventArgs e)
 {
     try
     {
         cls.ClsConnect();
         var dtng = cls.LoadDataText("select MAX(convert(date,NGAYKU,105)) as NGMAX from U_HSTD");
         DtpNgay.SelectedDate = DateTime.Parse(dtng.Rows[0]["NGMAX"].ToString());
     }
     catch (Exception ex)
     {
         MessageBox.Show("Tiếp tục" + ex.Message, "Mess");
     }
     cls.DongKetNoi();
 }
Ejemplo n.º 3
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     //dtpNgay.SelectedDate = DateTime.Now.AddDays(-1);
     try
     {
         cls.ClsConnect();
         string sql = "select PO_MA,PO_TEN from DMPOS order by PO_MA";
         dtpos = cls.LoadDataText(sql);
         for (int i = 0; i < dtpos.Rows.Count; i++)
         {
             CboPos.Items.Add(dtpos.Rows[i][0] + " | " + dtpos.Rows[i][1]);
         }
         //CboPos.SelectedIndex = 5;
         DataTable dtng = new DataTable();
         dtng = cls.LoadDataText("select MAX(convert(date,NGAYKU,105)) as NGKU,MAX(convert(date,NGAYBT,105)) as NGBT from U_HSTD");
         dtpNgayKu.SelectedDate = DateTime.Parse(dtng.Rows[0]["NGKU"].ToString());
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error " + ex.Message, "Mess", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     cls.DongKetNoi();
 }
Ejemplo n.º 4
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     Ration7.IsChecked = true;
     CboXa.IsEnabled   = false;
     try
     {
         cls.ClsConnect();
         DataTable dtng = new DataTable();
         dtng = cls.LoadDataText("select MAX(convert(date,NGAYKU,105)) as NGMAX from U_HSTD");
         dtpNgay.SelectedDate = DateTime.Parse(dtng.Rows[0]["NGMAX"].ToString());
         string sql = "select PO_MA,PO_TEN from DMPOS order by PO_MA";
         dtpos = cls.LoadDataText(sql);
         for (int i = 0; i < dtpos.Rows.Count; i++)
         {
             CboPos.Items.Add(dtpos.Rows[i][0] + " | " + dtpos.Rows[i][1]);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Tiếp tục" + ex.Message, "Mess");
     }
     cls.DongKetNoi();
 }
Ejemplo n.º 5
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     try
     {
         cls.ClsConnect();
         DataTable dtpos = new DataTable();
         string    sql   = "select PO_MA,PO_TEN from DMPOS where PO_MA='" + BienBll.NdMadv.Trim() + "' order by PO_MA";
         dtpos = cls.LoadDataText(sql);
         for (int i = 0; i < dtpos.Rows.Count; i++)
         {
             CboPos.Items.Add(dtpos.Rows[i][0] + " | " + dtpos.Rows[i][1]);
         }
         CboPos.SelectedIndex = 0;
         DataTable dtng = new DataTable();
         dtng = cls.LoadDataText("select MAX(convert(date,NGAYKU,105)) as NGMAX from U_HSTD");
         dtpNgay.SelectedDate = DateTime.Parse(dtng.Rows[0]["NGMAX"].ToString());
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error " + ex.Message, "Thông báo", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     cls.DongKetNoi();
 }
Ejemplo n.º 6
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            dtpTuNgay.SelectedDate  = DateTime.Parse("01/01/" + DateTime.Now.ToString("yyyy"));
            dtpDenNgay.SelectedDate = DateTime.Now.Date;
            ClsServer cls = new ClsServer();

            cls.ClsConnect();

            /*
             * DataTable dtgl = new DataTable();
             * dtgl = cls.LoadDataText("select BANK_AC as TKGL,TK_CAP5 as TKSBV ,AC_DESC as TENTK from dmtkgl where left(BANK_AC,2) in ('92','94','97','98','93','99') order by BANK_AC");
             * for (int i = 0; i<dtgl.Rows.Count; i++)
             * {
             *  cboTk.Items.Add(dtgl.Rows[i][0] + "|" + dtgl.Rows[i][1] + "|" + dtgl.Rows[i][2]);
             * }
             */
            DataTable dtglc3 = new DataTable();

            dtglc3 = cls.LoadDataText("select BANK_AC as TKGL,TK_CAP5 as TKSBV ,AC_DESC as TENTK from dmtkgl where len(BANK_AC)=4 order by BANK_AC");
            for (int i = 0; i < dtglc3.Rows.Count; i++)
            {
                cboTkC3.Items.Add(dtglc3.Rows[i][0] + "|" + dtglc3.Rows[i][1] + "|" + dtglc3.Rows[i][2]);
            }

            DataTable dtpos = new DataTable();

            cls.ClsConnect();
            string sql = "select PO_MA,PO_TEN from DMPOS where PO_MACN=" + "'" + BienBll.MainPos + "'" + " order by PO_MA";

            dtpos = cls.LoadDataText(sql);
            for (int i = 0; i < dtpos.Rows.Count; i++)
            {
                cboPos.Items.Add(dtpos.Rows[i][0] + " | " + dtpos.Rows[i][1]);
            }
            cboPos.SelectedIndex = 7;
            // cls.DongKetNoi();
        }
Ejemplo n.º 7
0
 private void WpfTuyenTruyenVB_OnLoaded(object sender, RoutedEventArgs e)
 {
     try
     {
         dtpNgay.SelectedDate = DateTime.Now;
         _cls.ClsConnect();
         string strpos = BienBll.NdCapbc.Trim() == "02" ? string.Format("select PO_MA,PO_TEN from DMPOS where PO_MA='{0}'", BienBll.NdMadv.Trim()) : "select PO_MA,PO_TEN from DMPOS where right(PO_MA,2)<>'00'";
         var    dtpos  = _cls.LoadDataText(strpos);
         RadCboPos.ItemsSource       = dtpos.DefaultView;
         RadCboPos.DisplayMemberPath = "PO_TEN";
         RadCboPos.SelectedValuePath = "PO_MA";
         string strng = "";
         if (BienBll.NdCapbc.Trim() == "02")
         {
             strng =
                 "select MA_CIF,ND_TEN from ng_dung where ND_PHONGBAN='29' and ND_MADV='" + BienBll.NdMadv.Trim() + "' and ND_TTHAI='A' order by ND_CHUCVU";
         }
         else
         {
             strng =
                 "select MA_CIF,ND_TEN from ng_dung where ND_PHONGBAN='17' and ND_TTHAI='A' order by ND_CHUCVU";
         }
         var dtky = _cls.LoadDataText(strng);
         RadCboKy.ItemsSource       = dtky.DefaultView;
         RadCboKy.DisplayMemberPath = "ND_TEN";
         RadCboKy.SelectedValuePath = "MA_CIF";
         var dtcv = _cls.LoadDataText("select * from DM_CHUCVU where ma in ('1','2')");
         RadCboCvu.ItemsSource       = dtcv.DefaultView;
         RadCboCvu.DisplayMemberPath = "TEN";
         RadCboCvu.SelectedValuePath = "MA";
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error \n" + ex.Message, "Mess", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     _cls.DongKetNoi();
 }
Ejemplo n.º 8
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     try
     {
         cls.ClsConnect();
         string sql   = "select PO_MA,PO_TEN from DMPOS where PO_MA='" + BienBll.NdMadv.Trim() + "' order by PO_MA";
         var    dtpos = cls.LoadDataText(sql);
         for (int i = 0; i < dtpos.Rows.Count; i++)
         {
             CboPos.Items.Add(dtpos.Rows[i][0] + " | " + dtpos.Rows[i][1]);
         }
         CboPos.SelectedIndex = 0;
         dtpNgay.SelectedDate = DateTime.Parse(DateTime.Now.AddMonths(-1).ToString("yyyy-MM") + "-" + DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.AddMonths(-1).Month).ToString());
         for (int i = 1; i <= 12; i++)
         {
             CboThang.Items.Add(i.ToString("00"));
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error " + ex.Message, "Thông báo", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     cls.DongKetNoi();
 }
Ejemplo n.º 9
0
        private void BtnOk_OnClick(object sender, RoutedEventArgs e)
        {
            string ng  = dtpNgay.SelectedDate.Value.ToString("dd/MM/yyyy");
            string nam = dtpNgay.SelectedDate.Value.ToString("yyyy");

            _cls.ClsConnect();
            try
            {
                sql = "select a.NAMBC,'" + ng + "' NGAY,convert(datetime,left(NGAY_NHAP,7)+'-'+D1,102) NGAYBC,a.MAPGD,b.PO_TEN,a.MA MAXA,a.TEN TENXA,(case when a.D16=2 then 'X' else '' end) CAPTINH"
                      + " ,(case when a.D16<>2 then 'X' else '' end) CAPHUYEN ,cast(a.D15 as numeric(10, 1)) SODIEM,a.NGAY_NHAP,a.NGUOI_NHAP from DULIEU_NT a"
                      + " left join DMPOS b on a.MAPGD = b.PO_MA where nambc = '" + nam + "' and khoa = 'TDNN_001' and cast(a.D15 as numeric) > 0 order by a.MA,a.NGAYBC,a.NGAY_NHAP";
                string sql1 = "with lst1 as "
                              + " ( select distinct a.MA from dulieu_nt a where a.khoa = 'TDNN_001' and a.nambc = '" + nam + "' and a.MA not in "
                              + " (select distinct b.MA from dulieu_nt b where b.khoa = 'TDNN_001' and b.nambc = '" + nam + "' and cast(b.D15 as numeric) > 0 " + " and a.MA = b.MA) )"
                              + " select '" + nam + "' NAMBC,'" + ng + "' NGAY,'' NGAYBC,a.PGD_QL MAPGD, c.PO_TEN,a.MA MAXA, a.TEN TENXA,'' CAPTINH,'' CAPHUYEN,0 SODIEM,'' " + "NGAY_NHAP,'' NGUOI_NHAP "
                              + " from dmxa a left join DMPOS c on a.PGD_QL = c.PO_MA, lst1 b where a.MA = b.MA order by a.ma";
                _dt = _cls.LoadDataText(sql);
                var dt1 = _cls.LoadDataText(sql1);
                if (_dt.Rows.Count == 0)
                {
                    MessageBox.Show("Không có dữ liệu !", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Warning);
                    Close();
                }
                else
                {
                    rpt_KT3502 rpt = new rpt_KT3502();
                    RPUtility.ShowRp(rpt, _dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(), srv.DbPassSerVer());
                    RPUtility.ShowRp(rpt, dt1, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(), srv.DbPassSerVer());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error" + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            _cls.DongKetNoi();
        }
Ejemplo n.º 10
0
        private void cboTkC3_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            cboTk.Items.Clear();
            ClsServer cls = new ClsServer();

            cls.ClsConnect();
            DataTable dtgl = new DataTable();

            dtgl = cls.LoadDataText("select BANK_AC as TKGL,TK_CAP5 as TKSBV ,AC_DESC as TENTK from dmtkgl where left(BANK_AC,4) ='" + str.Left(cboTkC3.SelectedValue.ToString().Trim(), 4) + "' and len(BANK_AC)=10 order by BANK_AC");
            for (int i = 0; i < dtgl.Rows.Count; i++)
            {
                cboTk.Items.Add(dtgl.Rows[i][0] + "|" + dtgl.Rows[i][1] + "|" + dtgl.Rows[i][2]);
            }
            cls.DongKetNoi();
        }
Ejemplo n.º 11
0
        // kiem tra da ton tai du lieu hay chua
        public bool ExitsData(string strsql)
        {
            ClsServer cls = new ClsServer();

            cls.ClsConnect();
            DataTable dt  = new DataTable();
            string    str = strsql;

            dt = cls.LoadDataText(str);
            if (dt.Rows.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 12
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                cls.ClsConnect();
                var dtng = cls.LoadDataText("select MAX(NGAYBC) as NGMAX from QT_TSCC");
                dtpNgay.SelectedDate = DateTime.Parse(dtng.Rows[0]["NGMAX"].ToString());
                //DateTime lastMonth = new DateTime(dtpNgay.SelectedDate.Value.Year, dtpNgay.SelectedDate.Value.Month, DateTime.DaysInMonth(dtpNgay.SelectedDate.Value.Year, dtpNgay.SelectedDate.Value.Month));
                //if (BienBll.NdMadv == BienBll.MainPos)
                //{
                strpos = "select PO_MA MA,PO_TEN TEN from DMPOS  order by PO_MA";
                //    strphong = "select * from DM_PHONGBAN order by MA";
                //}
                //else
                //{
                //    strpos = "select PO_MA MA,PO_TEN TEN from DMPOS where PO_MA='"+CboPos.SelectedValue.ToString().Trim()+"'";
                //    strphong = "select * from DM_PHONGBAN where ma not in ('17','18','19','20','21','22','34')";
                //}
                //strpos = "select PO_MA MA,PO_TEN TEN from DMPOS where PO_MA='" + BienBll.NdMadv + "'";
                //strphong = "select * from DM_PHONGBAN where MA='"+BienBll.PhongBan+"'";
                var dtpos = cls.LoadDataText(strpos);
                CboPos.ItemsSource       = dtpos.DefaultView;
                CboPos.DisplayMemberPath = "TEN";
                CboPos.SelectedValuePath = "MA";

                var dtloaitsct = cls.LoadDataText("select * from loai_ts_chitiet order by ma");
                CboLoaiTSCT.ItemsSource       = dtloaitsct.DefaultView;
                CboLoaiTSCT.DisplayMemberPath = "TEN";
                CboLoaiTSCT.SelectedValuePath = "MA";
            }
            catch (Exception ex)
            {
                MessageBox.Show("Tiếp tục" + ex.Message, "Mess");
            }
            cls.DongKetNoi();
        }
Ejemplo n.º 13
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            string str = "";

            // dtpNgay.SelectedDate = DateTime.Parse("31/12/" + DateTime.Now.AddYears(-1).ToString("yyyy"));
            cls.ClsConnect();
            if (BienBll.NdMadv == BienBll.MainPos)
            {
                str = "select * from VARMCN where MAU='QT' and NHAPTAY='T'";
            }
            else
            {
                string field = "CN" + bll.Right(BienBll.NdMadv, 2);
                str = "select STT,TENBIEN," + field + " from VARMCN where MAU='QT'and NHAPTAY='T' ";
            }
            dt = cls.LoadDataText(str);
            dgvData.ItemsSource = dt.DefaultView;
            cls.DongKetNoi();
        }
Ejemplo n.º 14
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            cls.ClsConnect();
            var dtng = cls.LoadDataText("select MAX(convert(date,NGAYKU,105)) as NGMAX from U_HSTD");

            dtpNgay.SelectedDate = DateTime.Parse(dtng.Rows[0]["NGMAX"].ToString());
            //string sql = "select PO_MA,PO_TEN from DMPOS where PO_MACN=" + "'" + BienBll.MainPos + "'" + " order by PO_MA";
            //var sql = BienBll.NdCapbc.Trim() == "1" ? string.Format("select PO_MA,PO_TEN from DMPOS where PO_MA='{0}'", BienBll.NdMadv.Trim()) : "select PO_MA,PO_TEN from DMPOS where right(PO_MA,2)<>'00'";
            sql = "select PO_MA,PO_TEN from DMPOS where PO_MA='" + BienBll.NdMadv.Trim() + "'";
            var dtpos = cls.LoadDataText(sql);

            for (int i = 0; i < dtpos.Rows.Count; i++)
            {
                CboPos.Items.Add(dtpos.Rows[i][0] + " | " + dtpos.Rows[i][1]);
            }
            CboPos.SelectedIndex = 0;
            cls.DongKetNoi();
        }
Ejemplo n.º 15
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                cls.ClsConnect();

                dt = cls.LoadDataText("select cast(0 as bit) CHON,*,cast(tgdc as varchar(10)) ST from NG_DUNG where ND_TTHAI='A' and ND_MADV='" + BienBll.NdMadv.Trim() + "' order by ND_CMT");
                if (dt.Rows.Count > 0)
                {
                    dgvData.ItemsSource = dt.DefaultView;
                }
                else
                {
                    MessageBox.Show("Không có dữ liệu !", "Mess", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Tiếp tục" + ex.Message, "Mess");
            }
            cls.DongKetNoi();
        }
Ejemplo n.º 16
0
        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            ClsServer cls = new ClsServer();

            try
            {
                bll.TaoThuMuc(Thumuc);
                string pos = bll.Right(bll.Left(CboPos.SelectedValue.ToString().Trim(), 6), 4);
                cls.ClsConnect();
                string strsql = "with lst1 as ( select MA, TEN from DMTHON where LEFT(MA,4)= '" + pos + "' and TRANGTHAI = 'A' ), lst2 as ( "
                                + " select a.CT,a.NAM,LEFT(a.DP, 4) POS,LEFT(a.DP, 6) Xa, a.DP THON,(select ten from dmthon where a.dp = MA) TENTHON,COUNT(a.HOTEN) DEM "
                                + " from DANHSACH a where LEFT(DP,4)= '" + pos + "' and CT = '" + bll.Left(CboChTr.SelectedValue.ToString(), 2) + "' and NAM = '" + comboBoxYear.SelectedValue + "' "
                                + " group by LEFT(a.DP, 4),LEFT(a.DP, 6), a.DP,a.CT,a.NAM ) "
                                + " select LEFT(a.MA, 4) POS,(select po_ten from dmpos where LEFT(a.MA, 4) = right(po_ma, 4)) TENPOS "
                                + " ,left(a.MA, 6) N'Xã' ,(select TEN from dmxa where MA = left(a.MA, 6)) N'Tên Xã',a.MA N'Thôn',a.TEN N'Tên Thôn','" + comboBoxYear.SelectedValue + "' NAM,'" + bll.Left(CboChTr.SelectedValue.ToString(), 2) + "' CT "
                                + " ,(select GIATRI from dmkhac where khoa_1 = '07' and MOTA = b.CT) N'Tên CHTR',isnull(b.DEM, 0) N'Số khẩu' "
                                + " from lst1 a left join lst2 b on a.MA = b.THON order by a.MA";
                dt       = cls.LoadDataText(strsql);
                FileName = Thumuc + "\\" + pos + "_" + comboBoxYear.SelectedValue + "_" + bll.Left(CboChTr.SelectedValue.ToString(), 2) + "_Danh sách" + ".csv";
                if (dt.Rows.Count > 0)
                {
                    bll.ExportToExcel(dt, FileName);
                    MessageBox.Show("Copy Excel to : " + FileName, "Thông báo", MessageBoxButton.OK, MessageBoxImage.Information);
                    bll.OpenExcel(FileName);
                }
                else
                {
                    MessageBox.Show("Không có số liệu", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Warning);
                }

                //MessageBox.Show(strsql, "Thông báo", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error + " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            cls.DongKetNoi();
        }
Ejemplo n.º 17
0
 private void LblCheck_OnMouseDown(object sender, MouseButtonEventArgs e)
 {
     try
     {
         ClsServer cls = new ClsServer();
         cls.ClsConnect();
         string nam  = comboBoxYear.SelectedValue.ToString().Trim();
         string pos  = bll.Right(bll.Left(CboPos.SelectedValue.ToString(), 6), 4);
         string chtr = bll.Left(CboChTr.SelectedValue.ToString(), 2);
         FileName = thumuc + "\\" + nam + "_" + pos + "_" + chtr + "_" + DateTime.Now.ToString("ddMMyyyy") + ".csv";
         string chk = "with lst1 as ( select b.MA MAXA, b.TEN TENXA, a.MA MATHON, a.TEN TENTHON from DMTHON a, DMXA b where a.XA = b.MA and left(a.MA, 4) ='" + pos + "'"
                      + " ), lst2 as (select distinct a.CT,a.NAM,a.DP from DANHSACH a, DMTHON b where a.NAM = '" + nam + "' and a.CT = '" + chtr + "' and left(a.DP, 4)= '" + pos + "'"
                      + ") select " + chtr + " N'Chương Trình'," + nam + " N'Năm', a.MAXA N'Mã Xã',a.TENXA N'Tên Xã',a.MATHON N'Mã Thôn',a.TENTHON N'Tên Thôn',(select 'X' from lst2 where DP = a.MATHON) N'Đã nhập' from lst1 a order by a.MATHON";
         var dt = cls.LoadDataText(chk);
         bll.ExportToExcel(dt, FileName);
         bll.OpenExcel(FileName);
         cls.DongKetNoi();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Ejemplo n.º 18
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     dtpNgay.SelectedDate = DateTime.Now;
     try
     {
         cls.ClsConnect();
         var sql = "select * from NGUONGQVL where NHAP='T' order by TT";
         dt = cls.LoadDataText(sql);
         if (dt.Rows.Count > 0)
         {
             dgvData.ItemsSource = dt.DefaultView;
         }
         else
         {
             MessageBox.Show("Không có xã nào !", "Mess", MessageBoxButton.OK, MessageBoxImage.Warning);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Tiếp tục" + ex.Message, "Mess");
     }
     cls.DongKetNoi();
 }
Ejemplo n.º 19
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     // var now = BienBll.EndOfYearBefor.AddMonths(DateTime.Now.Month-2);//DateTime.Now.AddMonths(-1);
     //dtpNgayTr.SelectedDate = BienBll.EndOfYearBefor.AddMonths(now.Month);
     //dtpNgay.SelectedDate = dtpNgayTr.SelectedDate.Value.AddMonths(1);
     dtpNgay.SelectedDate = DateTime.Parse(DateTime.Now.AddMonths(-1).ToString("yyyy-MM") + "-" + DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.AddMonths(-1).Month).ToString());
     try
     {
         cls.ClsConnect();
         DataTable dtpos = new DataTable();
         string    sql   = "select PO_MA,PO_TEN from DMPOS where PO_MACN=" + "'" + BienBll.MainPos + "'" + " order by PO_MA";
         dtpos = cls.LoadDataText(sql);
         for (int i = 0; i < dtpos.Rows.Count; i++)
         {
             cboPos.Items.Add(dtpos.Rows[i][0] + " | " + dtpos.Rows[i][1]);
         }
         cboPos.SelectedIndex = 1;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Tiếp tục" + ex.Message, "Mess");
     }
     cls.DongKetNoi();
 }
Ejemplo n.º 20
0
 private void WpfTdChamDiem_OnLoaded(object sender, RoutedEventArgs e)
 {
     PopulateMonthsAndYears();
     dtpNgay.SelectedDate = DateTime.Parse(DateTime.Now.AddMonths(-1).ToString("yyyy-MM") + "-" + DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.AddMonths(-1).Month).ToString());
     if (BienBll.NdCapbc == "02")
     {
         ChkTh.IsEnabled = false;
     }
     try
     {
         _cls.ClsConnect();
         var dtpos = _cls.LoadDataText("select PO_MA,PO_TEN from DMPOS where PO_MA='" + BienBll.NdMadv.Trim() + "'");
         for (int i = 0; i < dtpos.Rows.Count; i++)
         {
             CboPos.Items.Add(dtpos.Rows[i][0] + " | " + dtpos.Rows[i][1]);
         }
         CboPos.SelectedIndex = 0;
         var dtdot = _cls.LoadDataText("select * from DOT_THIDUA order by DOT");
         for (int i = 0; i < dtdot.Rows.Count; i++)
         {
             CboDot.Items.Add(dtdot.Rows[i][0].ToString().Trim() + " | " + dtdot.Rows[i][1]);
         }
         CboDot.SelectedIndex = 0;
         var dtchde =
             _cls.LoadDataText(
                 "select * from CHUYENDE order by MA");
         RadCboChDe.ItemsSource       = dtchde.DefaultView;
         RadCboChDe.DisplayMemberPath = "TEN";
         RadCboChDe.SelectedValuePath = "MA";
         RadCboChDe.SelectedIndex     = 0;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Tiếp tục" + ex.Message, "Mess");
     }
     _cls.DongKetNoi();
 }
Ejemplo n.º 21
0
        private void Print_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                _cls.ClsConnect();
                if (chkth.IsChecked == true)
                {
                    str = "select * from MAU_THIDUA where NAM='" +
                          comboBoxYear.SelectedValue + "' and QUY='" + CboQuy.SelectionBoxItem.ToString().Trim() +
                          "' and DOT='" + bll.Left(RadCboDot.SelectedValue.ToString(), 1) + "' and CHONIN='1' order by CHUYENDE,STT";
                }
                else
                {
                    str = "select * from MAU_THIDUA where NAM='" +
                          comboBoxYear.SelectedValue + "' and QUY='" + CboQuy.SelectionBoxItem.ToString().Trim() +
                          "' and DOT='" + bll.Left(RadCboDot.SelectedValue.ToString(), 1) + "'and CHUYENDE='" + RadCboChDe.SelectedValue.ToString().Trim() + "' and CHONIN='1' order by STT";
                }

                var dtin = _cls.LoadDataText(str);
                if (chkth.IsChecked == true)
                {
                    rpt_ThiDua04 rpt = new rpt_ThiDua04();
                    RPUtility.ShowRp(rpt, dtin, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(),
                                     srv.DbPassSerVer());
                }
                else
                {
                    rpt_ThiDua rpt = new rpt_ThiDua();
                    RPUtility.ShowRp(rpt, dtin, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(),
                                     srv.DbPassSerVer());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error \n" + ex.Message, "Mess", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                _cls.DongKetNoi();
            }
        }
Ejemplo n.º 22
0
        private void lblCauHoi_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                reset_clock();
                string sql = "";
                str.TaoThuMuc(Thumuc);
                cls.ClsConnect();

                dtvong = cls.LoadDataText("select max(VONG) VONG,count(*) DEM from KQTHINV where USERNAME='******' and LOAI='" + CboChuDe.SelectionBoxItem.ToString().Trim() + "'");
                if (dtvong.Rows[0]["DEM"].ToString() == "0")
                {
                    vong  = "0";
                    socau = "0";
                }
                else
                {
                    vong = dtvong.Rows[0]["VONG"].ToString();
                    if (CboChuDe.SelectionBoxItem.ToString().Trim() == "AL")
                    {
                        dtsocau = cls.LoadDataText(
                            "select cast(max(VONG) as int) VONG,count(*) DEM from KQTHINV where USERNAME='******' and VONG='" + vong + "' and TRALOI is null ");
                    }
                    else
                    {
                        dtsocau = cls.LoadDataText(
                            "select cast(max(VONG) as int) VONG,count(*) DEM from KQTHINV where USERNAME='******' and VONG='" + vong + "' and TRALOI is null and LOAI='" + CboChuDe.SelectionBoxItem.ToString().Trim() + "'");
                    }

                    if (dtsocau.Rows.Count > 0)
                    {
                        socau = dtsocau.Rows[0]["DEM"].ToString();
                    }
                    txtVong.Text = BienBll.NdTen + " Đang Thi Vòng Số : " + vong + " Số Câu Chưa Trả Lời : " + socau;
                }

                if (vong == "0" & socau == "0")
                {
                    if (CboChuDe.SelectionBoxItem.ToString().Trim() == "AL")
                    {
                        sql = "insert into KQTHINV select 'AL' LOAI, CAUHOI, A, B, C, D, DAPAN, TT, POS,'" +
                              BienBll.NdTen.Trim() +
                              "'  NG_NHAP,1 VONG,'" + BienBll.Ndma.Trim() + "' USERNAME, TRALOI,CANCU from CAUHOI order by TT";
                    }
                    else
                    {
                        sql = "insert into KQTHINV select LOAI, CAUHOI, A, B, C, D, DAPAN, TT, POS,'" +
                              BienBll.NdTen.Trim() +
                              "'  NG_NHAP,1 VONG,'" + BienBll.Ndma.Trim() + "' USERNAME, TRALOI,CANCU from CAUHOI where LOAI='" + CboChuDe.SelectionBoxItem.ToString().Trim() + "' order by TT";
                    }

                    cls.LoadDataText(sql);
                }
                else
                {
                    if (socau == "0")     //lam het cau tao vong moi
                    {
                        int    i = 0;
                        string s = vong;
                        i = int.Parse(s);
                        i = Convert.ToInt32(s) + 1;
                        if (CboChuDe.SelectionBoxItem.ToString().Trim() == "AL")
                        {
                            sql = "insert into KQTHINV select 'AL' LOAI, CAUHOI, A, B, C, D, DAPAN, TT, POS,'" +
                                  BienBll.NdTen.Trim() +
                                  "'  NG_NHAP," + i + " VONG,'" + BienBll.Ndma.Trim() +
                                  "' USERNAME, TRALOI,CANCU from CAUHOI order by TT";
                        }
                        else
                        {
                            sql = "insert into KQTHINV select LOAI, CAUHOI, A, B, C, D, DAPAN, TT, POS,'" +
                                  BienBll.NdTen.Trim() +
                                  "'  NG_NHAP," + i + " VONG,'" + BienBll.Ndma.Trim() + "' USERNAME, TRALOI,CANCU from CAUHOI where LOAI='" + CboChuDe.SelectionBoxItem.ToString().Trim() + "' order by TT";
                        }
                        cls.LoadDataText(sql);
                    }
                }
                //var dtsocau = cls.LoadDataText("select count(*) DEM from KQTHINV where USERNAME='******' and TRALOI is null");
                var dtsl = cls.LoadDataText("select max(VONG) VONG,count(*) DEM from KQTHINV where USERNAME='******' and TRALOI is null and LOAI='" + CboChuDe.SelectionBoxItem.ToString().Trim() + "'");
                if (dtsl.Rows.Count > 0)
                {
                    vong = dtsl.Rows[0]["VONG" +
                                        ""].ToString();
                    socau        = dtsl.Rows[0]["DEM"].ToString();
                    txtVong.Text = BienBll.NdTen + " Đang Thi Vòng Số : " + vong + " Số Câu Chưa Trả Lời : " + socau;
                    var dtsai =
                        cls.LoadDataText("select COUNT(*) dem from KQTHINV where VONG=" + vong + " and USERNAME='******' and DAPAN<>TRALOI and LOAI='" + CboChuDe.SelectionBoxItem.ToString().Trim() + "'");
                    socausai       = (int)dtsai.Rows[0]["DEM"];
                    lblSai.Content = socausai.ToString();
                    lblCon.Content = datraloi.ToString();
                }
                if (CboChuDe.SelectionBoxItem.ToString().Trim() == "AL")
                {
                    dt = cls.LoadDataText("select * from KQTHINV  where USERNAME='******' and TRALOI is null");
                }
                else
                {
                    dt = cls.LoadDataText("select * from KQTHINV  where USERNAME='******' and LOAI='" + CboChuDe.SelectionBoxItem + "' and TRALOI is null");
                }
                str.WriteText(dt, filename);
                StreamReader sr       = new StreamReader(filename);
                string       readLine = sr.ReadLine();
                if (readLine != null)
                {
                    string[] arrStr = readLine.Split('#');
                    txtCauHoi.Text = arrStr[1];
                    txtA.Text      = arrStr[2];
                    txtB.Text      = arrStr[3];
                    txtC.Text      = arrStr[4];
                    txtD.Text      = arrStr[5];
                    dapan          = arrStr[6];
                    TT             = arrStr[7];
                    cancu          = arrStr[13];
                }
                //MessageBox.Show(sql, "Thông báo", MessageBoxButton.OK, MessageBoxImage.Information);
                StreamReader srl = new StreamReader(filename);
                while (srl.Peek() >= 0)
                {
                    lst.Add(srl.ReadLine());
                    Sodong = Sodong + 1;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error " + ex.Message, "Thông báo", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            cls.DongKetNoi();
            lblCauHoi.IsEnabled = false;
            lblOk.IsEnabled     = false;
            Countdown(thoigian, TimeSpan.FromSeconds(1), cur => tb.Text = cur.ToString()); //tutm
            star_clock();
        }
Ejemplo n.º 23
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            str.TaoThuMuc(Thumuc);
            try
            {
                cls.ClsConnect();
                int      thamso = 6;
                string[] bien   = new string[thamso];
                object[] giatri = new object[thamso];
                bien[0]   = "@MaPos";
                giatri[0] = str.Left(cboPos.SelectedValue.ToString().Trim(), 6);
                bien[1]   = "@TuNgay";
                giatri[1] = dtpTuNgay.SelectedDate.Value.ToString("yyyy-MM-dd");
                bien[2]   = "@DenNgay";
                giatri[2] = dtpDenNgay.SelectedDate.Value.ToString("yyyy-MM-dd");
                bien[3]   = "@Chtr";
                giatri[3] = str.Left(CboChon.SelectedValue.ToString().Trim(), 2);
                bien[4]   = "@Mau";
                if (OptSke.IsChecked == true)
                {
                    giatri[4] = "0";
                }
                else if (OptChtr.IsChecked == true)
                {
                    giatri[4] = "1";                                 // chi tiet theo chuong trinh
                }
                else if (OptM03.IsChecked == true)
                {
                    giatri[4] = "2";                               //
                }
                bien[5]   = "@Ngay";
                giatri[5] = dtpNgay.SelectedDate.Value.ToString("yyyy-MM-dd");

                /*
                 * else if (OptM01.IsChecked==true) giatri[4] = "A";
                 * else if (OptM02.IsChecked == true) giatri[4] = "B";//Tông hợp tất cả các chương trình theo xã
                 */
                if (OptSke.IsChecked == true)
                {
                    if (str.Right(giatri[0].ToString(), 2) == "00")
                    {
                        strsql = " with lst1 as ( "
                                 + "select  a.KU_MAPGD, left(a.KU_MADP, 6) MAXA, a.KU_MATO, a.KU_MAKH, a.KU_SOKU, a.KU_CHTRINH, a.KU_NGAYGNCC NG_VAY, a.KU_NGAYDHAN_1, a.KU_DNOTHAN + a.KU_DNOQHAN + a.KU_DNOKHOANH DUNO "
                                 + ", dbo.SoThang(a.KU_NGAYGNCC, a.KU_NGAYDHAN_1) SOTHANG, a.KU_MAPNKT51 from HSCV_DAILY a where  a.KU_NGAYBC = '" + giatri[5] + "' and a.KU_DNOTHAN + a.KU_DNOQHAN + a.KU_DNOKHOANH > 0 and a.KU_TTMONVAY <> 'CLOSE' and a.KU_CHTRINH IN('01', '09', '19', '21') "
                                 + " ), lst1a as  ( select a.* from lst1 a where a.NG_VAY between '" + giatri[1] + "' and '" + giatri[2] + "' )"
                                 + ", lst1b as ( select a.* from lst1 a, lst1a b where a.KU_MAKH = b.KU_MAKH ), lst2 as ( select a.KU_MAKH,count(a.KU_MAKH) DEM,sum(a.DUNO) DUNO from lst1b a group by a.KU_MAKH having sum(a.DUNO) > 50000000 )"
                                 + " select a.KU_MAPGD,a.MAXA,d.TEN,a.KU_MATO,f.TO_TENTT,a.KU_MAKH,c.KH_TENKH,char(39) + a.KU_SOKU SOKU, a.KU_CHTRINH,e.TENVT, a.NG_VAY, a.KU_NGAYDHAN_1 NG_DHAN, a.DUNO, a.SOTHANG, a.KU_MAPNKT51 PNKT, g.TEN TEN_PNKT"
                                 + " , (case when(a.NG_VAY < '" + giatri[1] + "' and b.DEM > 1) or (a.NG_VAY > '" + giatri[1] + "' and b.DEM = 1)  then 1 else 2 end) LAN ,(case when (a.NG_VAY<'" + giatri[1] + "' and b.DEM>1) or (a.NG_VAY>'" + giatri[1] + "' and b.DEM=1) then a.DUNO else 0 end) DN_LAN1"
                                 + " ,(case when a.NG_VAY >= '" + giatri[1] + "' and b.DEM>1 then a.DUNO else 0 end) DN_LAN2 from lst1 a, lst2 b,hskh c, DMXA d,DM_CHTRINH e, HSTO f,DM_PNKT g "
                                 + " where a.KU_MAKH = b.KU_MAKH and a.KU_MAKH = c.KH_MAKH and a.MAXA = d.MA and a.KU_CHTRINH = e.CHTRINH and a.KU_MATO = f.TO_MATO and a.KU_MAPNKT51 = g.PNKT and c.KH_TTRANG='A' order by a.MAXA,a.KU_MAKH,a.KU_CHTRINH,a.NG_VAY";
                    }
                    else
                    {
                        strsql = " with lst1 as ( "
                                 + "select  a.KU_MAPGD, left(a.KU_MADP, 6) MAXA, a.KU_MATO, a.KU_MAKH, a.KU_SOKU, a.KU_CHTRINH, a.KU_NGAYGNCC NG_VAY, a.KU_NGAYDHAN_1, a.KU_DNOTHAN + a.KU_DNOQHAN + a.KU_DNOKHOANH DUNO "
                                 + ", dbo.SoThang(a.KU_NGAYGNCC, a.KU_NGAYDHAN_1) SOTHANG, a.KU_MAPNKT51 from HSCV_DAILY a where a.KU_MAPGD = '" + giatri[0] + "' and a.KU_NGAYBC = '" + giatri[5] + "' and a.KU_DNOTHAN + a.KU_DNOQHAN + a.KU_DNOKHOANH > 0 and a.KU_TTMONVAY <> 'CLOSE' and a.KU_CHTRINH IN('01', '09', '19', '21') "
                                 + " ), lst1a as  ( select a.* from lst1 a where a.NG_VAY between '" + giatri[1] + "' and '" + giatri[2] + "' )"
                                 + ", lst1b as ( select a.* from lst1 a, lst1a b where a.KU_MAKH = b.KU_MAKH ), lst2 as ( select a.KU_MAKH,count(a.KU_MAKH) DEM,sum(a.DUNO) DUNO from lst1b a group by a.KU_MAKH having sum(a.DUNO) > 50000000 )"
                                 + " select a.KU_MAPGD,a.MAXA,d.TEN,a.KU_MATO,f.TO_TENTT,a.KU_MAKH,c.KH_TENKH,char(39) + a.KU_SOKU SOKU, a.KU_CHTRINH,e.TENVT, a.NG_VAY, a.KU_NGAYDHAN_1 NG_DHAN, a.DUNO, a.SOTHANG, a.KU_MAPNKT51 PNKT, g.TEN TEN_PNKT"
                                 + " , (case when(a.NG_VAY < '" + giatri[1] + "' and b.DEM > 1) or (a.NG_VAY > '" + giatri[1] + "' and b.DEM = 1)  then 1 else 2 end) LAN ,(case when (a.NG_VAY<'" + giatri[1] + "' and b.DEM>1) or (a.NG_VAY>'" + giatri[1] + "' and b.DEM=1) then a.DUNO else 0 end) DN_LAN1"
                                 + " ,(case when a.NG_VAY >= '" + giatri[1] + "' and b.DEM>1 then a.DUNO else 0 end) DN_LAN2 from lst1 a, lst2 b,hskh c, DMXA d,DM_CHTRINH e, HSTO f,DM_PNKT g "
                                 + " where a.KU_MAKH = b.KU_MAKH and a.KU_MAKH = c.KH_MAKH and a.MAXA = d.MA and a.KU_CHTRINH = e.CHTRINH and a.KU_MATO = f.TO_MATO and a.KU_MAPNKT51 = g.PNKT and c.KH_TTRANG='A' order by a.MAXA,a.KU_MAKH,a.KU_CHTRINH,a.NG_VAY";
                    }

                    dt       = cls.LoadDataText(strsql);
                    FileName = Thumuc + "\\" + str.Left(cboPos.SelectedValue.ToString().Trim(), 6) + "_Cho vay nâng mức_từ ngày " + dtpTuNgay.SelectedDate.Value.ToString("ddMMyyyy") + "_Đến ngày_" + dtpDenNgay.SelectedDate.Value.ToString("ddMMyyyy") + ".csv";
                    str.ExportToExcel(dt, FileName);
                    MessageBox.Show("Copy Excel to : " + FileName, "Thông báo", MessageBoxButton.OK, MessageBoxImage.Information);
                    str.OpenExcel(FileName);
                }
                else if (str.Right(giatri[0].ToString(), 2) == "00")
                {
                    dt = cls.LoadDataProcPara("usp_ChovayNangmuc03", bien, giatri, thamso);
                }
                else
                {
                    dt = cls.LoadDataProcPara("usp_ChovayNangmuc", bien, giatri, thamso);
                }
                if (dt.Rows.Count > 0)
                {
                    if (OptChtr.IsChecked == true)
                    {
                        rpt_ChovayNangmuc01 rpt = new rpt_ChovayNangmuc01();
                        RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(), srv.DbPassSerVer());
                        // MessageBox.Show(OptChtr.Content.ToString());
                        FileName = Thumuc + "\\" + giatri[0] + "_" + OptChtr.Content + "_" + str.Left(CboChon.SelectedValue.ToString().Trim(), 2) + "_" + giatri[1] + "_Đến ngày_" + giatri[2] + ".xlsx";
                    }
                    else if (OptM03.IsChecked == true)
                    {
                        rpt_ChovayNangmuc03 rpt = new rpt_ChovayNangmuc03();
                        RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(), srv.DbPassSerVer());
                        FileName = Thumuc + "\\" + giatri[0] + "_Mãu 03BC_" + str.Left(CboChon.SelectedValue.ToString().Trim(), 2) + "_" + giatri[1] + "_Đến ngày_" + giatri[2] + ".xlsx";
                    }
                    // str.ExportToExcel(dt, FileName);
                    // str.OpenExcel(FileName);
                }
                else
                {
                    MessageBox.Show("Chưa có số liệu", "Thông báo");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            cls.DongKetNoi();
        }
Ejemplo n.º 24
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            cls.ClsConnect();
            bll.TaoThuMuc(Thumuc);
            try
            {
                string NGAY    = dtpNgay.SelectedDate.Value.ToString("dd/MM/yyyy");
                string TransCd = bll.Left(CboTranCd.SelectedValue.ToString().Trim(), 10);
                string strkt   = "select * from OfflineUp where TransCd = '" + TransCd + "'" + " and NGAYOFL = '" + NGAY + "'";
                cnn.ClsConnect();
                dtkt = cnn.LoadDataText(strkt);
                if (dtkt.Rows.Count > 0)
                {
                    MessageBox.Show("Đã thực hiện xuất số liệu, không thực hiện nữa", "Thông báo", MessageBoxButton.OK,
                                    MessageBoxImage.Warning);
                    btnOk.IsEnabled = false;
                    return;
                }
                else
                {
                    #region

                    string str = "select '00'+left(a.CommuneId,4) as MAPOS,c.TransCd" +
                                 " ,right(LEFT(b.BusinessDt,10),2)+'/'+SUBSTRING(LEFT(b.BusinessDt,10),5,2)+'/'+left(b.BusinessDt,4) as NGAY " +
                                 " ,right(LEFT(b.BusinessDt,10),2)+'-'+SUBSTRING(LEFT(b.BusinessDt,10),5,2)+'-'+left(b.BusinessDt,4) as NGAYQB " +
                                 " ,'KU' as MA,'11' as MNV,a.CommuneId as KH_MADP,left(a.CommuneId,6) as MAXA,c.GroupId as MATO, a.LoanNo as SOKU " +
                                 " ,a.CustomerId as MAKH,c.FullName as TENKH,LEFT(a.LoanProgramShort,2) as CHTRINH,a.Amount as MUCVAY" +
                                 ",CONVERT(decimal(28,12),0) as TNKH,CONVERT(decimal(28,12),0) as TNQH,a.FreezeAmount as DNKH,a.OverDueAmount as DNQH, " +
                                 " b.DisbursalAmount as SOTIEN	,right(LEFT(b.MakerDt,10),2)+'/'+SUBSTRING(LEFT(b.MakerDt,10),6,2)+'/'+left(b.MakerDt,4) as NGAYGD,'GN' as MOTA"+
                                 " from vLoanDetail a, BulkDisbursal b,Customer c  where b.DisbursalAmount>0 and c.GroupId<>'NOGROUP' and a.LoanNo=b.LoanNo and a.CustomerId=c.CustomerId " +
                                 " and right(LEFT(b.BusinessDt,10),2)+'/'+SUBSTRING(LEFT(b.BusinessDt,10),5,2)+'/'+left(b.BusinessDt,4) ='" +
                                 NGAY + "'" +
                                 " union	select '00'+left(a.CommuneId,4) as MAPOS,c.TransCd "+
                                 " ,RIGHT(b.BussinessDt, 2) + '/' + SUBSTRING(convert(varchar(10),b.BussinessDt), 5, 2) + '/' + LEFT(b.BussinessDt, 4) as NGAY " +
                                 " ,RIGHT(b.BussinessDt, 2) + '-' + SUBSTRING(convert(varchar(10),b.BussinessDt), 5, 2) + '-' + LEFT(b.BussinessDt, 4) as NGAYQB " +
                                 " ,'KU' as MA,'12' as MNV,a.CommuneId as KH_MADP,left(a.CommuneId,6) as MAXA,c.GroupId as MATO, a.LoanNo as SOKU " +
                                 " ,a.CustomerId as MAKH,c.FullName as TENKH,LEFT(a.LoanProgramShort,2) as CHTRINH,a.Amount as MUCVAY" +
                                 ",CONVERT(decimal(28,12),0) as TNKH,CONVERT(decimal(28,12),0) as TNQH,a.FreezeAmount as DNKH,a.OverDueAmount as DNQH, " +
                                 " b.TotalPrinPaid as SOTIEN	,right(LEFT(b.MakerDt,10),2)+'/'+SUBSTRING(LEFT(b.MakerDt,10),6,2)+'/'+left(b.MakerDt,4) as NGAYGD,'TN' as MOTA "+
                                 " from vLoanDetail a, BulkPayment b,Customer c  where b.TotalPrinPaid>0 and c.GroupId<>'NOGROUP' and a.LoanNo=b.LoanNo and a.CustomerId=c.CustomerId " +
                                 " and RIGHT(b.BussinessDt, 2) + '/' + SUBSTRING(convert(varchar(10),b.BussinessDt), 5, 2) + '/' + LEFT(b.BussinessDt, 4) = '" +
                                 NGAY + "'" +
                                 " union	select '00'+left(d.CommuneId,4) as MAPOS,c.TransCd "+
                                 " ,RIGHT(b.BussinessDt, 2) + '/' + SUBSTRING(convert(varchar(10),b.BussinessDt), 5, 2) + '/' + LEFT(b.BussinessDt, 4) as NGAY " +
                                 " ,RIGHT(b.BussinessDt, 2) + '-' + SUBSTRING(convert(varchar(10),b.BussinessDt), 5, 2) + '-' + LEFT(b.BussinessDt, 4) as NGAYQB " +
                                 " ,'TK' as MA,'13' as MNV,d.CommuneId as KH_MADP,left(d.CommuneId,6) as MAXA,c.GroupId as MATO, a.CasaNo as SOKU " +
                                 " ,a.CustomerId as MAKH,c.FullName as TENKH,'105' as CHTRINH,0 as MUCVAY" +
                                 ",CONVERT(decimal(28,12),0) as TNKH,CONVERT(decimal(28,12),0) as TNQH,0 as DNKH,0 as DNQH, " +
                                 " b.Deposit as SOTIEN,right(LEFT(b.MakerDt,10),2)+'/'+SUBSTRING(LEFT(b.MakerDt,10),6,2)+'/'+left(b.MakerDt,4) as NGAYGD,'GUITK' as MOTA " +
                                 " from Casa a, MicroSaving b,Customer c,vLoanDetail d " +
                                 " where  c.GroupId<>'NOGROUP' and a.CasaNo=b.CasaNo and a.CustomerId=c.CustomerId and c.CustomerId=a.CustomerId and a.CustomerId=d.CustomerId and b.Deposit<>0 " +
                                 " and RIGHT(b.BussinessDt, 2) + '/' + SUBSTRING(convert(varchar(10),b.BussinessDt), 5, 2) + '/' + LEFT(b.BussinessDt, 4) = '" +
                                 NGAY + "'" +
                                 " union	select '00'+left(d.CommuneId,4) as MAPOS,c.TransCd "+
                                 " ,RIGHT(b.BussinessDt, 2) + '/' + SUBSTRING(convert(varchar(10),b.BussinessDt), 5, 2) + '/' + LEFT(b.BussinessDt, 4) as NGAY " +
                                 " ,RIGHT(b.BussinessDt, 2) + '-' + SUBSTRING(convert(varchar(10),b.BussinessDt), 5, 2) + '-' + LEFT(b.BussinessDt, 4) as NGAYQB " +
                                 " ,'TK' as MA,'14' as MNV,d.CommuneId as KH_MADP,left(d.CommuneId,6) as MAXA,c.GroupId as MATO, a.CasaNo as SOKU " +
                                 " ,a.CustomerId as MAKH,c.FullName as TENKH,'105' as CHTRINH,0 as MUCVAY" +
                                 ",CONVERT(decimal(28,12),0) as TNKH,CONVERT(decimal(28,12),0) as TNQH,0 as DNKH,0 as DNQH, " +
                                 " b.Withdrawal as SOTIEN,right(LEFT(b.MakerDt,10),2)+'/'+SUBSTRING(LEFT(b.MakerDt,10),6,2)+'/'+left(b.MakerDt,4) as NGAYGD,'RUTTK' as MOTA " +
                                 " from Casa a, MicroSaving b,Customer c,vLoanDetail d " +
                                 " where c.GroupId<>'NOGROUP' and a.CasaNo=b.CasaNo and a.CustomerId=c.CustomerId and c.CustomerId=a.CustomerId and a.CustomerId=d.CustomerId and b.Withdrawal<>0 " +
                                 " and RIGHT(b.BussinessDt, 2) + '/' + SUBSTRING(convert(varchar(10),b.BussinessDt), 5, 2) + '/' + LEFT(b.BussinessDt, 4) = '" +
                                 NGAY + "'";

                    #endregion

                    dt = cls.LoadDataText(str);
                    if (dt.Rows.Count > 0)
                    {
                        #region

                        if (dt.Rows[0]["TransCd"].ToString().Trim() ==
                            bll.Left(CboTranCd.SelectedValue.ToString().Trim(), 10) &&
                            dt.Rows[0]["NGAY"].ToString().Trim() == NGAY)
                        {
                            dgvData.ItemsSource = dt.DefaultView;
                            //MessageBox.Show(dt.Rows[0]["TransCd"].ToString().Trim() + "  " + dt.Rows[0]["NGAY"].ToString().Trim());
                            InsertToTable();
                            //ClsConnectLocal cn = new ClsConnectLocal();
                            cnn.ClsConnect();
                            string ver = "insert into OfflineUp (MAPOS,TransCd,NGAYOFL) values ('" + dt.Rows[0]["MAPOS"] +
                                         "','" + dt.Rows[0]["TransCd"] + "','" + dt.Rows[0]["NGAY"] + "')";
                            cnn.UpdateDataText(ver);
                            cnn.DongKetNoi();
                        }
                        else
                        {
                            MessageBox.Show("Không đúng điểm giao dịch hoặc sai ngày ", "Thông báo", MessageBoxButton.OK,
                                            MessageBoxImage.Warning);
                            return;
                        }

                        #endregion
                    }
                    else
                    {
                        MessageBox.Show("không có dữ liệu, có thể xem lại ngày");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            cls.DongKetNoi();
        }
Ejemplo n.º 25
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            bll.TaoThuMuc(Thumuc);
            var lastMonth = new DateTime(dtpNgay.SelectedDate.Value.Year, dtpNgay.SelectedDate.Value.Month, DateTime.DaysInMonth(dtpNgay.SelectedDate.Value.Year, dtpNgay.SelectedDate.Value.Month));

            try
            {
                ServerInfor srv = new ServerInfor();
                cls.ClsConnect();
                const int thamso = 3;
                string[]  bien   = new string[thamso];
                object[]  giatri = new object[thamso];
                bien[0] = "@Ngay";
                if (dtpNgay.SelectedDate != null)
                {
                    giatri[0] = dtpNgay.SelectedDate.Value.ToString("yyyy-MM-dd");
                }
                bien[1] = "@Mato";
                if (Ration3.IsChecked == true)
                {
                    giatri[1] = bll.Left(cboXa.SelectedValue.ToString().Trim(), 6);
                }
                else
                {
                    giatri[1] = bll.Left(cboTo.SelectedValue.ToString().Trim(), 7);
                }
                bien[2] = "@Mau";
                if (Ration1.IsChecked == true || Ration5.IsChecked == true) // Mau KT
                {
                    giatri[2] = "1";
                }
                else //Mau Tat toan
                {
                    giatri[2] = "0";
                }

                if (Ration4.IsChecked == true)
                {
                    if (dtpNgay.SelectedDate.Value.ToString("yyyy-MM-dd") == lastMonth.ToString("yyyy-MM-dd"))
                    {
                        str = "select a.KU_MAPGD,left(a.KU_MADP,6) MAXA,c.TEN TENXA,a.KU_MATO,(select TO_TENTT from HSTO where TO_MATO=a.KU_MATO) TENTT,b.KH_MAKH,b.KH_TENKH,b.KH_TENVC "
                              + " ,char(39) + a.KU_SOKU SOKU, a.KU_CHTRINH,a.KU_MAQD,(select GIATRI from DMKHAC where KHOA_1='07' and KHOA_2=a.KU_MAQD) TENCHTR, a.KU_NGAYVAY, a.KU_NGAYDHAN_1, a.KU_NGAYDHAN_3 "
                              +
                              " , a.KU_DNOTHAN + a.KU_DNOQHAN + a.KU_DNOKHOANH DUNO, a.KU_LAITHAN + a.KU_LAIQHAN LAIDATHU, a.KU_LAITONTHAN + a.KU_LAITONQHAN LAITON "
                              +
                              " , (select SV_TENSV from HSSV where SV_SOKU = a.KU_SOKU) TENSV,a.KU_MAPNKT51,(select GIATRI from DMKHAC where KHOA_1 = '25' and KHOA_2 = a.KU_MAPNKT51) PNKT1 "
                              +
                              " ,a.KU_MAPNKT52,(select GIATRI from DMKHAC where KHOA_1 = '25' and KHOA_2 = a.KU_MAPNKT52) PNKT2,b.KH_DIACHI "
                              + " from HSKU a, HSKH b,DMXA c "
                              +
                              " where a.KU_DNOTHAN + a.KU_DNOQHAN + a.KU_DNOKHOANH>0 and a.KU_TTMONVAY<>'CLOSE' and a.KU_NGAYBC = '" +
                              giatri[0] + "' and a.KU_MATO = '" + giatri[1] +
                              "' and a.KU_MAKH = b.KH_MAKH and left(a.KU_MADP, 6)= c.MA order by b.KH_MAKH,a.KU_CHTRINH";
                    }
                    else
                    {
                        str = "select a.KU_MAPGD,left(a.KU_MADP,6) MAXA,c.TEN TENXA,a.KU_MATO,(select TO_TENTT from HSTO where TO_MATO=a.KU_MATO) TENTT,b.KH_MAKH,b.KH_TENKH, b.KH_TENVC "
                              + " ,char(39) + a.KU_SOKU SOKU, a.KU_CHTRINH,a.KU_MAQD,(select GIATRI from DMKHAC where KHOA_1='07' and KHOA_2=a.KU_MAQD) TENCHTR, a.KU_NGAYVAY, a.KU_NGAYDHAN_1, a.KU_NGAYDHAN_3 "
                              +
                              " , a.KU_DNOTHAN + a.KU_DNOQHAN + a.KU_DNOKHOANH DUNO, a.KU_LAITHAN + a.KU_LAIQHAN LAIDATHU, a.KU_LAITONTHAN + a.KU_LAITONQHAN LAITON "
                              +
                              " , (select SV_TENSV from HSSV where SV_SOKU = a.KU_SOKU) TENSV,a.KU_MAPNKT51,(select GIATRI from DMKHAC where KHOA_1 = '25' and KHOA_2 = a.KU_MAPNKT51) PNKT1 "
                              +
                              " ,a.KU_MAPNKT52,(select GIATRI from DMKHAC where KHOA_1 = '25' and KHOA_2 = a.KU_MAPNKT52) PNKT2,b.KH_DIACHI "
                              + " from HSCV_DAILY a, HSKH b,DMXA c "
                              +
                              " where a.KU_DNOTHAN + a.KU_DNOQHAN + a.KU_DNOKHOANH>0 and a.KU_TTMONVAY<>'CLOSE' and a.KU_NGAYBC = '" +
                              giatri[0] + "' and a.KU_MATO = '" + giatri[1] +
                              "' and a.KU_MAKH = b.KH_MAKH and left(a.KU_MADP, 6)= c.MA order by b.KH_MAKH,a.KU_CHTRINH";
                    }
                    dt       = cls.LoadDataText(str);
                    FileName = Thumuc + "\\" + bll.Left(cboPos.SelectedValue.ToString().Trim(), 6) + "_SKETO_" + bll.Left(cboTo.SelectedValue.ToString().Trim(), 7) + "_" + dtpNgay.SelectedDate.Value.ToString("ddMMyyyy") + ".csv";
                    bll.ExportToExcel(dt, FileName);
                    MessageBox.Show("Copy Excel to : " + FileName, "Thông báo", MessageBoxButton.OK, MessageBoxImage.Information);
                    bll.OpenExcel(FileName);
                }
                else
                {
                    dt = cls.LoadDataProcPara(Ration3.IsChecked != true ? "usp_sketo" : "usp_SkeBsungTT", bien, giatri, thamso);
                    //rpt_kt740_01 rpt = new rpt_kt740_01();
                    if (dt.Rows.Count > 0)
                    {
                        if (Ration1.IsChecked == true)
                        {
                            rpt_SkeTo rpt = new rpt_SkeTo();
                            RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(),
                                             srv.DbPassSerVer());
                        }
                        else if (Ration2.IsChecked == true)
                        {
                            rpt_SkeTo1 rpt = new rpt_SkeTo1();
                            RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(),
                                             srv.DbPassSerVer());
                        }
                        else if (Ration3.IsChecked == true)
                        {
                            rpt_SkeBsungTT rpt = new rpt_SkeBsungTT();
                            RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(),
                                             srv.DbPassSerVer());
                        }
                        else if (Ration5.IsChecked == true)
                        {
                            rpt_Mau06_01 rpt = new rpt_Mau06_01();
                            RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(),
                                             srv.DbPassSerVer());
                        }
                    }
                    else
                    {
                        MessageBox.Show("Chưa có số liệu", "Thông báo");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            cls.DongKetNoi();
        }
Ejemplo n.º 26
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            bll.TaoThuMuc(Thumuc);
            try
            {
                ServerInfor srv = new ServerInfor();
                cls.ClsConnect();
                DataTable dt     = new DataTable();
                int       thamso = 2;
                string[]  bien   = new string[thamso];
                object[]  giatri = new object[thamso];
                bien[0] = "@Ngay";
                if (dtpNgay.SelectedDate != null)
                {
                    giatri[0] = dtpNgay.SelectedDate.Value.ToString("yyyy-MM-dd");
                }
                bien[1]   = "@MaPos";
                giatri[1] = bll.Left(cboPos.SelectedValue.ToString().Trim(), 6);
                if (radioButton1.IsChecked == true)
                {
                    FileName = Thumuc + "\\D15NHNN_" + bll.Left(cboPos.SelectedValue.ToString().Trim(), 6) + "_" + dtpNgay.SelectedDate.Value.ToString("ddMMyyyy") + ".xlsx";
                    dt       = cls.LoadDataProcPara("usp_D15NHNN", bien, giatri, thamso);
                }
                else if (radioButton2.IsChecked == true)
                {
                    FileName = Thumuc + "\\D20NHNN_" + bll.Left(cboPos.SelectedValue.ToString().Trim(), 6) + "_" +
                               dtpNgay.SelectedDate.Value.ToString("ddMMyyyy") + ".xlsx";
                    dt = cls.LoadDataProcPara("usp_D20NHNN", bien, giatri, thamso);
                }
                else
                {
                    dt =
                        cls.LoadDataText(
                            "select CS_MAPGD,COUNT(distinct CS_MAKH) DEM from casa where CS_NGAYBC='" + dtpNgay.SelectedDate.Value.ToString("yyyy-MM-dd") + "' and CS_SODU_TK>0 group by CS_MAPGD");
                }

                if (dt.Rows.Count > 0)
                {
                    if (radioButton1.IsChecked == true || radioButton2.IsChecked == true)
                    {
                        bll.WriteDataTableToExcel(dt, "Details", FileName, "TUTM");
                        MessageBox.Show("Copy Excel to : " + FileName, "Thông báo", MessageBoxButton.OK,
                                        MessageBoxImage.Information);
                    }
                    if (radioButton1.IsChecked == true)
                    {
                        rpt_D15NHNN rpt = new rpt_D15NHNN();
                        RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(),
                                         srv.DbPassSerVer());
                    }
                    else if (radioButton2.IsChecked == true)
                    {
                        rpt_D20NHNN rpt = new rpt_D20NHNN();
                        RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(),
                                         srv.DbPassSerVer());
                    }
                    else
                    {
                        MessageBox.Show("CN01 : " + dt.Rows[0]["DEM"].ToString() + " | " + "CN02 : " + dt.Rows[1]["DEM"].ToString() + " | " + "CN03 : " + dt.Rows[2]["DEM"].ToString() + " | " + "CN04 : " + dt.Rows[3]["DEM"].ToString() + " | " + "CN05 : " + dt.Rows[4]["DEM"].ToString() + " | " + "CN06 : " + dt.Rows[5]["DEM"].ToString() + " | " + "CN07 : " + dt.Rows[6]["DEM"].ToString() + " | " + "CN08 : " + dt.Rows[7]["DEM"].ToString(), "Số hộ huy động vốn", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
                else
                {
                    MessageBox.Show("Chưa có số liệu", "Thông báo");
                }
                cls.DongKetNoi();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lổi " + ex.Message, "Thông báo", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 27
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if (cls.KiemTraKetNoi())
            {
                #region

                try
                {
                    cls.ClsConnect();
                    DataTable dt       = new DataTable();
                    String    userName = txtUserName.Text.Trim();
                    String    passWord = sBll.Encrypt(PassBox.Password.Trim(), true);
                    string    sql      = "select * from NG_DUNG where ND_MA= " + "'" + userName + "' and ND_MATKHAU= " + "'" +
                                         passWord + "'";
                    dt = cls.LoadDataText(sql);
                    if (dt.Rows.Count > 0)
                    {
                        DataRow dtr = dt.Rows[0];
                        BienBll.Ndma           = (string)dtr["ND_MA"];
                        BienBll.NdTen          = (string)dtr["ND_TEN"];
                        BienBll.NdDiachi       = (string)dtr["ND_DIACHI"];
                        BienBll.NdCapbc        = (string)dtr["ND_CAPBC"];
                        BienBll.NdMadv         = (string)dtr[9];
                        BienBll.Quyen          = (string)dtr["ND_QUYEN"];
                        BienBll.NdTrangThai    = (string)dtr["ND_TTHAI"];
                        BienBll.MainPos        = ConfigurationManager.AppSettings["MainPos"];
                        BienBll.LogIn          = (string)dtr["ND_LOGIN"];
                        BienBll.ChucVu         = (string)dtr["ND_CHUCVU"];
                        BienBll.PhongBan       = (string)dtr["ND_PHONGBAN"];
                        BienBll.ChamCong       = (string)dtr["CHAMCONG"];
                        BienBll.EndOfYearBefor = DateTime.Parse("31/12/" + DateTime.Now.AddYears(-1).ToString("yyyy"));
                        if (BienBll.NdTrangThai == "A")
                        {
                            /*
                             * if (BienBll.LogIn.Trim() == "T")
                             * {
                             *  MessageBox.Show(BienBll.NdTen.Trim()+" đang Login ở máy khác !", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Warning);
                             *  Close();
                             * }
                             * else
                             * {
                             *  string str = "update NG_DUNG set ND_LOGIN='******' where ND_MA='" + BienBll.Ndma.Trim() + "'";
                             *  cls.UpdateDataText(str);
                             *  var f = new MainWindow();
                             *  Hide();
                             *  f.ShowDialog();
                             *  Close();
                             * }
                             */
                            var f = new MainWindow();
                            Hide();
                            f.ShowDialog();
                            Close();
                        }
                        else
                        {
                            MessageBox.Show("Các Anh / Chị đang sử dụng phần mềm này thông cảm, phần mềm đóng từ ngày 16/06/2016 !", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Information);
                            Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("UserName or PassWord not correct", "Thông Báo", MessageBoxButton.OK,
                                        MessageBoxImage.Error);
                        txtUserName.Text = "";
                        PassBox.Password = "";
                    }
                    cls.DongKetNoi();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Kiểm tra kết nối máy chủ " + ex.Message + " Định dạng ngày tháng dd/MM/yyyy ", "Mess", MessageBoxButton.OK, MessageBoxImage.Error);
                }

                #endregion
            }
        }
Ejemplo n.º 28
0
        private void OK_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                _cls.ClsConnect();
                string quy     = ((int.Parse(dtpNgay.SelectedDate.Value.ToString("MM")) - 1) / 3 + 1).ToString();
                string nam     = dtpNgay.SelectedDate.Value.ToString("yyyy");
                string ng      = dtpNgay.SelectedDate.Value.ToString("yyyy-MM-dd");
                string ngay    = dtpNgay.SelectedDate.Value.ToString("ddMMyyyy");
                string pos     = RadCboPos.SelectedValue.ToString();
                string theloai = RadCboTheLoai.SelectedValue.ToString();
                string nguon   = RadCboNguon.SelectedValue.ToString();
                string tluong  = RadCboThoiLuong.SelectedValue.ToString();
                string cap     = RadCboCap.SelectedValue.ToString();
                string phong   = RadCboPhong.SelectedValue.ToString().Trim();
                string loaitin = RadCboLoaiTin.SelectedValue.ToString();
                string matin   = ngay.Trim() + pos.Trim() + phong.Trim() + theloai.Trim() + nguon.Trim();
                string sele    = "select * from TT_CAPNHAT where MATIN='" + matin + "'";
                var    dtchk   = _cls.LoadDataText(sele);
                if (dtchk.Rows.Count == 0)
                {
                    string str = "insert into TT_CAPNHAT values('" + matin + "','" + ng + "','" +
                                 pos + "','" + nam + "','" + quy + "','" + theloai + "','',N'" + txtTieuDe.Text + "','" +
                                 txtLink.Text + "','" + nguon + "','',N'" + BienBll.NdTen + "',N'" + txtGhiChu.Text + "','" + tluong + "','','" + cap + "','','" + phong + "','','" + loaitin + "','')";
                    _cls.UpdateDataText(str);
                    MessageBox.Show("Lưu thành công !", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Information);
                    ReLoad();
                }
                else
                {
                    MessageBox.Show("Mẫu tin " + matin + "đã tồn tại !", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Information);
                }

                /*
                 * string strin = "select a.NGAY N'Ngày',a.POS,b.PO_TEN N'Tên POS', c.TEN N'Thể loại', d.TEN N'Nguồn',a.TIEUDE N'Tiêu đề',a.LINK "
                 +" from TT_CAPNHAT a,DMPOS b, TT_THELOAI c,TT_NGUONTIN d where a.POS = b.PO_MA and a.MA_THELOAI = c.MA and a.MA_NGUON = d.MA"
                 +" and a.POS = '"+pos+"'order by a.NGAY";
                 * var dtin = _cls.LoadDataText(strin);
                 * string FileName = Thumuc + "\\" + pos + "_Tổng hợp thông tin tuyên truyền_" + dtpNgay.SelectedDate.Value.ToString("ddMMyyyy") + ".csv";
                 * bll.ExportToExcel(dtin, FileName);
                 */
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error \n" + ex.Message, "Mess", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                _cls.DongKetNoi();
            }
        }
Ejemplo n.º 29
0
        private void OK_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                _cls.ClsConnect();
                ListBox.Items.Clear();
                ListUp.Items.Clear();
                ListBak.Items.Clear();
                //------------------------------
                DirectoryInfo dirbak   = new DirectoryInfo(txtPathBak.Text.Trim());
                FileInfo[]    filesbak = dirbak.GetFiles("*.bak*");
                foreach (FileInfo filebak in filesbak)
                {
                    string DiemGd = filebak.Name.Trim();
                    string Ngay   = DiemGd.Substring(17, 8);//str.Right(DiemGd, 8);
                    string Maxa   = DiemGd.Substring(11, 6);
                    if (Ngay == dtpNgay.SelectedDate.Value.ToString("yyyyMMdd"))
                    {
                        //MessageBox.Show("Ma xa : " + Maxa + "   Ngay : " + Ngay);
                        string sqlgd = "select MA MAXA, TEN TENXA from DMXA where MA='" + Maxa + "'";
                        var    dtup  = _cls.LoadDataText(sqlgd);
                        foreach (DataRow dr in dtup.Rows)
                        {
                            ListBak.Items.Add(dr["MAXA"] + " | " + dr["TENXA"]);
                        }
                    }
                }

                //------------------------------
                DirectoryInfo dir   = new DirectoryInfo(txtPath.Text.Trim());
                FileInfo[]    files = dir.GetFiles("*.Offline*");
                foreach (FileInfo file in files)
                {
                    string DiemGd = file.Name.Trim();
                    string Ngay   = DiemGd.Substring(10, 8);//str.Right(DiemGd, 8);
                    string Maxa   = DiemGd.Substring(4, 6);
                    if (Ngay == dtpNgay.SelectedDate.Value.ToString("yyyyMMdd"))
                    {
                        //MessageBox.Show("Ma xa : " + Maxa + "   Ngay : " + Ngay);
                        string sqlgd = "select MA MAXA, TEN TENXA from DMXA where MA='" + Maxa + "'";
                        var    dtup  = _cls.LoadDataText(sqlgd);
                        foreach (DataRow dr in dtup.Rows)
                        {
                            ListBox.Items.Add(dr["MAXA"] + " | " + dr["TENXA"]);
                        }
                    }
                }
                if (ListBox.Items.Count == 0)
                {
                    MessageBox.Show("Ngày : " + dtpNgay.SelectedDate.Value.ToString("dd/MM/yyyy") + " không có giao dịch tại xã !", "Thông Báo", MessageBoxButton.OK, MessageBoxImage.None);
                }
                else
                {
                    string sql =
                        "select right(a.TransCd,6) MAXA,b.TEN TENXA from OfflineUp a,DMXA b where a.NGAYOFL='" +
                        dtpNgay.SelectedDate.Value.ToString("dd/MM/yyyy") +
                        "' and RIGHT(a.TransCd,6)=b.MA order by a.TransCd";
                    _dt = _cls.LoadDataText(sql);
                    //DataGrid.ItemsSource = _dt.DefaultView;
                    foreach (DataRow dr in _dt.Rows)
                    {
                        ListUp.Items.Add(dr["MAXA"] + " | " + dr["TENXA"]);
                    }
                    if (ListBox.Items.Count == ListUp.Items.Count)
                    {
                        ListBox.Items.Clear();
                        MessageBox.Show("OK Đã Upload All", "Thông Báo", MessageBoxButton.OK, MessageBoxImage.None);
                    }
                    else
                    {
                        for (int i = 0; i < ListBox.Items.Count; i++)
                        {
                            for (int j = 0; j < ListUp.Items.Count; j++)
                            {
                                //MessageBox.Show(str.Left(ListBox.Items[i].ToString().Trim(), 6) + "       " + str.Left(ListUp.Items[j].ToString().Trim(), 6));
                                if (str.Left(ListBox.Items[i].ToString().Trim(), 6) ==
                                    str.Left(ListUp.Items[j].ToString().Trim(), 6))
                                {
                                    //MessageBox.Show("Giatri I: " + i.ToString() + "Gia tri list box" + ListBox.Items.Count.ToString());
                                    ListBox.Items.RemoveAt(i);
                                }
                                //MessageBox.Show(ListBox.Items[i].ToString() + "       " + ListUp.Items[j].ToString());
                            }
                        }
                    }
                }
                //MessageBox.Show(sql, "Mess", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error \n" + ex.Message, "Mess", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                _cls.DongKetNoi();
            }
        }
Ejemplo n.º 30
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                cls.ClsConnect();
                const int thamso = 2;
                string[]  bien   = new string[thamso];
                object[]  giatri = new object[thamso];
                bien[0] = "@Ngay";
                if (dtpNgay.SelectedDate != null)
                {
                    giatri[0] = dtpNgay.SelectedDate.Value.ToString("dd/MM/yyyy");
                }
                bien[1]   = "@MaPos";
                giatri[1] = bll.Left(CboPos.SelectedValue.ToString().Trim(), 6);
                //MessageBox.Show(giatri[0].ToString() + "   " + giatri[1].ToString());
                //dt = cls.LoadDataProcPara("usp_QT_KHTC", bien, giatri, thamso);
                cls.LoadDataProcPara("usp_QT_KHTC", bien, giatri, thamso);

                if (BienBll.NdMadv == BienBll.MainPos)
                {
                    if (bll.Left(CboPos.SelectedValue.ToString().Trim(), 6) == "003000")
                    {
                        string str1 = "select * from TAM_KHTC where MAU='1' order by TT";
                        dt = cls.LoadDataText(str1);
                        rpt_QT_KHTC rpt = new rpt_QT_KHTC();
                        RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(),
                                         srv.DbPassSerVer());
                        string str2 = "select * from TAM_KHTC where MAU='2' order by TT";
                        dt = cls.LoadDataText(str2);
                        rpt_QT_KHTC rpt1 = new rpt_QT_KHTC();
                        RPUtility.ShowRp(rpt1, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(),
                                         srv.DbPassSerVer());
                    }
                    else
                    {
                        string str1 = "select * from TAM_KHTC where MAU='1' order by TT";
                        dt = cls.LoadDataText(str1);
                        rpt_QT_KHTCHuyen rpt = new rpt_QT_KHTCHuyen();
                        RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(), srv.DbPassSerVer());
                        string str2 = "select * from TAM_KHTC where MAU='2' order by TT";
                        dt = cls.LoadDataText(str2);
                        rpt_QT_KHTCHuyen rpt1 = new rpt_QT_KHTCHuyen();
                        RPUtility.ShowRp(rpt1, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(), srv.DbPassSerVer());
                    }
                }
                else
                {
                    string str1 = "select * from TAM_KHTC where MAU='1' order by TT";
                    dt = cls.LoadDataText(str1);
                    rpt_QT_KHTCHuyen rpt = new rpt_QT_KHTCHuyen();
                    RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(), srv.DbPassSerVer());
                    string str2 = "select * from TAM_KHTC where MAU='2' order by TT";
                    dt = cls.LoadDataText(str2);
                    rpt_QT_KHTCHuyen rpt1 = new rpt_QT_KHTCHuyen();
                    RPUtility.ShowRp(rpt1, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(), srv.DbPassSerVer());
                }

                cls.DongKetNoi();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lổi, liên hệ phòng tin học" + ex.Message, "Thông báo", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }