private void LoadReport(int UserID) { cls_Report_User objUser = new cls_Report_User(); DataTable _dt = objUser.GetReportFollowUser(UserID); cboReport.DataValueField = "ID_Report"; cboReport.DataTextField = "Report_Name"; cboReport.DataSource = _dt; cboReport.DataBind(); if (cboReport.Items.Count > 0) { cboReport.SelectedIndex = 0; LoadControlToPage(Convert.ToInt32(cboReport.SelectedValue)); } }
private void LoadControlToPage(int ReportId) { try { Panel.Controls.Clear(); cls_Report_User objUser = new cls_Report_User(); DataSet _ds = objUser.GetConfigReport(ReportId); DataTable _dtConfig = _ds.Tables[0]; if (_dtConfig.Rows.Count == 0) return; ViewState["Config"] = _dtConfig; short TabIndex = 1; Label LB; string[] ArrRow =null; int t = 0; int k = 0; while (k < _dtConfig.Rows.Count) { if (ArrRow == null) Array.Resize(ref ArrRow, 1); else Array.Resize(ref ArrRow, ArrRow.Length + 1); if (k < _dtConfig.Rows.Count - 1 && (Convert.ToInt32(_dtConfig.Rows[k]["Width"]) + Convert.ToInt32(_dtConfig.Rows[k + 1]["Width"]) <= (848 - 848 / 3))) { ArrRow[t] = k.ToString() + ":" + (k + 1).ToString(); k++; } else { ArrRow[t] = k.ToString(); } t++; k++; } //Lay max text string strMax = ""; for (k = 0; k < ArrRow.Length; k++) { if (ArrRow[k] != null && ArrRow[k].Length > 0) { if (ArrRow[k].IndexOf(":") >= 0) { string[] ArStr = ArrRow[k].Split(':'); if (_dtConfig.Rows[Convert.ToInt32(ArStr[0])]["Parameter_Name"].ToString().Length > strMax.Length) strMax = _dtConfig.Rows[Convert.ToInt32(ArStr[0])]["Parameter_Name"].ToString(); } else { if (_dtConfig.Rows[Convert.ToInt32(ArrRow[k])]["Parameter_Name"].ToString().Length > strMax.Length) strMax = _dtConfig.Rows[Convert.ToInt32(ArrRow[k])]["Parameter_Name"].ToString(); } } } strMax += ": "; // for (k = 0; k < ArrRow.Length; k++) { if (k > 0) { HtmlAnchor te = new HtmlAnchor(); te.InnerHtml = "<br />"; Panel.Controls.Add(te); HtmlAnchor te1 = new HtmlAnchor(); te1.InnerHtml = "<br />"; Panel.Controls.Add(te1); } if (ArrRow[k].Length > 0) { if (ArrRow[k].IndexOf(":") >= 0) { string[] ArStr = ArrRow[k].Split(':'); for (int j = 0; j < ArStr.Length; j++) { LB = new Label(); if (j > 0) { HtmlAnchor tex = new HtmlAnchor(); //tex.InnerText = tex.InnerHtml = " "; Panel.Controls.Add(tex); } string str = _dtConfig.Rows[Convert.ToInt32(ArStr[j])]["Parameter_Name"].ToString() + ": "; LB.Text = str; Panel.Controls.Add(LB); if(j==0) if (str.Length < strMax.Length) { string sadd =""; for (int y = 0; y <= strMax.Length - str.Length;y++ ) sadd += " "; HtmlAnchor add = new HtmlAnchor(); add.InnerHtml = sadd; Panel.Controls.Add(add); } string sCate = _dtConfig.Rows[Convert.ToInt32(ArStr[j])]["Control_Type"].ToString(); if (sCate == "TextBox") { TextBox TB = new TextBox(); TB.ID = _dtConfig.Rows[Convert.ToInt32(ArStr[j])]["Parameter_Code"].ToString(); TB.Height = Convert.ToInt32(_dtConfig.Rows[Convert.ToInt32(ArStr[j])]["Height"]); TB.Width = Convert.ToInt32(_dtConfig.Rows[Convert.ToInt32(ArStr[j])]["Width"]); TB.TabIndex = TabIndex; Panel.Controls.Add(TB); } if (sCate == "DatePicker") { RadDatePicker date = new RadDatePicker(); date.Height = Convert.ToInt32(_dtConfig.Rows[Convert.ToInt32(ArStr[j])]["Height"]); date.Width = Convert.ToInt32(_dtConfig.Rows[Convert.ToInt32(ArStr[j])]["Width"]); date.Skin = "Vista"; date.DateInput.DateFormat = "dd/MM/yyyy"; date.ID = _dtConfig.Rows[Convert.ToInt32(ArStr[j])]["Parameter_Code"].ToString(); // date.Culture = new System.Globalization.CultureInfo("Vietnamese"); date.Font.Bold = true; date.Font.Name = "Times New Roman"; date.Font.Size = 12; date.SelectedDate = DateTime.Now; date.TabIndex = TabIndex; Panel.Controls.Add(date); } if (sCate == "DateTimePicker") { RadDateTimePicker date = new RadDateTimePicker(); date.Height = Convert.ToInt32(_dtConfig.Rows[Convert.ToInt32(ArStr[j])]["Height"]); date.Width = Convert.ToInt32(_dtConfig.Rows[Convert.ToInt32(ArStr[j])]["Width"]); date.Skin = "Vista"; date.DateInput.DateFormat = "dd/MM/yyyy"; date.ID = _dtConfig.Rows[Convert.ToInt32(ArStr[j])]["Parameter_Code"].ToString(); // date.Culture = new System.Globalization.CultureInfo("Vietnamese"); date.Font.Bold = true; date.Font.Name = "Times New Roman"; date.Font.Size = 12; date.SelectedDate = DateTime.Now; date.TabIndex = TabIndex; Panel.Controls.Add(date); } if (sCate == "ComboBox") { RadComboBox com = new RadComboBox(); com.Skin = "Vista"; com.Height = Convert.ToInt32(_dtConfig.Rows[Convert.ToInt32(ArStr[j])]["Height"])*5; com.Width = Convert.ToInt32(_dtConfig.Rows[Convert.ToInt32(ArStr[j])]["Width"]); com.ID = _dtConfig.Rows[Convert.ToInt32(ArStr[j])]["Parameter_Code"].ToString(); com.EnableVirtualScrolling = true; string SQL = _dtConfig.Rows[Convert.ToInt32(ArStr[j])]["Data_SQL"].ToString(); if (SQL.Length > 0) { DataTable _dt; if (_dtConfig.Rows[Convert.ToInt32(ArStr[j])]["IsSP"] != null && Convert.ToBoolean(_dtConfig.Rows[Convert.ToInt32(ArStr[j])]["IsSP"]) == true) { int Index = SQL.IndexOf('@'); if (Index >= 0) _dt = objUser.GetSP(SQL.Substring(0, Index), SQL.Substring(Index, SQL.Length - Index), Session["UserId"] == null ? "0" : Session["UserId"].ToString()); else _dt = objUser.GetSP(SQL); } else _dt = objUser.GetSQL(SQL); com.DataValueField = "ID"; com.DataTextField = "Name"; com.DataSource = _dt; com.DataBind(); } com.TabIndex = TabIndex; Panel.Controls.Add(com); } TabIndex++; } } else { LB = new Label(); string str = _dtConfig.Rows[Convert.ToInt32(ArrRow[k])]["Parameter_Name"].ToString() + ": "; LB.Text = str; Panel.Controls.Add(LB); if (str.Length < strMax.Length) { string sadd = ""; for (int y = 0; y <= strMax.Length - str.Length; y++) sadd += " "; HtmlAnchor add = new HtmlAnchor(); add.InnerHtml = sadd; Panel.Controls.Add(add); } string sCate = _dtConfig.Rows[Convert.ToInt32(ArrRow[k])]["Control_Type"].ToString(); if (sCate == "TextBox") { TextBox TB = new TextBox(); TB.ID = _dtConfig.Rows[Convert.ToInt32(ArrRow[k])]["Parameter_Code"].ToString(); TB.Height = Convert.ToInt32(_dtConfig.Rows[Convert.ToInt32(ArrRow[k])]["Height"]); TB.Width = Convert.ToInt32(_dtConfig.Rows[Convert.ToInt32(ArrRow[k])]["Width"]); TB.TabIndex = TabIndex; Panel.Controls.Add(TB); } if (sCate == "DatePicker") { RadDatePicker date = new RadDatePicker(); date.Height = Convert.ToInt32(_dtConfig.Rows[Convert.ToInt32(ArrRow[k])]["Height"]); date.Width = Convert.ToInt32(_dtConfig.Rows[Convert.ToInt32(ArrRow[k])]["Width"]); date.Skin = "Vista"; date.DateInput.DateFormat = "dd/MM/yyyy"; date.ID = _dtConfig.Rows[Convert.ToInt32(ArrRow[k])]["Parameter_Code"].ToString(); // date.Culture = new System.Globalization.CultureInfo("Vietnamese"); date.Font.Bold = true; date.Font.Name = "Times New Roman"; date.Font.Size = 12; date.SelectedDate = DateTime.Now; date.TabIndex = TabIndex; Panel.Controls.Add(date); } if (sCate == "DateTimePicker") { RadDateTimePicker date = new RadDateTimePicker(); date.Height = Convert.ToInt32(_dtConfig.Rows[Convert.ToInt32(ArrRow[k])]["Height"]); date.Width = Convert.ToInt32(_dtConfig.Rows[Convert.ToInt32(ArrRow[k])]["Width"]); date.Skin = "Vista"; date.DateInput.DateFormat = "dd/MM/yyyy"; date.ID = _dtConfig.Rows[Convert.ToInt32(ArrRow[k])]["Parameter_Code"].ToString(); // date.Culture = new System.Globalization.CultureInfo("Vietnamese"); date.Font.Bold = true; date.Font.Name = "Times New Roman"; date.Font.Size = 12; date.SelectedDate = DateTime.Now; date.TabIndex = TabIndex; Panel.Controls.Add(date); } if (sCate == "ComboBox") { RadComboBox com = new RadComboBox(); com.Skin = "Vista"; com.Height = Convert.ToInt32(_dtConfig.Rows[Convert.ToInt32(ArrRow[k])]["Height"]) * 5; com.Width = Convert.ToInt32(_dtConfig.Rows[Convert.ToInt32(ArrRow[k])]["Width"]); com.ID = _dtConfig.Rows[Convert.ToInt32(ArrRow[k])]["Parameter_Code"].ToString(); com.EnableVirtualScrolling = true; string SQL = _dtConfig.Rows[Convert.ToInt32(ArrRow[k])]["Data_SQL"].ToString(); if (SQL.Length > 0) { DataTable _dt; if (_dtConfig.Rows[Convert.ToInt32(ArrRow[k])]["IsSP"] != null && Convert.ToBoolean(_dtConfig.Rows[Convert.ToInt32(ArrRow[k])]["IsSP"]) == true) { int Index = SQL.IndexOf('@'); if (Index >= 0) _dt = objUser.GetSP(SQL.Substring(0, Index), SQL.Substring(Index, SQL.Length - Index), Session["UserId"] == null ? "0" : Session["UserId"].ToString()); else _dt = objUser.GetSP(SQL); } else _dt = objUser.GetSQL(SQL); com.DataValueField = "ID"; com.DataTextField = "Name"; com.DataSource = _dt; com.DataBind(); } com.TabIndex = TabIndex; Panel.Controls.Add(com); } TabIndex++; } } } // } catch (Exception ex) { } }
private void ViewReport_CVInformation() { try { if(Request["M_Code"].ToString() =="Emp") { //check quyền của người dùng short canView = bindAuthority("Information"); if (canView > 0) { ReportDocument reportDocument = new ReportDocument(); string[] sArr = ConfigurationSettings.AppSettings["Report_Emp_CVSP"].Split(','); DataSet _dtSource = new DataSet(); DataTable _dtPara = new DataTable(); _dtPara.Columns.Add("ParaName"); _dtPara.Columns.Add("ParaValue"); _dtPara.Rows.Add("@EmployeeID", Request["E_Id"].ToString()); cls_Report_User objUser = new cls_Report_User(); DataTable _dtTemp; for (int i = 0; i < sArr.Count(); i++) { _dtTemp = objUser.GetDataSourceReport(_dtPara, sArr[i]); _dtTemp.TableName = sArr[i]; _dtSource.Tables.Add(_dtTemp.Copy()); } string sPath = ConfigurationManager.AppSettings["Report_Emp_CVFile"].ToString(); reportDocument.Load(sPath); if (_dtSource != null) reportDocument.SetDataSource(_dtSource); CrystalReportViewer.ReportSource = reportDocument; CrystalReportViewer.DataBind(); } else Response.Redirect("~/ErrorPermission.aspx"); } else Response.Redirect("~/ErrorPermission.aspx"); } catch (Exception ex) { } }
private void ViewReport_Salary() { try { if ((Request["M_Code"].ToString() == "Emp")&& (Request["CompanyId"] != null) && (Request["YEAR"] != null) && (Request["MONTH"] != null) && (Request["S_Type"] != null)) { //check quyền của người dùng short canView = bindAuthority("Salary"); if (canView > 0) { ReportDocument reportDocument = new ReportDocument(); string spName = ConfigurationSettings.AppSettings["Report_Emp_SalarySP"]; DataSet _dtSource = new DataSet(); DataTable _dtPara = new DataTable(); _dtPara.Columns.Add("ParaName"); _dtPara.Columns.Add("ParaValue"); _dtPara.Rows.Add("@CompanyId", Request["CompanyId"].ToString()); _dtPara.Rows.Add("@Formula_Type", Request["S_Type"].ToString()); _dtPara.Rows.Add("@Month", Request["MONTH"].ToString()); _dtPara.Rows.Add("@Year", Request["YEAR"].ToString()); cls_Report_User objUser = new cls_Report_User(); DataTable _dtTemp; _dtTemp = objUser.GetDataSourceReport(_dtPara, spName); // _dtSource.Tables.Add(_dtTemp.Copy()); string sPath = ConfigurationManager.AppSettings["Report_Emp_SalaryFile"].ToString(); reportDocument.Load(sPath); if (_dtSource != null) reportDocument.SetDataSource(_dtTemp); //reportDocument.SetParameterValue("@CompanyId", Request["CompanyId"].ToString()); //reportDocument.SetParameterValue("@Formula_Type", Request["S_Type"].ToString()); //reportDocument.SetParameterValue("@Month", Request["MONTH"].ToString()); //reportDocument.SetParameterValue("@Year", Request["YEAR"].ToString()); reportDocument.SetParameterValue("Month", Request["MONTH"].ToString()); reportDocument.SetParameterValue("Year", Request["YEAR"].ToString()); CrystalReportViewer.ReportSource = reportDocument; CrystalReportViewer.DataBind(); } else Response.Redirect("~/ErrorPermission.aspx"); } else Response.Redirect("~/ErrorPermission.aspx"); } catch (Exception ex) { } }
private void ViewReport() { try { ReportDocument reportDocument = new ReportDocument(); string sReportID = Request.QueryString["ID_Report"].ToString(); cls_Catalog_Report objRe = new cls_Catalog_Report(); DataTable _dtRe = objRe.GetReport(sReportID); DataTable _dtPara = Session["ReportPara"] == null ? null : (DataTable)(Session["ReportPara"]); DataTable _dtP = _dtPara.Clone(); DataTable _dtPReport = _dtPara.Clone(); DataTable _dtSource; string[] sArr = _dtRe.Rows[0]["SPName"].ToString().Split('@'); cls_Report_User objUser = new cls_Report_User(); if (sArr.Length > 1) { for (int i = 0; i < _dtPara.Rows.Count; i++) { bool Exist = false; for (int k = 1; k < sArr.Length; k++) if (_dtPara.Rows[i]["ParaName"].ToString().ToUpper() == sArr[k].ToUpper()) { Exist = true; break; } if (Exist) { _dtP.ImportRow(_dtPara.Rows[i]); } else _dtPReport.ImportRow(_dtPara.Rows[i]); } _dtSource = objUser.GetDataSourceReport(_dtP, sArr[0]); } else _dtSource = objUser.GetSP(sArr[0]); // if (sArr.Length >= 1 && sArr[0].Length <= 0) _dtPReport = _dtPara; string sPath = ConfigurationManager.AppSettings["Report_File"].ToString() + _dtRe.Rows[0]["File_Path"].ToString(); reportDocument.Load(sPath); //tham so bao cao if (_dtSource != null) reportDocument.SetDataSource(_dtSource); for (int k = 0; k < _dtP.Rows.Count; k++) { for (int i = 0; i < reportDocument.ParameterFields.Count; i++) { if (reportDocument.ParameterFields[i].Name.ToUpper() == _dtP.Rows[k]["ParaName"].ToString().ToUpper()) reportDocument.SetParameterValue(reportDocument.ParameterFields[i].Name, _dtP.Rows[k]["ParaValue"]); } } if (_dtPReport.Rows.Count > 0) for (int i = 0; i < _dtPReport.Rows.Count; i++) reportDocument.SetParameterValue(_dtPReport.Rows[i]["ParaName"].ToString(), _dtPReport.Rows[i]["ParaValue"]); CrystalReportViewer.ReportSource = reportDocument; CrystalReportViewer.DataBind(); } catch (Exception ex) { } }