public static void LoadReportCaption(string username, string language_id, string template, string function_id) { SYS_tblReportCaptionBUS busReport = new SYS_tblReportCaptionBUS(); DataTable dt = busReport.LoadImportCaption(username, language_id, function_id, true); Workbook wb = new Workbook(Temp + string.Format(@"\{0}", template)); Worksheet ws = wb.Worksheets[0]; int index = 0; int count = wb.Worksheets.Count; if (dt != null && dt.Rows.Count > 0) { try { FindOptions opts = new FindOptions(); opts.LookInType = LookInType.Values; opts.LookAtType = LookAtType.EntireContent; for (int i = 0; i < dt.Rows.Count; i++) { Cell cell = ws.Cells.Find("$" + dt.Rows[i]["ControlID"].ToString() + "$", null, opts); if (cell != null) { int column = cell.Column; ws.Replace("$" + dt.Rows[i]["ControlID"].ToString() + "$", dt.Rows[i]["Caption"].ToString()); if (Convert.ToBoolean(dt.Rows[i]["IsList"]) && cell != null) { string tmp = ""; tmp = ws.Cells[cell.Row + 1, cell.Column].Value + ""; DataTable dt2 = busReport.LoadComboDynamicList(username, language_id, "", dt.Rows[i]["TableName"] + "", "Code"); index++; if (dt2 != null && dt2.Rows.Count > 0) { wb.Worksheets[index].Name = dt.Rows[i]["TableName"] + ""; Worksheet ws1 = wb.Worksheets[index]; ws1.Cells.ImportDataTable(dt2, true, 0, 0, true, false); Range range = ws1.Cells.CreateRange(1, 0, dt2.Rows.Count, 1); range.Name = tmp; for (int j = 0; j < dt2.Rows.Count; j++) { AsposeCellsStyle.Cells.BackgroundColor(ws1.Cells[0, j], Color.Yellow); AsposeCellsStyle.Cells.Font.Color(ws1.Cells[0, j], Color.Red); } ws1.AutoFitColumns(); } CellArea cellArea; cellArea.StartRow = 2; cellArea.EndRow = ws.Cells.MaxRow; cellArea.StartColumn = cell.Column; cellArea.EndColumn = cell.Column; ValidationCollection validations = ws.Validations; Validation validation = validations[validations.Add(cellArea)]; validation.Type = ValidationType.List; validation.Operator = OperatorType.None; validation.InCellDropDown = true; validation.Formula1 = "=" + tmp; validation.ShowError = false; validation.AreaList.Add(cellArea); } } if (Convert.ToBoolean(dt.Rows[i]["IsRequire"])) { AsposeCellsStyle.Cells.Font.Color(cell, Color.Red); } } SaveExportCustom(wb, "HellDemons"); } catch (Exception ex) { Logger.Error(ex); return; } } }
private void Initialize() { string Language = User.UserInfo.LanguageID; busImport = new SYS_tblImportFileConfigBUS(); busReport = new SYS_tblReportCaptionBUS(); dtSelectedFile = CreateSeletedFileTable(); gridSeletedFiles.DataBindings.Clear(); gridSeletedFiles.DataSource = dtSelectedFile; wwpStepOne.AllowNext = false; bteBrowseFile.Properties.Buttons[1].Enabled = false; mainData = new DataSet(); DevExpress.XtraGrid.StyleFormatCondition styleInsertFormat = new DevExpress.XtraGrid.StyleFormatCondition(); DevExpress.XtraGrid.StyleFormatCondition styleUpdateFormat = new DevExpress.XtraGrid.StyleFormatCondition(); DevExpress.XtraGrid.StyleFormatCondition styleNormalFormat = new DevExpress.XtraGrid.StyleFormatCondition(); #region [Inserted Style Format] styleInsertFormat.Appearance.BackColor = System.Drawing.Color.Green; styleInsertFormat.Appearance.BorderColor = Color.Black; styleInsertFormat.Appearance.ForeColor = Color.White; styleInsertFormat.Appearance.Options.UseBackColor = true; styleInsertFormat.Appearance.Options.UseBorderColor = true; styleInsertFormat.Appearance.Options.UseForeColor = true; styleInsertFormat.Column = grvMainData.Columns["Return Message"]; styleInsertFormat.Condition = DevExpress.XtraGrid.FormatConditionEnum.Equal; styleInsertFormat.Value1 = "Inserted"; styleInsertFormat.ApplyToRow = true; #endregion #region [Updated Style Format] styleUpdateFormat.Appearance.BackColor = Color.Yellow; styleUpdateFormat.Appearance.BorderColor = Color.Black; styleUpdateFormat.Appearance.ForeColor = Color.Black; styleUpdateFormat.Appearance.Options.UseBackColor = true; styleUpdateFormat.Appearance.Options.UseBorderColor = true; styleUpdateFormat.Appearance.Options.UseForeColor = true; styleUpdateFormat.Column = grvMainData.Columns["Return Message"]; styleUpdateFormat.Condition = DevExpress.XtraGrid.FormatConditionEnum.Equal; styleUpdateFormat.Value1 = "Updated"; styleUpdateFormat.ApplyToRow = true; #endregion this.grvMainData.FormatConditions.AddRange(new DevExpress.XtraGrid.StyleFormatCondition[] { styleInsertFormat, styleUpdateFormat }); lciBrowseFile.Text = (Language.Equals("VN")) ? "Chọn tệp tin dữ liệu:" : "Choose data file:"; btnDownloadTemplate.Text = Language.Equals("VN") ? "Tải Template" : "Download template"; btnCheckTemplate.Text = Language.Equals("VN") ? "Kiểm Tra" : "Check Files"; grvSeletedFiles.GroupPanelText = Language.Equals("VN") ? "Kéo một tiêu đề cột vào đây để nhóm theo cột đó" : "Drag a column header here to group by that column"; gcolSelectedFileName.Caption = Language.Equals("VN") ? "Tên tệp tin" : "File name"; gcolSelectedDateModified.Caption = Language.Equals("VN") ? "Ngày cập nhật" : "Date modified"; gcolSelectedFileSize.Caption = Language.Equals("VN") ? "Kích thước" : "File size"; gcolSelectedNote.Caption = Language.Equals("VN") ? "Ghi chú" : "Note"; gcolSeletedFilePath.Caption = Language.Equals("VN") ? "Đường dẫn" : "File path"; lciGridMainData.Text = Language.Equals("VN") ? "Dữ liệu nhập tổng quát" : "Input data overview"; lciSelectedFiles.Text = Language.Equals("VN") ? "Chọn tệp dữ liệu:" : "Choose data file:"; btnImportAllFiles.Text = Language.Equals("VN") ? "Nhập Tất Cả Tập Tin" : "Import all files"; btnImportSelectedFile.Text = Language.Equals("VN") ? "Nhập Tệp Đã Chọn" : "Import selected file"; wzcMain.CancelText = Language.Equals("VN") ? "Hủy Bỏ" : "Cancel"; wzcMain.NextText = Language.Equals("VN") ? "Tiếp Tục >" : "Next >"; wzcMain.FinishText = Language.Equals("VN") ? "Hoàn Tất" : "Finish"; wzcMain.Text = Language.Equals("VN") ? "Trình hướng dẫn nhập dữ liệu từ file Excel" : "Wizard import data from Excel file"; wwpStepOne.Text = Language.Equals("VN") ? "Chọn tệp dữ liệu Excel cần nhập" : "Choose Excel file want to import"; wwpStepTwo.Text = Language.Equals("VN") ? "Quá trình thực hiện" : "Implementation process"; wwpStepThree.Text = Language.Equals("VN") ? "Tóm tắt thông tin nhập liệu" : "Summary import information"; logSelectedFiles.Text = Language.Equals("VN") ? "Tệp tin đã chọn từ máy tính" : "Selected files from your computer"; }