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 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); } }