Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DevExpress.DataAccess.Sql.SqlDataSource sqlDataSource = GenerateSqlDataSource();
            DevExpress.DataAccess.ObjectBinding.ObjectDataSource objDataSource   = GenerateObjectDataSource();
            DevExpress.DataAccess.EntityFramework.EFDataSource   efDataSource    = GenerateEFDataSource();
            DevExpress.DataAccess.Excel.ExcelDataSource          excelDataSource = GenerateExcelDataSource();
            DevExpress.DataAccess.Json.JsonDataSource            jsonDataSource  = GenerateJsonDataSource();

            ASPxReportDesigner1.DataSources.Add(sqlDataSource.Name, sqlDataSource);
            ASPxReportDesigner1.DataSources.Add(objDataSource.Name, objDataSource);
            ASPxReportDesigner1.DataSources.Add(efDataSource.Name, efDataSource);
            ASPxReportDesigner1.DataSources.Add(excelDataSource.Name, excelDataSource);
            ASPxReportDesigner1.DataSources.Add(jsonDataSource.Name, jsonDataSource);

            ASPxReportDesigner1.OpenReport("XtraReportTest");
        }
Beispiel #2
0
        private DevExpress.DataAccess.Excel.ExcelDataSource GenerateExcelDataSource()
        {
            DevExpress.DataAccess.Excel.ExcelDataSource excelDS = new DevExpress.DataAccess.Excel.ExcelDataSource();

            excelDS.FileName = Server.MapPath("App_Data/Categories.xlsx");
            excelDS.Name     = "CustomExcelDataSource";

            DevExpress.DataAccess.Excel.ExcelWorksheetSettings excelWorksheetSettings1 = new DevExpress.DataAccess.Excel.ExcelWorksheetSettings()
            {
                CellRange = null, WorksheetName = "Sheet"
            };
            DevExpress.DataAccess.Excel.ExcelSourceOptions excelSourceOptions1 = new DevExpress.DataAccess.Excel.ExcelSourceOptions(excelWorksheetSettings1)
            {
                SkipEmptyRows = true, SkipHiddenColumns = true, SkipHiddenRows = true, UseFirstRowAsHeader = true
            };

            excelDS.SourceOptions = excelSourceOptions1;

            DevExpress.DataAccess.Excel.FieldInfo fieldInfo1 = new DevExpress.DataAccess.Excel.FieldInfo()
            {
                Name = "CategoryID", Type = typeof(double)
            };
            DevExpress.DataAccess.Excel.FieldInfo fieldInfo2 = new DevExpress.DataAccess.Excel.FieldInfo()
            {
                Name = "CategoryName", Type = typeof(string)
            };
            DevExpress.DataAccess.Excel.FieldInfo fieldInfo3 = new DevExpress.DataAccess.Excel.FieldInfo()
            {
                Name = "Description", Type = typeof(string)
            };

            excelDS.Schema.AddRange(new DevExpress.DataAccess.Excel.FieldInfo[] {
                fieldInfo1,
                fieldInfo2,
                fieldInfo3
            });
            excelDS.RebuildResultSchema();
            return(excelDS);
        }
Beispiel #3
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     DevExpress.DataAccess.Excel.FieldInfo              fieldInfo1              = new DevExpress.DataAccess.Excel.FieldInfo();
     DevExpress.DataAccess.Excel.FieldInfo              fieldInfo2              = new DevExpress.DataAccess.Excel.FieldInfo();
     DevExpress.DataAccess.Excel.FieldInfo              fieldInfo3              = new DevExpress.DataAccess.Excel.FieldInfo();
     DevExpress.DataAccess.Excel.FieldInfo              fieldInfo4              = new DevExpress.DataAccess.Excel.FieldInfo();
     DevExpress.DataAccess.Excel.FieldInfo              fieldInfo5              = new DevExpress.DataAccess.Excel.FieldInfo();
     DevExpress.DataAccess.Excel.FieldInfo              fieldInfo6              = new DevExpress.DataAccess.Excel.FieldInfo();
     DevExpress.DataAccess.Excel.ExcelSourceOptions     excelSourceOptions1     = new DevExpress.DataAccess.Excel.ExcelSourceOptions();
     DevExpress.DataAccess.Excel.ExcelWorksheetSettings excelWorksheetSettings1 = new DevExpress.DataAccess.Excel.ExcelWorksheetSettings();
     this.Detail            = new DevExpress.XtraReports.UI.DetailBand();
     this.excelDataSource1  = new DevExpress.DataAccess.Excel.ExcelDataSource();
     this.pageHeaderBand1   = new DevExpress.XtraReports.UI.PageHeaderBand();
     this.xrTableRow1       = new DevExpress.XtraReports.UI.XRTableRow();
     this.xrTableCell1      = new DevExpress.XtraReports.UI.XRTableCell();
     this.xrTableCell2      = new DevExpress.XtraReports.UI.XRTableCell();
     this.xrTableCell3      = new DevExpress.XtraReports.UI.XRTableCell();
     this.xrTableRow2       = new DevExpress.XtraReports.UI.XRTableRow();
     this.xrTableCell4      = new DevExpress.XtraReports.UI.XRTableCell();
     this.xrTableCell5      = new DevExpress.XtraReports.UI.XRTableCell();
     this.xrTableCell6      = new DevExpress.XtraReports.UI.XRTableCell();
     this.pageFooterBand1   = new DevExpress.XtraReports.UI.PageFooterBand();
     this.xrPageInfo1       = new DevExpress.XtraReports.UI.XRPageInfo();
     this.xrPageInfo2       = new DevExpress.XtraReports.UI.XRPageInfo();
     this.reportHeaderBand1 = new DevExpress.XtraReports.UI.ReportHeaderBand();
     this.xrLabel1          = new DevExpress.XtraReports.UI.XRLabel();
     this.Title             = new DevExpress.XtraReports.UI.XRControlStyle();
     this.FieldCaption      = new DevExpress.XtraReports.UI.XRControlStyle();
     this.PageInfo          = new DevExpress.XtraReports.UI.XRControlStyle();
     this.DataField         = new DevExpress.XtraReports.UI.XRControlStyle();
     this.topMarginBand1    = new DevExpress.XtraReports.UI.TopMarginBand();
     this.bottomMarginBand1 = new DevExpress.XtraReports.UI.BottomMarginBand();
     this.xrLabel2          = new DevExpress.XtraReports.UI.XRLabel();
     this.xrLabel3          = new DevExpress.XtraReports.UI.XRLabel();
     this.xrLabel4          = new DevExpress.XtraReports.UI.XRLabel();
     this.xrLabel5          = new DevExpress.XtraReports.UI.XRLabel();
     this.xrLabel6          = new DevExpress.XtraReports.UI.XRLabel();
     this.xrLabel7          = new DevExpress.XtraReports.UI.XRLabel();
     this.xrLabel8          = new DevExpress.XtraReports.UI.XRLabel();
     this.xrLabel9          = new DevExpress.XtraReports.UI.XRLabel();
     this.xrLine1           = new DevExpress.XtraReports.UI.XRLine();
     ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
     //
     // Detail
     //
     this.Detail.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] {
         this.xrLabel5,
         this.xrLabel4,
         this.xrLabel3,
         this.xrLabel2
     });
     this.Detail.HeightF       = 23F;
     this.Detail.Name          = "Detail";
     this.Detail.Padding       = new DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 100F);
     this.Detail.StyleName     = "DataField";
     this.Detail.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
     //
     // excelDataSource1
     //
     this.excelDataSource1.FileName = "C:\\Users\\ishan.malik\\Downloads\\Customer Order.xlsx";
     this.excelDataSource1.Name     = "excelDataSource1";
     fieldInfo1.Name     = "Product";
     fieldInfo1.Type     = typeof(string);
     fieldInfo2.Name     = "Supplier";
     fieldInfo2.Type     = typeof(string);
     fieldInfo3.Name     = "Column3";
     fieldInfo3.Selected = false;
     fieldInfo3.Type     = typeof(string);
     fieldInfo4.Name     = "Quantity";
     fieldInfo4.Type     = typeof(double);
     fieldInfo5.Name     = "Discount";
     fieldInfo5.Selected = false;
     fieldInfo5.Type     = typeof(double);
     fieldInfo6.Name     = "Subtotal";
     fieldInfo6.Type     = typeof(double);
     this.excelDataSource1.Schema.AddRange(new DevExpress.DataAccess.Excel.FieldInfo[] {
         fieldInfo1,
         fieldInfo2,
         fieldInfo3,
         fieldInfo4,
         fieldInfo5,
         fieldInfo6
     });
     excelWorksheetSettings1.CellRange     = null;
     excelWorksheetSettings1.WorksheetName = "Sheet";
     excelSourceOptions1.ImportSettings    = excelWorksheetSettings1;
     this.excelDataSource1.SourceOptions   = excelSourceOptions1;
     //
     // pageHeaderBand1
     //
     this.pageHeaderBand1.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] {
         this.xrLine1,
         this.xrLabel9,
         this.xrLabel8,
         this.xrLabel7,
         this.xrLabel6
     });
     this.pageHeaderBand1.HeightF = 56.00001F;
     this.pageHeaderBand1.Name    = "pageHeaderBand1";
     //
     // xrTableRow1
     //
     this.xrTableRow1.Cells.AddRange(new DevExpress.XtraReports.UI.XRTableCell[] {
         this.xrTableCell1,
         this.xrTableCell2,
         this.xrTableCell3
     });
     this.xrTableRow1.Name   = "xrTableRow1";
     this.xrTableRow1.Weight = 1D;
     //
     // xrTableCell1
     //
     this.xrTableCell1.Name   = "xrTableCell1";
     this.xrTableCell1.Text   = "xrTableCell1";
     this.xrTableCell1.Weight = 1D;
     //
     // xrTableCell2
     //
     this.xrTableCell2.Name   = "xrTableCell2";
     this.xrTableCell2.Text   = "xrTableCell2";
     this.xrTableCell2.Weight = 1D;
     //
     // xrTableCell3
     //
     this.xrTableCell3.Name   = "xrTableCell3";
     this.xrTableCell3.Text   = "xrTableCell3";
     this.xrTableCell3.Weight = 1D;
     //
     // xrTableRow2
     //
     this.xrTableRow2.Cells.AddRange(new DevExpress.XtraReports.UI.XRTableCell[] {
         this.xrTableCell4,
         this.xrTableCell5,
         this.xrTableCell6
     });
     this.xrTableRow2.Name   = "xrTableRow2";
     this.xrTableRow2.Weight = 1D;
     //
     // xrTableCell4
     //
     this.xrTableCell4.Name   = "xrTableCell4";
     this.xrTableCell4.Text   = "xrTableCell4";
     this.xrTableCell4.Weight = 1D;
     //
     // xrTableCell5
     //
     this.xrTableCell5.Name   = "xrTableCell5";
     this.xrTableCell5.Text   = "xrTableCell5";
     this.xrTableCell5.Weight = 1D;
     //
     // xrTableCell6
     //
     this.xrTableCell6.Name   = "xrTableCell6";
     this.xrTableCell6.Text   = "xrTableCell6";
     this.xrTableCell6.Weight = 1D;
     //
     // pageFooterBand1
     //
     this.pageFooterBand1.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] {
         this.xrPageInfo1,
         this.xrPageInfo2
     });
     this.pageFooterBand1.HeightF = 29F;
     this.pageFooterBand1.Name    = "pageFooterBand1";
     //
     // xrPageInfo1
     //
     this.xrPageInfo1.LocationFloat = new DevExpress.Utils.PointFloat(6F, 6F);
     this.xrPageInfo1.Name          = "xrPageInfo1";
     this.xrPageInfo1.Padding       = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
     this.xrPageInfo1.PageInfo      = DevExpress.XtraPrinting.PageInfo.DateTime;
     this.xrPageInfo1.SizeF         = new System.Drawing.SizeF(313F, 23F);
     this.xrPageInfo1.StyleName     = "PageInfo";
     //
     // xrPageInfo2
     //
     this.xrPageInfo2.Format        = "Page {0} of {1}";
     this.xrPageInfo2.LocationFloat = new DevExpress.Utils.PointFloat(331F, 6F);
     this.xrPageInfo2.Name          = "xrPageInfo2";
     this.xrPageInfo2.Padding       = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
     this.xrPageInfo2.SizeF         = new System.Drawing.SizeF(313F, 23F);
     this.xrPageInfo2.StyleName     = "PageInfo";
     this.xrPageInfo2.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopRight;
     //
     // reportHeaderBand1
     //
     this.reportHeaderBand1.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] {
         this.xrLabel1
     });
     this.reportHeaderBand1.HeightF = 53F;
     this.reportHeaderBand1.Name    = "reportHeaderBand1";
     //
     // xrLabel1
     //
     this.xrLabel1.LocationFloat = new DevExpress.Utils.PointFloat(6F, 6F);
     this.xrLabel1.Name          = "xrLabel1";
     this.xrLabel1.Padding       = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
     this.xrLabel1.SizeF         = new System.Drawing.SizeF(638F, 35F);
     this.xrLabel1.StyleName     = "Title";
     this.xrLabel1.Text          = "Orders";
     //
     // Title
     //
     this.Title.BackColor   = System.Drawing.Color.Transparent;
     this.Title.BorderColor = System.Drawing.Color.Black;
     this.Title.Borders     = DevExpress.XtraPrinting.BorderSide.None;
     this.Title.BorderWidth = 1F;
     this.Title.Font        = new System.Drawing.Font("Times New Roman", 21F);
     this.Title.ForeColor   = System.Drawing.Color.Black;
     this.Title.Name        = "Title";
     //
     // FieldCaption
     //
     this.FieldCaption.BackColor   = System.Drawing.Color.Transparent;
     this.FieldCaption.BorderColor = System.Drawing.Color.Black;
     this.FieldCaption.Borders     = DevExpress.XtraPrinting.BorderSide.Bottom;
     this.FieldCaption.BorderWidth = 1F;
     this.FieldCaption.Font        = new System.Drawing.Font("Times New Roman", 10F);
     this.FieldCaption.ForeColor   = System.Drawing.Color.Black;
     this.FieldCaption.Name        = "FieldCaption";
     //
     // PageInfo
     //
     this.PageInfo.BackColor   = System.Drawing.Color.Transparent;
     this.PageInfo.BorderColor = System.Drawing.Color.Black;
     this.PageInfo.Borders     = DevExpress.XtraPrinting.BorderSide.None;
     this.PageInfo.BorderWidth = 1F;
     this.PageInfo.Font        = new System.Drawing.Font("Arial", 8F);
     this.PageInfo.ForeColor   = System.Drawing.Color.Black;
     this.PageInfo.Name        = "PageInfo";
     //
     // DataField
     //
     this.DataField.BackColor   = System.Drawing.Color.Transparent;
     this.DataField.BorderColor = System.Drawing.Color.Black;
     this.DataField.Borders     = DevExpress.XtraPrinting.BorderSide.None;
     this.DataField.BorderWidth = 1F;
     this.DataField.Font        = new System.Drawing.Font("Arial", 9F);
     this.DataField.ForeColor   = System.Drawing.Color.Black;
     this.DataField.Name        = "DataField";
     this.DataField.Padding     = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
     //
     // topMarginBand1
     //
     this.topMarginBand1.HeightF = 51F;
     this.topMarginBand1.Name    = "topMarginBand1";
     //
     // bottomMarginBand1
     //
     this.bottomMarginBand1.HeightF = 24F;
     this.bottomMarginBand1.Name    = "bottomMarginBand1";
     //
     // xrLabel2
     //
     this.xrLabel2.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
         new DevExpress.XtraReports.UI.XRBinding("Text", null, "Product")
     });
     this.xrLabel2.LocationFloat = new DevExpress.Utils.PointFloat(10.00001F, 0F);
     this.xrLabel2.Name          = "xrLabel2";
     this.xrLabel2.Padding       = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96F);
     this.xrLabel2.SizeF         = new System.Drawing.SizeF(182.7083F, 23F);
     this.xrLabel2.Text          = "xrLabel2";
     //
     // xrLabel3
     //
     this.xrLabel3.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
         new DevExpress.XtraReports.UI.XRBinding("Text", null, "Quantity")
     });
     this.xrLabel3.LocationFloat = new DevExpress.Utils.PointFloat(204.4167F, 0F);
     this.xrLabel3.Name          = "xrLabel3";
     this.xrLabel3.Padding       = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96F);
     this.xrLabel3.SizeF         = new System.Drawing.SizeF(100F, 23F);
     this.xrLabel3.Text          = "xrLabel3";
     //
     // xrLabel4
     //
     this.xrLabel4.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
         new DevExpress.XtraReports.UI.XRBinding("Text", null, "Supplier")
     });
     this.xrLabel4.LocationFloat = new DevExpress.Utils.PointFloat(427.0833F, 0F);
     this.xrLabel4.Name          = "xrLabel4";
     this.xrLabel4.Padding       = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96F);
     this.xrLabel4.SizeF         = new System.Drawing.SizeF(187.5F, 23F);
     this.xrLabel4.Text          = "xrLabel4";
     //
     // xrLabel5
     //
     this.xrLabel5.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
         new DevExpress.XtraReports.UI.XRBinding("Text", null, "Subtotal")
     });
     this.xrLabel5.LocationFloat = new DevExpress.Utils.PointFloat(315.625F, 0F);
     this.xrLabel5.Name          = "xrLabel5";
     this.xrLabel5.Padding       = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96F);
     this.xrLabel5.SizeF         = new System.Drawing.SizeF(100F, 23F);
     this.xrLabel5.Text          = "xrLabel5";
     //
     // xrLabel6
     //
     this.xrLabel6.Font                  = new System.Drawing.Font("Times New Roman", 5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Millimeter);
     this.xrLabel6.LocationFloat         = new DevExpress.Utils.PointFloat(10.00001F, 10.00001F);
     this.xrLabel6.Name                  = "xrLabel6";
     this.xrLabel6.Padding               = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96F);
     this.xrLabel6.SizeF                 = new System.Drawing.SizeF(100F, 23F);
     this.xrLabel6.StylePriority.UseFont = false;
     this.xrLabel6.Text                  = "Product";
     //
     // xrLabel7
     //
     this.xrLabel7.Font                  = new System.Drawing.Font("Times New Roman", 5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Millimeter);
     this.xrLabel7.LocationFloat         = new DevExpress.Utils.PointFloat(204.4167F, 10.00001F);
     this.xrLabel7.Name                  = "xrLabel7";
     this.xrLabel7.Padding               = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
     this.xrLabel7.SizeF                 = new System.Drawing.SizeF(100F, 23F);
     this.xrLabel7.StylePriority.UseFont = false;
     this.xrLabel7.Text                  = "Quantity";
     //
     // xrLabel8
     //
     this.xrLabel8.Font                  = new System.Drawing.Font("Times New Roman", 5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Millimeter);
     this.xrLabel8.LocationFloat         = new DevExpress.Utils.PointFloat(315.625F, 10.00001F);
     this.xrLabel8.Name                  = "xrLabel8";
     this.xrLabel8.Padding               = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
     this.xrLabel8.SizeF                 = new System.Drawing.SizeF(100F, 23F);
     this.xrLabel8.StylePriority.UseFont = false;
     this.xrLabel8.Text                  = "SubTotal";
     //
     // xrLabel9
     //
     this.xrLabel9.Font                  = new System.Drawing.Font("Times New Roman", 5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Millimeter);
     this.xrLabel9.LocationFloat         = new DevExpress.Utils.PointFloat(427.0833F, 10.00001F);
     this.xrLabel9.Name                  = "xrLabel9";
     this.xrLabel9.Padding               = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
     this.xrLabel9.SizeF                 = new System.Drawing.SizeF(100F, 23F);
     this.xrLabel9.StylePriority.UseFont = false;
     this.xrLabel9.Text                  = "Supplier";
     //
     // xrLine1
     //
     this.xrLine1.LocationFloat = new DevExpress.Utils.PointFloat(0F, 33.00001F);
     this.xrLine1.Name          = "xrLine1";
     this.xrLine1.SizeF         = new System.Drawing.SizeF(650F, 23F);
     //
     // XtraReport1
     //
     this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] {
         this.Detail,
         this.pageHeaderBand1,
         this.pageFooterBand1,
         this.reportHeaderBand1,
         this.topMarginBand1,
         this.bottomMarginBand1
     });
     this.ComponentStorage.AddRange(new System.ComponentModel.IComponent[] {
         this.excelDataSource1
     });
     this.DataSource = this.excelDataSource1;
     this.Margins    = new System.Drawing.Printing.Margins(100, 100, 51, 24);
     this.StyleSheet.AddRange(new DevExpress.XtraReports.UI.XRControlStyle[] {
         this.Title,
         this.FieldCaption,
         this.PageInfo,
         this.DataField
     });
     this.Version = "15.2";
     ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
 }
Beispiel #4
0
        void ImportData(string ImportFileName)
        {
            if (string.IsNullOrWhiteSpace(ImportFileName))
            {
                Alit.WinformControls.MessageBox.Show("Please select excel file.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (!System.IO.File.Exists(ImportFileName))
            {
                Alit.WinformControls.MessageBox.Show("Selected file doesn't exists.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string extension = System.IO.Path.GetExtension(ImportFileName).ToUpper();

            if (extension != ".XLS" && extension != ".XLSX")
            {
                if (Alit.WinformControls.MessageBox.Show(this, "Selected file is not seems to be valid excel file. Do you want to continue ?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
                {
                    return;
                }
            }

            //--
            tAApprovalImportViewModelBindingSource.Clear();

            if (extension.ToUpper() != ".XLS" && extension.ToUpper() != ".XLSX")
            {
                if (Alit.WinformControls.MessageBox.Show(this, "Selected file is seems to be Not valid excel file. Do you want to continue ?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
                {
                    return;
                }
            }

            string conStr = string.Empty;

            if (extension == ".xlsx")
            {
                conStr = string.Format(Excel07ConString, ImportFileName, "Yes");
            }
            else
            {
                conStr = string.Format(Excel03ConString, ImportFileName, "Yes");
            }

            ShowWaitForm();

            try
            {
                DevExpress.DataAccess.Excel.ExcelDataSource myExcelSource = new DevExpress.DataAccess.Excel.ExcelDataSource();
                myExcelSource.FileName = ImportFileName;
                DevExpress.DataAccess.Excel.ExcelWorksheetSettings worksheetSettings = new DevExpress.DataAccess.Excel.ExcelWorksheetSettings(GetWorkSheetNameByIndex(ImportFileName, 0));
                myExcelSource.SourceOptions = new DevExpress.DataAccess.Excel.ExcelSourceOptions(worksheetSettings);
                myExcelSource.SourceOptions.SkipEmptyRows       = true;
                myExcelSource.SourceOptions.UseFirstRowAsHeader = true;
                myExcelSource.Fill();

                System.Collections.IList list = ((IListSource)myExcelSource).GetList();
                DevExpress.DataAccess.Native.Excel.DataView dataView = (DevExpress.DataAccess.Native.Excel.DataView)list;

                try
                {
                    #region Decoding Data
                    for (int ri = 0; ri < dataView.Count; ri++)
                    {
                        DevExpress.DataAccess.Native.Excel.ViewRow dsRow = (DevExpress.DataAccess.Native.Excel.ViewRow)dataView[ri];

                        TAApprovalImportViewModel NewRecord = new TAApprovalImportViewModel()
                        {
                            RowNo = ri + 1
                        };
                        //--
                        object importvalue = null;

                        // Transaction Date (Approval Date)

                        importvalue = dataView.Columns[ImportFileColumnIndex_TransactionDate].GetValue(dsRow);
                        if (importvalue != null)
                        {
                            DateTime dtvalue;
                            if (DateTime.TryParse(importvalue.ToString(), out dtvalue))
                            {
                                NewRecord.ApprovalDate = dtvalue;
                            }
                            else
                            {
                                NewRecord.ApprovalDateError = importvalue.ToString() + " : invalid value";
                            }
                        }
                        else
                        {
                            NewRecord.ApprovalDateError = "No value";
                        }

                        // TransactionNoPrefix
                        importvalue = dataView.Columns[ImportFileColumnIndex_TransactionNoPrefix].GetValue(dsRow);
                        if (importvalue != null)
                        {
                            NewRecord.ApprovalNoPrefixName = importvalue.ToString();

                            string prefixToCheck = NewRecord.ApprovalNoPrefixName.Trim().ToUpper();
                            var    Prefix        = dsApprovalNoPrefix.FirstOrDefault(r => r.TAApprovalNoPrefixName.ToUpper() == prefixToCheck);
                            if (Prefix != null)
                            {
                                NewRecord.ApprovalNoPrefixID = Prefix.TAApprovalNoPrefixID;
                            }
                            else
                            {
                                NewRecord.ApprovalNoPrefixNameError = importvalue.ToString() + " : not found.";
                            }
                        }
                        else
                        {
                            NewRecord.ApprovalNoPrefixNameError = "No value.";
                        }

                        // TransactionNo
                        importvalue = dataView.Columns[ImportFileColumnIndex_TransactionNo].GetValue(dsRow);
                        if (importvalue != null)
                        {
                            int value = 0;
                            if (int.TryParse(importvalue.ToString(), out value))
                            {
                                NewRecord.ApprovalNo = value;

                                //--
                                if (NewRecord.ApprovalNoPrefixID != null)
                                {
                                    if (DALObj.IsDuplicateRecord(NewRecord.ApprovalNoPrefixID.Value, NewRecord.ApprovalNo.Value, 0))
                                    {
                                        NewRecord.ApprovalNo      = null;
                                        NewRecord.ApprovalNoError = importvalue.ToString() + " : duplicate value can not accepted.";
                                    }
                                }
                            }
                            else
                            {
                                NewRecord.ApprovalNoError = importvalue.ToString() + " : invalid value";
                            }
                        }
                        else
                        {
                            NewRecord.ApprovalNoError = "No value";
                        }

                        // EmployeeNo
                        importvalue = dataView.Columns[ImportFileColumnIndex_EmployeeNo].GetValue(dsRow);
                        if (importvalue != null)
                        {
                            int value = 0;
                            if (int.TryParse(importvalue.ToString(), out value))
                            {
                                NewRecord.EmployeeNo = value;

                                var Employee = dsEmployee.FirstOrDefault(r => r.EmployeeNo == NewRecord.EmployeeNo);

                                if (Employee != null)
                                {
                                    NewRecord.EmployeeID           = Employee.EmployeeID;
                                    NewRecord.EmployeeNoPrefixName = Employee.EmployeeNoPrefix;
                                    NewRecord.EmployeeName         = Employee.EmployeeName;
                                }
                                else
                                {
                                    NewRecord.EmployeeNameError = importvalue.ToString() + " : not found";
                                }
                            }
                            else
                            {
                                NewRecord.EmployeeNameError = importvalue.ToString() + " : invalid value";
                            }
                        }
                        else
                        {
                            NewRecord.EmployeeNameError = "No value";
                        }

                        // Approved Date
                        importvalue = dataView.Columns[ImportFileColumnIndex_ApprovedDate].GetValue(dsRow);
                        if (importvalue != null)
                        {
                            DateTime value;
                            if (DateTime.TryParse(importvalue.ToString(), out value))
                            {
                                NewRecord.ApprovedDate = value;
                            }
                            else
                            {
                                NewRecord.ApprovedDateError = importvalue.ToString() + " : invalid value";
                            }
                        }
                        else
                        {
                            NewRecord.ApprovedDateError = "No value";
                        }


                        // ApprovedHours
                        importvalue = dataView.Columns[ImportFileColumnIndex_ApprovedHours].GetValue(dsRow);
                        if (importvalue != null)
                        {
                            decimal value;
                            if (decimal.TryParse(importvalue.ToString(), out value))
                            {
                                NewRecord.ApprovedHours = value;
                            }
                            else
                            {
                                NewRecord.ApprovedHoursError = importvalue.ToString() + " : invalid value";
                            }
                        }
                        else
                        {
                            NewRecord.ApprovedHoursError = "No value";
                        }


                        // ApprovedFor
                        importvalue = dataView.Columns[ImportFileColumnIndex_ApprovedFor].GetValue(dsRow);
                        if (importvalue != null)
                        {
                            int value;
                            if (int.TryParse(importvalue.ToString(), out value) && value >= 1 && value <= 4)
                            {
                                NewRecord.ApprovalTypeID = (eTAApprovalType)(value - 1);
                            }
                            else
                            {
                                NewRecord.ApprovalTypeIDError = importvalue.ToString() + " : invalid value";
                            }
                        }
                        else
                        {
                            NewRecord.ApprovalTypeIDError = "No value";
                        }


                        // Remark
                        importvalue = dataView.Columns[ImportFileColumnIndex_Remark].GetValue(dsRow);
                        if (importvalue != null)
                        {
                            NewRecord.Remark = importvalue.ToString();
                        }

                        //// DocumandLocation
                        //importvalue = dataView.Columns[ImportFileColumnIndex_DocumandLocation].GetValue(dsRow);
                        //if (importvalue != null)
                        //{
                        //    NewRecord.DocumentLocation = importvalue.ToString();
                        //}


                        //// Check - Valid for Import
                        //if (NewRecord.ApprovalDate != null && NewRecord.ApprovalNoPrefixID != null && NewRecord.ApprovalNo != null &&
                        //    NewRecord.ApprovalTypeID != null && NewRecord.EmployeeID != null &&
                        //    NewRecord.ApprovedDate != null && NewRecord.ApprovedHours != null)
                        //{
                        //    NewRecord.ValidForImport = true;
                        //}
                        //else
                        //{
                        //    NewRecord.ValidForImport = false;
                        //}
                        //--
                        tAApprovalImportViewModelBindingSource.Add(NewRecord);
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    ex = DAL.CommonFunctions.GetFinalError(ex);
                    CloseWaitForm();
                    Alit.WinformControls.MessageBox.Show("Error while trying to decode excel file.\r\n" + (ex != null ? ex.Message : ""), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                ex = DAL.CommonFunctions.GetFinalError(ex);
                CloseWaitForm();
                Alit.WinformControls.MessageBox.Show("Error while trying to connect excel file.\r\n" + (ex != null ? ex.Message : ""), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            CloseWaitForm();
        }