Exemplo n.º 1
0
        async Task SetDataTable(List <Clients> SD)
        {
            try
            {
                await Task.Run(() =>
                {
                    GridControl1.Invoke(new Action(() => GridControl1.BeginUpdate()));
                    GridControl1.Invoke(new Action(() => GridControl1.DataSource = null));
                    GridControl1.Invoke(new Action(() => GridView1.Columns.Clear()));

                    DataTable dt = Ext.ToDataTable(SD);

                    GridControl1.Invoke(new Action(() => GridControl1.DataSource = dt));

                    for (int i = 0; i < GridView1.Columns.Count; i++)
                    {
                        GridView1.Columns[i].OptionsFilter.FilterPopupMode = DevExpress.XtraGrid.Columns.FilterPopupMode.CheckedList;
                    }

                    GridView1.Columns["ID"].Visible            = false;
                    GridView1.Columns["Name"].Caption          = "Անուն";
                    GridView1.Columns["LastName"].Caption      = "Ազգանուն";
                    GridView1.Columns["BirdDate"].Caption      = "Ծննդյան Ամս.";
                    GridView1.Columns["City"].Caption          = "Բնակավայր";
                    GridView1.Columns["Contacts"].Caption      = "Կոնտակտային Տվ.";
                    GridView1.Columns["Destination"].Caption   = "Մեկնման Վայր";
                    GridView1.Columns["TravelDate"].Caption    = "Մեկնման Ամս.";
                    GridView1.Columns["PersonsNumber"].Caption = "Անձերի Քանակ";
                    GridView1.Columns["Childs"].Caption        = "Երեխաներ";
                    GridView1.Columns["Comments"].Caption      = "Մեկնաբանություն";

                    if (GridView1.RowCount > 0)
                    {
                        if (GridView1.Columns["Name"].Summary.ActiveCount == 0)
                        {
                            GridView1.Columns["Name"].Summary.Add(new GridColumnSummaryItem(DevExpress.Data.SummaryItemType.Count, "Name", "Count` {0}"));
                        }
                    }

                    GridView1.ClearSelection();
                    GridControl1.Invoke(new Action(() => GridControl1.EndUpdate()));
                });
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        private void LoadExcelFile()
        {
            if (String.IsNullOrEmpty(FileName))
            {
                throw new Exception("Select file");
            }

            OleDbConnection  connExcel = new OleDbConnection();
            OleDbCommand     cmdExcel  = new OleDbCommand();
            OleDbDataAdapter oda       = new OleDbDataAdapter();

            connExcel           = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + FileName + ";Extended Properties=Excel 12.0;");
            cmdExcel.Connection = connExcel;
            connExcel.Open();
            System.Data.DataTable dt = connExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);

            if (dt == null)
            {
                throw new Exception("File read error");
            }

            foreach (DataRow row in dt.Rows)
            {
                string t = row["TABLE_NAME"].ToString();
                EI.Add(new ExcelInfo {
                    ID = t, Sheet = CleanUpSheetName(t)
                });
            }

            CleanUpSheetName(EI[0].ID);

            connExcel.Close();

            GridControl1.BeginUpdate();
            GridControl1.DataSource = null;
            GridView1.Columns.Clear();

            GridControl1.DataSource = Ext.ToDataTable(EI);

            GridView1.Columns["ID"].Visible = false;

            GridView1.ClearSelection();
            GridControl1.EndUpdate();
        }
Exemplo n.º 3
0
        private void DoRowDoubleClick(GridView view, Point pt)
        {
            try
            {
                GridHitInfo info = view.CalcHitInfo(pt);
                if (info.InRow || info.InRowCell)
                {
                    if (info.Column == null)
                    {
                    }
                    else
                    {
                        if ((view.GetRowCellValue(info.RowHandle, "ID")) == DBNull.Value || Convert.ToInt32(view.GetRowCellValue(info.RowHandle, "ID")) <= 0)
                        {
                            return;
                        }

                        GridView1.ClearSelection();
                        GridView1.SelectRows(info.RowHandle, info.RowHandle);

                        roClient.Text     = String.Concat(view.GetRowCellValue(info.RowHandle, "Name").ToString(), " ", view.GetRowCellValue(info.RowHandle, "LastName").ToString());
                        roBDate.Text      = String.IsNullOrEmpty(view.GetRowCellValue(info.RowHandle, "BirdDate").ToString()) ? String.Empty : Convert.ToDateTime(view.GetRowCellValue(info.RowHandle, "BirdDate")).ToShortDateString();
                        roCity.Text       = view.GetRowCellValue(info.RowHandle, "City").ToString();
                        roContact.Text    = view.GetRowCellValue(info.RowHandle, "Contacts").ToString();
                        roPlace.Text      = view.GetRowCellValue(info.RowHandle, "Destination").ToString();
                        roTravelDate.Text = String.IsNullOrEmpty(view.GetRowCellValue(info.RowHandle, "TravelDate").ToString()) ? String.Empty : Convert.ToDateTime(view.GetRowCellValue(info.RowHandle, "TravelDate")).ToShortDateString();
                        roNumber.Text     = view.GetRowCellValue(info.RowHandle, "PersonsNumber").ToString();
                        roChild.Text      = view.GetRowCellValue(info.RowHandle, "Childs").ToString();
                        roComment.Text    = view.GetRowCellValue(info.RowHandle, "Comments").ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }