private void btnOk_Click(object sender, RoutedEventArgs e) { // MessageBox.Show(BienBll.Ndma); ServerInfor srv = new ServerInfor(); _cls.ClsConnect(); 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] = _str.Left(cboPos.SelectedValue.ToString().Trim(), 6); _dt = _cls.LoadDataProcPara("usp_NVBQIN", bien, giatri, thamso); if (_dt.Rows.Count > 0) { rpt_NVBQ rpt = new rpt_NVBQ(); RPUtility.ShowRp(rpt, _dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(), srv.DbPassSerVer()); FileName = Thumuc + "\\" + giatri[1] + "_SODU_NGUONVON_BQ_" + dtpNgay.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 { MessageBox.Show("Chưa có số liệu", "Thông báo"); } _cls.DongKetNoi(); }
private void btnOk_Click(object sender, RoutedEventArgs e) { //var lastMonth = new DateTime(dtpNgay.SelectedDate.Value.Year, dtpNgay.SelectedDate.Value.Month, DateTime.DaysInMonth(dtpNgay.SelectedDate.Value.Year, dtpNgay.SelectedDate.Value.Month)); cls.ClsConnect(); try { int thamso = 2; string[] bien = new string[thamso]; object[] giatri = new object[thamso]; bien[0] = "@Ma"; giatri[0] = bll.Left(CboCanbo.SelectedValue.ToString().Trim(), 10); bien[1] = "@Ngay"; if (dtpNgay.SelectedDate != null) { giatri[1] = dtpNgay.SelectedDate.Value.ToString("yyyy-MM-dd"); } dt = cls.LoadDataProcPara("usp_ChamCongPC", bien, giatri, thamso); if (dt.Rows.Count > 0) { rpt_ChamCong06 rpt = new rpt_ChamCong06(); RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(), srv.DbPassSerVer()); } else { MessageBox.Show("Không có bản ghi nào!", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Warning); } } catch (Exception ex) { MessageBox.Show(ex.Message); } cls.DongKetNoi(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { try { str.TaoThuMuc(Thumuc); } catch (Exception ex) { MessageBox.Show("Lổi tạo thư mục " + ex.Message, "Thông báo", MessageBoxButton.OK, MessageBoxImage.Error); } cls.ClsConnect(); DataTable dtng = new DataTable(); DataTable dtpos = 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 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 = 0; cls.DongKetNoi(); }
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()); dtpDNgay.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"; 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 = 1; //CboPos_SelectionChanged(null, null); //if (cls.KiemTraKetNoi() == false) cls.ClsConnect(); string sqlMau = "select * from Kt740 order by TT"; var dtMau = cls.LoadDataText(sqlMau); for (int i = 0; i < dtMau.Rows.Count; i++) { CboMau.Items.Add(dtMau.Rows[i][1] + " | " + dtMau.Rows[i][2]); } CboMau.SelectedIndex = 0; cls.DongKetNoi(); }
private void Them_OnClick(object sender, RoutedEventArgs e) { try { _cls.ClsConnect(); string strchk = "select * from " + tablename + " where MA='" + txtMa.Text.Trim() + "'"; var dtchk = _cls.LoadDataText(strchk); if (dtchk.Rows.Count == 0) { string strup = "insert into " + tablename + " (MA,TEN,MA_THELOAI) values ('" + txtMa.Text.Trim() + "',N'" + txtTen.Text.Trim() + "','" + txtMaTheLoai.Text.Trim() + "')"; _cls.UpdateDataText(strup); MessageBox.Show("Thêm thành công !", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Information); GetForm_OnMouseDown(null, null); } else { MessageBox.Show("Không thể thêm mã này vì đã tồn tại mã " + txtMa.Text + " trong bảng " + dttable, "Mess", MessageBoxButton.OK, MessageBoxImage.Error); } } catch (Exception ex) { MessageBox.Show("Error \n" + ex.Message, "Mess", MessageBoxButton.OK, MessageBoxImage.Error); } finally { _cls.DongKetNoi(); } }
private void OK_OnClick(object sender, RoutedEventArgs e) { try { _cls.ClsConnect(); string pos = RadCboPos.SelectedValue.ToString().Trim(); string quy = ((int.Parse(dtpNgay.SelectedDate.Value.ToString("MM")) - 1) / 3 + 1).ToString(); string thang = dtpNgay.SelectedDate.Value.ToString("MM"); string nam = dtpNgay.SelectedDate.Value.ToString("yyyy"); string ng = dtpNgay.SelectedDate.Value.ToString("yyyy-MM-dd"); string ngayky = dtpNgayKy.SelectedDate.Value.ToString("yyyy-MM-dd"); string strsql = "INSERT INTO TT_VBCD (NGAY, THANG, NAM,SOVB,NOIDUNG,MA_CIF,MA_CVU,POS,QUY,NGAYKY) " + " VALUES ('" + ng + "', '" + thang + "', '" + nam + "',N'" + txtSoVB.Text + "',N'" + txtNoiDung.Text + "','" + RadCboKy.SelectedValue + "','" + RadCboCvu.SelectedValue + "','" + pos + "','" + quy + "','" + ngayky + "'); "; _cls.UpdateDataText(strsql); MessageBox.Show("Lưu thành công !", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { MessageBox.Show("Error \n" + ex.Message, "Mess", MessageBoxButton.OK, MessageBoxImage.Error); } finally { _cls.DongKetNoi(); } }
private void OK_OnClick(object sender, RoutedEventArgs e) { try { _cls.ClsConnect(); foreach (DataRow dr in _dt.Rows) { string strup = "update MAU_THIDUA set DIEM='" + dr["DIEM"] + "',TT='" + dr["TT"] + "', CHITIEU= N'" + dr["CHITIEU"] + "',INDAM='" + dr["INDAM"] + "',NGHIENG='" + dr["NGHIENG"] + "',CONG='" + dr["CONG"] + "' where NAM='" + comboBoxYear.SelectedValue + "' and QUY='" + CboQuy.SelectionBoxItem.ToString().Trim() + "' and DOT='" + bll.Left(RadCboDot.SelectedValue.ToString(), 1) + "' and STT=" + dr["STT"] + " and CHUYENDE='" + RadCboChDe.SelectedValue.ToString().Trim() + "'"; //MessageBox.Show(strup); _cls.UpdateDataText(strup); } MessageBox.Show("Lưu thành công !", "Mess", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { MessageBox.Show("Error \n" + ex.Message, "Mess", MessageBoxButton.OK, MessageBoxImage.Error); } finally { _cls.DongKetNoi(); } }
private void OK_OnClick(object sender, RoutedEventArgs e) { try { cls.ClsConnect(); int thamso = 1; string[] bien = new string[thamso]; object[] giatri = new object[thamso]; bien[0] = "@Ngay"; giatri[0] = DtpNgay.SelectedDate.Value.ToString("yyyy-MM-dd"); dt = cls.LoadDataProcPara("usp_D21NHNN", bien, giatri, thamso); if (dt.Rows.Count > 0) { FileName = Thumuc + "\\" + DtpNgay.SelectedDate.Value.ToString("ddMMyyyy") + "_SoLieu_NHNN.xlsx"; bll.WriteDataTableToExcel(dt, "Person Details", FileName, "Details"); MessageBox.Show("OK đã xuất file Excel " + FileName, "Mess", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("Không có dữ liệu", "Mess", MessageBoxButton.OK, MessageBoxImage.Warning); } } catch (Exception ex) { MessageBox.Show("Error \n" + ex.Message, "Mess", MessageBoxButton.OK, MessageBoxImage.Error); } finally { cls.DongKetNoi(); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { //dtpNgay.SelectedDate = DateTime.Now.AddDays(-1); try { cls.ClsConnect(); const 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.ItemsSource = dtpos.DefaultView; CboPos.SelectedValuePath = "PO_MA"; CboPos.DisplayMemberPath = "PO_TEN"; CboPos.SelectedIndex = 1; /* * const string sqlload = "select * from CBTD "; * dt = cls.LoadDataText(sqlload); * dgvData.ItemsSource = dt.DefaultView; */ } catch (Exception ex) { MessageBox.Show("Tiếp tục" + ex.Message, "Mess"); } cls.DongKetNoi(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { dtpNgay.SelectedDate = DateTime.Now.AddDays(-1); try { _cls.ClsConnect(); if (BienBll.NdMadv == BienBll.MainPos) { sql = "select PO_MA,PO_TEN from DMPOS order by PO_MA"; } else { sql = "select PO_MA,PO_TEN from DMPOS where PO_MA='" + BienBll.NdMadv + "'"; } 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 = 1; var dtng = _cls.LoadDataText("select MAX(convert(date,NGAY,105)) as NGMAX from U_CANDOI"); dtpNgay.SelectedDate = DateTime.Parse(dtng.Rows[0]["NGMAX"].ToString()); } catch (Exception ex) { MessageBox.Show("Tiếp tục" + ex.Message, "Mess"); } _cls.DongKetNoi(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { //MessageBox.Show(DateTime.Now.AddYears(-1).ToString("yyyy")); //dtpTuNgay.SelectedDate = DateTime.Parse("31/12/" + DateTime.Now.AddYears(-1).ToString("yyyy")); //dtpNgay.SelectedDate = DateTime.Now.Date; //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(); if (BienBll.NdMadv == BienBll.MainPos) { sql = "select PO_MA,PO_TEN from DMPOS order by PO_MA"; } else { sql = "select PO_MA,PO_TEN from DMPOS where PO_MA='" + BienBll.NdMadv + "'"; } 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 = 1; 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(); }
//string Thumuc = "C:\\Saoke"; //private string FileName = ""; private void Window_Loaded(object sender, RoutedEventArgs e) { cls.ClsConnect(); DataTable dtng = new DataTable(); DataTable dtpos = new DataTable(); DataTable dtdvut = 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 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 = 0; * * string sqldv = "select DVUT,TENDV from DVUT order by DVUT"; * dtdvut = cls.LoadDataText(sqldv); * for (int i = 0; i < dtdvut.Rows.Count; i++) * { * CboDvut.Items.Add(dtdvut.Rows[i][0] + " | " + dtdvut.Rows[i][1]); * } * CboDvut.SelectedIndex = 0; */ cls.DongKetNoi(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { try { dtpNgay.SelectedDate = DateTime.Now; cls.ClsConnect(); string sql = "select PO_MA,PO_TEN from DMPOS where PO_MA=" + "'" + BienBll.NdMadv.Trim() + "'"; //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'"; 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; CboPB.Items.Clear(); if (BienBll.NdMadv.Trim() == BienBll.MainPos.Trim()) { dtxa = cls.LoadDataText("select * from DM_PHONGBAN where MA in ('18','19','20','21','22') order by MA"); } else { dtxa = cls.LoadDataText("select * from DM_PHONGBAN where MA in ('29','30','31') order by MA"); } for (int i = 0; i < dtxa.Rows.Count; i++) { CboPB.Items.Add(dtxa.Rows[i][0].ToString().Trim() + " | " + dtxa.Rows[i][1]); } cls.DongKetNoi(); } catch (Exception ex) { MessageBox.Show("Tiếp tục" + ex.Message, "Mess"); } cls.DongKetNoi(); }
private void LblGetData_OnMouseDown(object sender, MouseButtonEventArgs e) { dt = null; dgvData.ItemsSource = null; try { cls.ClsConnect(); strsql = " select '" + dtpNgay.SelectedDate.Value.ToString("yyyy-MM-dd") + "' NGAY,b.PO_MA,b.PO_TEN,c.ND_MA,c.ND_TEN,a.* from DANHGIAGV a,DMPOS b, NG_DUNG c where b.PO_MA = c.ND_MADV and ND_MA='" + BienBll.Ndma.Trim() + "'"; //MessageBox.Show(strsql); dt = cls.LoadDataText(strsql); if (dt.Rows.Count > 0) { dgvData.ItemsSource = dt.DefaultView; } else { MessageBox.Show("Không có dữ liệu !", "Thông Báo", MessageBoxButton.OK, MessageBoxImage.Warning); } } catch (Exception ex) { MessageBox.Show("Tiếp tục" + ex.Message, "Mess"); } cls.DongKetNoi(); }
private void OK_OnClick(object sender, RoutedEventArgs e) { try { _cls.ClsConnect(); dtNew = _dt.GetChanges(); if (dtNew == null) { MessageBox.Show("Chưa có giá trị nào thay đổi !", "Thông Báo", MessageBoxButton.OK, MessageBoxImage.Warning); } else { foreach (DataRow dr in dtNew.Rows) { string sql = "update MAUKHB set DUCUOI=" + dr["DUCUOI"] + " where DT_MAPGD='" + dr["DT_MAPGD"] + "' and DT_CAPDT='" + dr["DT_CAPDT"] + "' and NGAY='" + dtpNgay.SelectedDate.Value.ToString("yyyy-MM-dd") + "' and DT_MAPGD='" + bll.Left(cboPos.SelectedValue.ToString().Trim(), 6) + "' and KU_CHTRINH='" + dr["KU_CHTRINH"] + "'"; _cls.UpdateDataText(sql); } MessageBox.Show("Save data OK", "Mess", MessageBoxButton.OK, MessageBoxImage.Information); } } catch (Exception ex) { MessageBox.Show("Error \n" + ex.Message, "Mess", MessageBoxButton.OK, MessageBoxImage.Error); } finally { _cls.DongKetNoi(); } }
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 order by PO_MA"; //if (BienBll.NdMadv == BienBll.MainPos) // strphong = "select * from DM_PHONGBAN where ma in ('17','18','19','20','21','22','34') order by MA"; //else strphong = "select * from DM_PHONGBAN where ma not in ('17','18','19','20','21','22','34')"; //strphong = "select * from DM_PHONGBAN where MA='"+BienBll.PhongBan+"'"; var dtpos = cls.LoadDataText(strpos); CboPos.ItemsSource = dtpos.DefaultView; CboPos.DisplayMemberPath = "TEN"; CboPos.SelectedValuePath = "MA"; } catch (Exception ex) { MessageBox.Show("Tiếp tục" + ex.Message, "Mess"); } cls.DongKetNoi(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { try { // dtpNgay.SelectedDate = DateTime.Now; 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()).AddMonths(-1); //DateTime lastMonth = new DateTime(dtpNgay.SelectedDate.Value.Year, dtpNgay.SelectedDate.Value.Month, //DateTime.DaysInMonth(dtpNgay.SelectedDate.Value.Year, dtpNgay.SelectedDate.Value.Month)); //dtpNgay.SelectedDate = lastMonth; string sql; sql = "select PO_MA MA,PO_TEN TEN from DMPOS where PO_MA=" + "'" + BienBll.NdMadv.Trim() + "'"; var dtpos = cls.LoadDataText(sql); CboPos.ItemsSource = dtpos.DefaultView; CboPos.DisplayMemberPath = "TEN"; CboPos.SelectedValuePath = "MA"; CboPos.SelectedIndex = 0; var sqlpb = "select a.MA,a.TEN from DMXA a where a.PGD_QL='" + CboPos.SelectedValue + "' and right(a.MA,2)<>'00' order by a.MA"; var dtloaits = cls.LoadDataText(sqlpb); CboXa.ItemsSource = dtloaits.DefaultView; CboXa.DisplayMemberPath = "TEN"; CboXa.SelectedValuePath = "MA"; CboXa.SelectedIndex = 0; } catch (Exception ex) { MessageBox.Show("Tiếp tục" + ex.Message, "Mess"); } cls.DongKetNoi(); }
private void OK_OnClick(object sender, RoutedEventArgs e) { try { cls.ClsConnect(); int thamso = 3; string[] bien = new string[thamso]; object[] giatri = new object[thamso]; bien[0] = "@MaPos"; giatri[0] = str.Left(CboPos.SelectedValue.ToString().Trim(), 6); bien[1] = "@MaXa"; giatri[1] = str.Left(CboXa.SelectedValue.ToString().Trim(), 6); bien[2] = "@Ngay"; if (dtpNgay.SelectedDate != null) { giatri[2] = dtpNgay.SelectedDate.Value.ToString("yyyy-MM-dd"); } dt = cls.LoadLdbf("usp_XLN_M1", bien, giatri, thamso); if (dt.Rows.Count > 0) { rpt_XLN_M1 rpt = new rpt_XLN_M1(); RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(), srv.DbPassSerVer()); } else { MessageBox.Show("Không có khế ước nào đến hạn !", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Warning); } } catch (Exception ex) { MessageBox.Show("Error \n" + ex.Message, "Mess", MessageBoxButton.OK, MessageBoxImage.Error); } finally { cls.DongKetNoi(); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { // GroupBox.IsEnabled = false; try { cls.ClsConnect(); //DataTable dtpos; 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"; var dtpos = cls.LoadDataText(sql); for (var i = 0; i < dtpos.Rows.Count; i++) { CboPos.Items.Add(dtpos.Rows[i][0] + " | " + dtpos.Rows[i][1]); } CboPos.SelectedIndex = BienBll.NdCapbc.Trim() == "1" ? 0 : 5; var dtng = cls.LoadDataText("select MAX(convert(date,NGAYKU,105)) as NGMAX from U_HSTD"); DtpDenNgay.SelectedDate = DateTime.Parse(dtng.Rows[0]["NGMAX"].ToString()); //var ngay = DtpDenNgay.SelectedDate.Value.AddMonths(-1); //DtpNgay.SelectedDate = DateTime.Parse(ngay.ToString("yyyy-MM") + "-" + DateTime.DaysInMonth(ngay.Year, ngay.Month)); //DtpDenNgay.SelectedDate = DateTime.Parse(DtpNgay.SelectedDate.Value.ToString("yyyy-MM") + "-" + DateTime.DaysInMonth(DtpNgay.SelectedDate.Value.Year, DtpNgay.SelectedDate.Value.Month).ToString()); } catch (Exception ex) { MessageBox.Show("Tiếp tục" + ex.Message, "Mess"); } cls.DongKetNoi(); }
private void btnOk_Click(object sender, RoutedEventArgs e) { try { ServerInfor srv = new ServerInfor(); cls.ClsConnect(); 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] = str.Left(cboPos.SelectedValue.ToString().Trim(), 6); dt = cls.LoadDataProcPara("usp_Khtc03", bien, giatri, thamso); if (dt.Rows.Count > 0) { rpt_khtc03 rpt = new rpt_khtc03(); 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"); } cls.DongKetNoi(); } catch (Exception ex) { MessageBox.Show("Lổi " + ex.Message, "Mess"); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { Ration1.IsChecked = true; dtpNgay.SelectedDate = DateTime.Now.AddDays(-1); dtpTuNgay.SelectedDate = DateTime.Now.AddDays(-30); dtpDenNgay.SelectedDate = DateTime.Now.AddDays(-1); try { cls.ClsConnect(); DataTable dtpos = new DataTable(); 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]); } 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("Tiếp tục" + ex.Message, "Mess"); } cls.DongKetNoi(); }
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_DonGia", bien, giatri, thamso); //MessageBox.Show(BienBll.NdMadv+" "+BienBll.MainPos); if (BienBll.NdMadv == BienBll.MainPos) { rpt_DonGia rpt = new rpt_DonGia(); RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(), srv.DbPassSerVer()); } else { rpt_DonGiaHuyen rpt = new rpt_DonGiaHuyen(); RPUtility.ShowRp(rpt, 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); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { try { cls.ClsConnect(); //DataTable dtpos; 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"; //var sql = "select PO_MA,PO_TEN from DMPOS where PO_MA='"+BienBll.NdMadv+"'"; var dtpos = cls.LoadDataText(sql); for (var i = 0; i < dtpos.Rows.Count; i++) { CboPos.Items.Add(dtpos.Rows[i][0] + " | " + dtpos.Rows[i][1]); } //CboPos.SelectedIndex = BienBll.NdCapbc.Trim() == "1" ? 0 : 5; var dtng = cls.LoadDataText("select MAX(convert(date,NGAYKU,105)) as NGMAX from U_HSTD"); dtpNgay.SelectedDate = DateTime.Parse(dtng.Rows[0]["NGMAX"].ToString()); //DtpDenNgay.SelectedDate = DateTime.Parse(DtpNgay.SelectedDate.Value.ToString("yyyy-MM") + "-" + DateTime.DaysInMonth(DtpNgay.SelectedDate.Value.Year, DtpNgay.SelectedDate.Value.Month).ToString()); var dvut = cls.LoadDataText("select * from dvut where dvut in ('11','12','13','14') order by DVUT"); for (var i = 0; i < dvut.Rows.Count; i++) { CboDvut.Items.Add(dvut.Rows[i][0] + " | " + dvut.Rows[i][1]); } } catch (Exception ex) { MessageBox.Show("Tiếp tục" + ex.Message, "Mess"); } cls.DongKetNoi(); }
private void btnOk_Click(object sender, RoutedEventArgs e) { str.TaoThuMuc(Thumuc); try { cls.ClsConnect(); string strsql = "select a.PLN_MAPGD,(select PO_TEN from dmpos where po_ma=a.pln_mapgd) TENPOS" + " , left(a.PLN_MADP, 6) MAXA,(select ten from dmxa where ma = left(a.PLN_MADP, 6)) TENXA " + " ,a.PLN_MATO,a.PLN_TENTT,a.PLN_MAKH,a.PLN_TENKH,CHAR(39) + a.PLN_SOKU SOKU " + " ,a.PLN_DNOTHAN,a.PLN_DNOQHAN,a.PLN_DNOKHOANH,a.PLN_K_KNTN_SODU from PLN_KNTN_CL a " + " where a.PLN_NGAYBC = '2018-06-30' and a.PLN_TT_MONVAY <> 'CLOSE' and a.PLN_TRANGTHAI = 'S' and a.PLN_K_KNTN_SODU > 0 " + " and a.PLN_K_KNTN_SD" + str.Left(CboNgNhan.SelectedValue.ToString(), 2) + ">0 order by a.PLN_MADP,a.PLN_MATO,a.PLN_MAKH"; dt = cls.LoadDataText(strsql); FileName = Thumuc + "\\" + str.Left(cboPos.SelectedValue.ToString(), 6) + "_" + CboNgNhan.SelectedValue.ToString().Substring(4, CboNgNhan.SelectedValue.ToString().Trim().Length - 4) + "_" + dtpNgay.SelectedDate.Value.ToString("ddMMyyyy") + ".csv"; MessageBox.Show(FileName); str.ExportToExcel(dt, FileName); MessageBox.Show("Copy Excel to : " + FileName, "Thông báo", MessageBoxButton.OK, MessageBoxImage.Information); str.OpenExcel(FileName); } catch (Exception ex) { MessageBox.Show(ex.Message); } cls.DongKetNoi(); }
private void lblCauHoi_MouseDown(object sender, MouseButtonEventArgs e) { try { if (dtpNgay.SelectedDate != null) { ng = dtpNgay.SelectedDate.Value.ToString("yyyy-MM-dd"); } reset_clock(); string sql = ""; str.TaoThuMuc(Thumuc); cls.ClsConnect(); var dtchk = cls.LoadDataText("select * from KQTHINV where USERNAME='******' and NGAY='" + ng + "'"); if (dtchk.Rows.Count == 0) { sql = "insert into KQTHINV select LOAI, CAUHOI, A, B, C, D, DAPAN, TT, POS,'" + BienBll.NdTen.Trim() + "' NG_NHAP,0 VONG,'" + BienBll.Ndma.Trim() + "' USERNAME, TRALOI,CANCU,NGAY from CAUHOI where NGAY='" + ng + "'"; cls.LoadDataText(sql); } dt = cls.LoadDataText("select * from KQTHINV where USERNAME='******' and NGAY='" + ng + "' and TRALOI is null"); if (dt.Rows.Count > 0) { 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]; } StreamReader srl = new StreamReader(filename); while (srl.Peek() >= 0) { lst.Add(srl.ReadLine()); Sodong = Sodong + 1; } cls.DongKetNoi(); lblCauHoi.IsEnabled = false; star_clock(); } else { MessageBox.Show("Bạn đã làm xong bài thi của mình rồi !", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Information); } } catch (Exception ex) { MessageBox.Show("Error " + ex.Message, "Thông báo", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void OK_OnClick(object sender, RoutedEventArgs e) { try { cls.ClsConnect(); int thamso = 3; string[] bien = new string[thamso]; object[] giatri = new object[thamso]; bien[0] = "@MaPos"; giatri[0] = bll.Left(CboPos.SelectedValue.ToString().Trim(), 6); bien[1] = "@Ngay"; if (DtpNgay.SelectedDate != null) { giatri[1] = DtpNgay.SelectedDate.Value.ToString("yyyy-MM-dd"); bien[2] = "@DenNgay"; if (DtpDenNgay.SelectedDate != null) { giatri[2] = DtpDenNgay.SelectedDate.Value.ToString("yyyy-MM-dd"); dt = cls.LoadDataProcPara("usp_SkeDnKhoanh", bien, giatri, thamso); if (dt.Rows.Count > 0) { if (RadioButton1.IsChecked == true) { rpt_SkeKhoanh rpt = new rpt_SkeKhoanh(); RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(), srv.DbPassSerVer()); } else { FileName = Thumuc + "\\" + bll.Left(CboPos.SelectedValue.ToString().Trim(), 6) + "_" + DtpDenNgay.SelectedDate.Value.ToString("ddMMyyyy") + "_Ske_Khoanh.csv"; /*bll.WriteDataTableToExcel(dt, "Person Details", FileName, "Details"); * bll.ExportToExcel(dt, FileName); * MessageBox.Show("OK đã xuất file Excel " + FileName, "Mess", MessageBoxButton.OK, MessageBoxImage.Information); * bll.OpenExcel(FileName); */ //FileStream fs = new FileStream(FileName, FileMode.Create); //StreamWriter sw = new StreamWriter(fs, Encoding.Unicode); //bll.ToCSV(dt, sw, true); bll.ExportToExcel(dt, FileName); MessageBox.Show("Export to Excel : " + FileName, "Thông báo"); bll.OpenExcel(FileName); } } else { MessageBox.Show("Không có dữ liệu", "Mess", MessageBoxButton.OK, MessageBoxImage.Warning); } } } } catch (Exception ex) { MessageBox.Show("Error \n" + ex.Message, "Mess", MessageBoxButton.OK, MessageBoxImage.Error); } finally { cls.DongKetNoi(); } }
private void btnOk_Click(object sender, RoutedEventArgs e) { try { cls.ClsConnect(); int thamso = 4; string[] bien = new string[thamso]; object[] giatri = new object[thamso]; bien[0] = "@MaPos"; giatri[0] = bll.Left(CboPos.SelectedValue.ToString().Trim(), 6); bien[1] = "@Ngay"; giatri[1] = dtpNgay.SelectedDate.Value.ToString("dd/MM/yyyy"); if (giatri[1] == null) { MessageBox.Show("Chưa chọn ngày : ", "Mess"); return; } bien[2] = "@Mau"; if (Ration1.IsChecked == true) { giatri[2] = "1"; } else if (Ration2.IsChecked == true) { giatri[2] = "2"; } else { giatri[2] = "3"; } bien[3] = "@Nguon"; if (Ration4.IsChecked == true) { giatri[3] = "1"; } else if (Ration5.IsChecked == true) { giatri[3] = "2"; } else { giatri[3] = "3"; } //dt = cls.LoadDataProcPara("usp_PhanTichSL", bien, giatri, thamso); dt = cls.LoadLdbf("usp_PhanTichSL", bien, giatri, thamso); //dataGrid1.ItemsSource = dt.DefaultView; rpt_PhanTichSL rpt = new rpt_PhanTichSL(); RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(), srv.DbPassSerVer()); cls.DongKetNoi(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnReOk_Click(object sender, RoutedEventArgs e) { _cls.ClsConnect(); sql = "delete from LUU_DIENBAO where NGAY = '" + dtpNgay.SelectedDate.Value.ToString("yyyy-MM-dd") + "'"; //MessageBox.Show(sql); _cls.UpdateDataText(sql); _cls.DongKetNoi(); BtnOk_OnClick(null, null); }
private void Window_Loaded(object sender, RoutedEventArgs e) { 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()); cls.DongKetNoi(); }
private void btnOk_Click(object sender, RoutedEventArgs e) { #region try { cls.ClsConnect(); int thamso = 5; 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] = str.Left(CboPos.SelectedValue.ToString().Trim(), 6); bien[2] = "@MaXa"; giatri[2] = str.Left(CboXa.SelectedValue.ToString().Trim(), 6); bien[3] = "@Mau"; if (Ration1.IsChecked == true) { giatri[3] = "1"; } else if (Ration2.IsChecked == true) { giatri[3] = "2"; } else { giatri[3] = "3"; } bien[4] = "@Cqlv"; giatri[4] = str.Left(CboCqlv.SelectedValue.ToString().Trim(), 2); dt = cls.LoadLdbf("usp_QlyGqvl", bien, giatri, thamso); if (dt.Rows.Count > 0) { //rpt_QlyGqvl rpt = new rpt_QlyGqvl(); rpt_QlyGqvlNew rpt = new rpt_QlyGqvlNew(); RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(), srv.DbPassSerVer()); } else { MessageBox.Show("Không có số liệu", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Warning); } } catch (Exception ex) { MessageBox.Show(ex.Message); } cls.DongKetNoi(); #endregion }