public override void SetData(object objParam) { if (objParam == null) return; m_struct = (HPA.Common.SReport)objParam; //MessageBox.Show("Set data in Report view"); }
public override bool OnExport() { // validate data if (!ValidateInput()) { return false; } pnlInformation.Visible = true; // get parameter values paramValue = new string[grbFilter.Controls.Count / 2]; paramName = new string[grbFilter.Controls.Count / 2]; int count = 0; foreach (Control ctr in grbFilter.Controls) { if (ctr is Label) { // do nothing } else { try { //get values switch (ctr.Name.Substring(0, 3)) { case TXT_PREFIX: { TextBox txt = ctr as TextBox; if (txt.Name.ToLower().Contains(CommonConst.A_EmployeeID.ToLower()) && txt.Text.Equals("")) { paramName[count] = txt.Name.Substring(3); paramValue[count] = "-1"; } else { paramName[count] = txt.Name.Substring(3); paramValue[count] = txt.Text; } break; } case CBX_PREFIX: { DevExpress.XtraEditors.LookUpEdit cbx = (DevExpress.XtraEditors.LookUpEdit)ctr; paramName[count] = cbx.Name.Substring(3); paramValue[count] = cbx.EditValue.ToString(); break; } case DTP_PREFIX: { DateEdit dtp = ctr as DateEdit; paramName[count] = dtp.Name.Substring(3); paramValue[count] = dtp.EditValue.ToString(); break; } default: { break; } } count++; } catch (Exception ex) { pnlInformation.Visible = false; UIMessage.ShowMessage(ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } InputConditionValue(); //Export data // match Parameter name and value try { byte index = 0; object[] param = new object[(grbFilter.Controls.Count / 2) * 2 + 2]; for (byte i = 0; i < paramName.Length; i++) { param[index++] = paramName[i]; param[index++] = paramValue[i]; } //add loginID parameter param[index++] = CommonConst.A_LoginID; param[index++] = UserID; if (!txtExportType.Text.Trim().ToLower().Equals(EXPORT_TYPE)) { // get data from SQL and export to excell DataSet dsExport = DBEngine.execReturnDataSet(strSPName, param);//DBEngine.execReturnDataTable(strSPName, param); if ((dsExport == null) || (dsExport.Tables.Count <= 0)) return false; // Export data if (ckbCSV.Checked) ExportToCSV(dsExport.Tables[0]); else if (strExtend.Equals(DOC)) ExportToWord(dsExport.Tables[0], txtExcelFileName.Text); else { app = new Excel.Application(); app.UserControl = true; //System.Globalization.CultureInfo oldCI = System.Threading.Thread.CurrentThread.CurrentCulture; System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); ExportToExcel(dsExport); } }// view crystal report else { // report noneed LoginID string strReportName = txtExcelFileName.Text.Trim(); HPA.Common.SReport sRpt = new HPA.Common.SReport(); sRpt.ReportName = strReportName; sRpt.Parameters = param; object o = null; OpenObject("HPA.Report", "CReportView", true, sRpt, out o); } } catch (Exception ex) { pnlInformation.Visible = false; UIMessage.ShowMessage(ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Warning); } pnlInformation.Visible = false; return true; }