private void RadDock1_DockStateChanged(object sender, DockWindowEventArgs e)
 {
     try
     {
         //
         //Image img = new Bitmap(form.Image, new Size(16, 16));
         //e.DockWindow.TabStripItem.Image = img;
         if (e.DockWindow.DockState == DockState.Floating)
         {
             DockWindow dockedWindow = ((DockWindow)e.DockWindow);
             Bitmap     bitmap       = new Bitmap(dockedWindow.Image);
             Icon       icon         = System.Drawing.Icon.FromHandle(bitmap.GetHicon());
             dockedWindow.FloatingParent.Icon            = icon;
             dockedWindow.FloatingParent.ShowIcon        = true;
             dockedWindow.FloatingParent.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
             dockedWindow.FloatingParent.FormElement.TitleBar.IconPrimitive.Visibility = Telerik.WinControls.ElementVisibility.Visible;
         }
         //if (hostWindow.DockState == DockState.Docked)
         //{
         //    if (!(hostWindow.DockTabStrip as ToolTabStrip).CaptionElement.Children[2].Children.Contains(iconImage))
         //    {
         //        (hostWindow.DockTabStrip as ToolTabStrip).CaptionElement.Children[2].Children.Insert(0, iconImage);
         //    }
         //}
     }
     catch (Exception ex)
     {
         ClsMessage.ProjectExceptionMessage(ex);
     }
 }
        private void RdBtnAddExcelCol_2_Click(object sender, EventArgs e)
        {
            try
            {
                if (DtExcelColumns != null && DtExcelColumns.DefaultView.Count > 0)
                {
                    if (DtExcelColumns_2 != null && DtExcelColumns_2.DefaultView.Count > 0)
                    {
                        if (DtExcelColumns.Rows.Count < DtExcelColumns_2.Rows.Count)
                        {
                            int IRowDiffrance = DtExcelColumns_2.Rows.Count - DtExcelColumns.Rows.Count;
                            for (int i = 0; i < IRowDiffrance; i++)
                            {
                                DtExcelColumns.Rows.Add();
                            }
                        }

                        for (int IColCount = 0; IColCount < DtExcelColumns_2.DefaultView.Count; IColCount++)
                        {
                            DtExcelColumns.DefaultView[IColCount].BeginEdit();
                            DtExcelColumns.DefaultView[IColCount]["cExcelCol_2"] = DtExcelColumns_2.DefaultView[IColCount]["cExcelCol_2"];
                            DtExcelColumns.DefaultView[IColCount].EndEdit();
                        }
                        DtExcelColumns.AcceptChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                ClsMessage.ProjectExceptionMessage(ex);
            }
        }
 private void RdGrdExcelColumns_CellDoubleClick(object sender, GridViewCellEventArgs e)
 {
     try
     {
         if (e.Column.FieldName == "cExcelCol_2")
         {
             if (DtExcelColumns != null && DtExcelColumns.DefaultView.Count > 0)
             {
                 if (DtExcelColumns_2 != null && DtExcelColumns_2.DefaultView.Count > 0)
                 {
                     int IRowIndex = 0;
                     IRowIndex = RdGrdExcelColumns.CurrentRow.Index;
                     DtExcelColumns.DefaultView[IRowIndex].BeginEdit();
                     DtExcelColumns.DefaultView[IRowIndex]["cExcelCol_2"] = "";
                     DtExcelColumns.DefaultView[IRowIndex].EndEdit();
                     DtExcelColumns.AcceptChanges();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         ClsMessage.ProjectExceptionMessage(ex);
     }
 }
 private void RdBtnRemoveExcelCol_2_Click(object sender, EventArgs e)
 {
     try
     {
         if (DtExcelColumns != null && DtExcelColumns.DefaultView.Count > 0)
         {
             if (DtExcelColumns_2 != null && DtExcelColumns_2.DefaultView.Count > 0)
             {
                 for (int IColCount = 0; IColCount < DtExcelColumns_2.DefaultView.Count; IColCount++)
                 {
                     DtExcelColumns.DefaultView[IColCount].BeginEdit();
                     if (DtExcelColumns.DefaultView[IColCount]["cExcelCol_2"] == DtExcelColumns_2.DefaultView[IColCount]["cExcelCol_2"])
                     {
                         DtExcelColumns.DefaultView[IColCount]["cExcelCol_2"] = "";
                     }
                     DtExcelColumns.DefaultView[IColCount].EndEdit();
                 }
                 DtExcelColumns.AcceptChanges();
             }
         }
     }
     catch (Exception ex)
     {
         ClsMessage.ProjectExceptionMessage(ex);
     }
 }
        private void RdBtnGetColumns_Click(string StrButtonName)
        {
            try
            {
                Cursor = Cursors.WaitCursor;
                if (StrButtonName == "RdBtnGetExcelColumns_1" && RdCmbExcelFile_1.Text != null && RdCmbExcelFile_1.Text.Trim() != "")
                {
                    DtExcelColumns.Rows.Clear();
                    ClsExcelWork.InstanceClsExcelWor.GetExcelColumns(RdCmbExcelFile_1.Tag.ToString(), RdCmbExcelFile_1.Text, DtExcelColumns, "cExcelCol_1");
                    RdGrdExcelColumns.DataSource = DtExcelColumns;

                    DtExcelData             = new DataTable();
                    DtExcelData             = ClsExcelWork.InstanceClsExcelWor.GetExcelData(RdCmbExcelFile_1.Tag.ToString(), RdCmbExcelFile_1.Text);
                    RdGrdExcel_1.DataSource = DtExcelData;
                }
                if (StrButtonName == "RdBtnGetExcelColumns_2" && RdCmbExcelFile_2.Text != null && RdCmbExcelFile_2.Text.Trim() != "")
                {
                    DtExcelColumns_2.Rows.Clear();
                    ClsExcelWork.InstanceClsExcelWor.GetExcelColumns(RdCmbExcelFile_2.Tag.ToString(), RdCmbExcelFile_2.Text, DtExcelColumns_2, "cExcelCol_2");
                    RdGrdExcelColumns_2.DataSource = DtExcelColumns_2;

                    DtExcelData_2           = new DataTable();
                    DtExcelData_2           = ClsExcelWork.InstanceClsExcelWor.GetExcelData(RdCmbExcelFile_2.Tag.ToString(), RdCmbExcelFile_2.Text);
                    RdGrdExcel_2.DataSource = DtExcelData_2;
                }
            }
            catch (Exception ex)
            {
                ClsMessage.ProjectExceptionMessage(ex);
            }
            Cursor = Cursors.Default;
        }
 private void RdBtnOpen_1_Click(object sender, EventArgs e)
 {
     try
     {
         using (var OpnDlg = new OpenFileDialog())
         {
             OpnDlg.Filter = "Excel File(*.xlsx)|*.xlsx";
             if (OpnDlg.ShowDialog() == DialogResult.OK)
             {
                 if (((RadButton)sender).Name == "RdBtnOpen_1")
                 {
                     RdCmbExcelFile_1.Items.AddRange(ClsExcelWork.InstanceClsExcelWor.GetExcelSheet(OpnDlg.FileName));
                     RdCmbExcelFile_1.Tag           = OpnDlg.FileName;
                     RdCmbExcelFile_1.SelectedIndex = 0;
                     // RdTxtExcle_1.Text = OpnDlg.FileName;
                     //
                 }
                 else if (((RadButton)sender).Name == "RdBtnOpen_2")
                 {
                     //RdTxtExcle_2.Text = OpnDlg.FileName;
                     //
                     RdCmbExcelFile_2.Items.AddRange(ClsExcelWork.InstanceClsExcelWor.GetExcelSheet(OpnDlg.FileName));
                     RdCmbExcelFile_2.Tag           = OpnDlg.FileName;
                     RdCmbExcelFile_2.SelectedIndex = 0;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         ClsMessage.ProjectExceptionMessage(ex);
     }
 }
 private void FrmMainForm_Resize(object sender, EventArgs e)
 {
     try
     {
         //RdPanelButton.Location = new Point(this.ClientSize.Width / 2 - RdPanelButton.Parent.Size.Width / 2,
         //                                     this.ClientSize.Height / 2 - RdPanelButton.Parent.Size.Height / 2);
         RdPanelButton.Anchor = AnchorStyles.None;
     }
     catch (Exception ex)
     {
         ClsMessage.ProjectExceptionMessage(ex);
     }
 }
 private void FrmMainForm_Load(object sender, EventArgs e)
 {
     try
     {
         DtExcelColumns = new DataTable();
         DtExcelColumns.Columns.AddRange(new DataColumn[] { new DataColumn("cExcelCol_1", typeof(string)), new DataColumn("cExcelCol_2", typeof(string)) });
         DtExcelColumns_2.Columns.AddRange(new DataColumn[] { new DataColumn("cExcelCol_2", typeof(string)) });
     }
     catch (Exception ex)
     {
         ClsMessage.ProjectExceptionMessage(ex);
     }
 }
Exemplo n.º 9
0
        public DataTable GetExcelData(string StrxmlFile, string StrExcelSheetName)
        {
            try
            {
                DataTable DtReturnTable = new DataTable();

                using (var workBook = new XLWorkbook(StrxmlFile))
                {
                    var workSheet    = workBook.Worksheet(StrExcelSheetName);
                    var firstRowUsed = workSheet.FirstRowUsed();
                    if (firstRowUsed == null)
                    {
                        return(null);
                    }
                    var firstPossibleAddress = workSheet.Row(firstRowUsed.RowNumber()).FirstCell().Address;
                    var lastPossibleAddress  = workSheet.LastCellUsed().Address;

                    // Get a range with the remainder of the worksheet data (the range used)
                    var range = workSheet.Range(firstPossibleAddress, lastPossibleAddress).AsRange(); //.RangeUsed();
                    range.Clear(XLClearOptions.AllFormats);                                           // Treat the range as a table (to be able to use the column names)
                                                                                                      //var table = range.AsTable();
                    IXLTable xLTable = null;
                    if (range.Worksheet.Tables.Count() > 0)
                    {
                        xLTable = range.Worksheet.Table(0);
                    }
                    else
                    {
                        xLTable = range.CreateTable();
                    }
                    var table = xLTable;
                    DtReturnTable = table.AsNativeDataTable();
                    return(DtReturnTable);
                }
            }
            catch (Exception ex)
            {
                ClsMessage.ProjectExceptionMessage(ex);
                return(null);
            }
        }
Exemplo n.º 10
0
 public List <string> GetExcelSheet(string StrxmlFile)
 {
     try
     {
         List <string> LstExcelSheet = new List <string>();
         using (var workBook = new XLWorkbook(StrxmlFile))
         {
             var results = workBook.Worksheets;
             foreach (IXLWorksheet item in results)
             {
                 LstExcelSheet.Add(item.Name);
             }
         }
         return(LstExcelSheet);
     }
     catch (Exception ex)
     {
         ClsMessage.ProjectExceptionMessage(ex);
         return(null);
     }
 }