示例#1
0
        private void queryBuilder1_QueryElementControlCreated(QueryElement queryElement,
                                                              IQueryElementControl queryElementControl)
        {
            if (queryElementControl is IQueryColumnListControl)
            {
                var          queryColumnListControl = (IQueryColumnListControl)queryElementControl;
                DataGridView dataGridView           = (DataGridView)queryColumnListControl.DataGrid;

                _customColumn?.Dispose();

                // Create custom column
                _customColumn = new DataGridViewTextBoxColumn
                {
                    Name = "CustomColumn", HeaderText = "Custom Column", Width = 200, ValueType = typeof(string)
                };
                _customColumn.HeaderCell.Style.Font = new Font("Tahoma", 8, FontStyle.Bold);

                // Insert custom column to specified position
                dataGridView.Columns.Insert(2, _customColumn);

                // Handle requierd events
                dataGridView.CellBeginEdit   += DataGridView_CellBeginEdit;
                dataGridView.CellValueNeeded += DataGridView_CellValueNeeded;
                dataGridView.CellValuePushed += DataGridView_CellValuePushed;
            }
        }
示例#2
0
        private void toolStripComboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            int a = toolStripComboBox2.SelectedIndex + minimum;

            mdip.changed = true;
            if (MDIParent.z < a && toolStripComboBox1.SelectedIndex == 2)
            {
                DataGridViewTextBoxColumn _col;
                for (int i = 0; i < (a - MDIParent.z); i++)
                {
                    _col = new DataGridViewTextBoxColumn
                    {
                        Name       = "Column" + dataGridView1.ColumnCount,
                        HeaderText = (dataGridView1.ColumnCount - 2).ToString(),
                        Width      = 35,
                        SortMode   = DataGridViewColumnSortMode.Programmatic
                    };
                    dataGridView1.Columns.Insert(dataGridView1.Columns.Count - 2, _col);
                    _col.Dispose();
                }
            }
            else if (toolStripComboBox1.SelectedIndex == 2)
            {
                for (int i = 0; i < (MDIParent.z - a); i++)
                {
                    dataGridView1.Columns.RemoveAt(dataGridView1.ColumnCount - 3);
                }
            }
            MDIParent.z = toolStripComboBox2.SelectedIndex + 2;
        }
示例#3
0
        /// <summary>
        /// 列追加(テキストボックス)
        /// </summary>
        /// <param name="dgv">DataGridViewオブジェクト</param>
        /// <param name="HeaderText">表示タイトル</param>
        /// <param name="ColName" >カラム名称</param>
        /// <param name="DataPropertyName">元データ名</param>
        static public void AddCol_TextBox(DataGridView dgv, string HeaderText, string ColName, string DataPropertyName,
                                          bool readOnly)
        {
            DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn();

            col.DataPropertyName = DataPropertyName;
            col.HeaderText       = HeaderText;
            col.Name             = ColName;
            col.ReadOnly         = readOnly;
            col.SortMode         = DataGridViewColumnSortMode.NotSortable;
            dgv.Columns.Add(col);
            col.Dispose();
        }
示例#4
0
 /// <summary>
 /// 清理所有正在使用的资源。
 /// </summary>
 /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
     }
     if (Id != null)
     {
         Id.Dispose();
         Id = null;
     }
     if (gridview1 != null)
     {
         gridview1.Dispose();
         gridview1 = null;
     }
     if (pager1 != null)
     {
         pager1.Dispose();
         pager1 = null;
     }
     base.Dispose(disposing);
 }
示例#5
0
        private void LoadDBGrid()
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                DBGrid.Rows.Clear();
                DBGrid.Columns.Clear();
                DBGrid.ReadOnly              = false;
                DBGrid.AllowUserToAddRows    = false;
                DBGrid.AllowUserToDeleteRows = false;
                DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn();
                col.HeaderText       = clsTranslate.TranslateString("ProductId");
                col.DataPropertyName = "ProductId";
                col.Name             = "ProductId";
                col.Width            = 160;
                col.ReadOnly         = true;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                  = new DataGridViewTextBoxColumn();
                col.HeaderText       = clsTranslate.TranslateString("ProductName");
                col.DataPropertyName = "ProductName";
                col.Name             = "ProductName";
                col.Width            = 160;
                col.ReadOnly         = false;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                  = new DataGridViewTextBoxColumn();
                col.HeaderText       = clsTranslate.TranslateString("Specify");
                col.DataPropertyName = "Specify";
                col.Name             = "Specify";
                if (clsLxms.ShowProductSpecify() == 1)
                {
                    col.Width = 110;
                }
                else
                {
                    col.Visible = false;
                }
                col.ReadOnly = true;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                  = new DataGridViewTextBoxColumn();
                col.HeaderText       = clsTranslate.TranslateString("UnitNo");
                col.DataPropertyName = "UnitNo";
                col.Name             = "UnitNo";
                col.Width            = 40;
                col.ReadOnly         = false;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                  = new DataGridViewTextBoxColumn();
                col.HeaderText       = clsTranslate.TranslateString("Brand");
                col.DataPropertyName = "Brand";
                col.Name             = "Brand";
                col.Width            = 60;
                col.ReadOnly         = false;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                            = new DataGridViewTextBoxColumn();
                col.HeaderText                 = clsTranslate.TranslateString("Qty");
                col.DataPropertyName           = "Qty";
                col.Name                       = "Qty";
                col.Width                      = 60;
                col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                col.ReadOnly                   = false;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                            = new DataGridViewTextBoxColumn();
                col.HeaderText                 = clsTranslate.TranslateString("Price");
                col.DataPropertyName           = "Price";
                col.Name                       = "Price";
                col.Width                      = 60;
                col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                col.ReadOnly                   = false;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                  = new DataGridViewTextBoxColumn();
                col.HeaderText       = clsTranslate.TranslateString("Remark");
                col.DataPropertyName = "Remark";
                col.Name             = "Remark";
                col.Width            = 80;
                col.ReadOnly         = false;
                DBGrid.Columns.Add(col);
                col.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
示例#6
0
        private void toolStripComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            mdip.changed = true;
            toolStripComboBox2.Enabled = true;
            toolStripComboBox3.Enabled = true;
            dataGridView1.Rows.Clear();
            dataGridView1.Columns.Clear();
            dataGridView1.Columns.Add("Column0", "Наим. процесса");
            dataGridView1.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
            dataGridView1.Columns[0].Frozen       = true;

            switch (toolStripComboBox1.SelectedIndex)
            {
            case 0:     //Ритмичный поток
                dataGridView1.Columns.Add("Column1", "Ритм бригады");
                dataGridView1.Columns.Add("Column2", "Рабочие");
                dataGridView1.Columns.Add("Column3", "Стоимость");
                dataGridView1.Columns[0].Width = 115;
                dataGridView1.Columns[1].Width = 115;
                for (int i = 0; i < MDIParent.p; i++)
                {
                    dataGridView1.Rows.Add("Процесс" + (i + 1));
                }
                dataGridView1[1, 0].Style.BackColor = Color.AntiqueWhite;
                dataGridView1[2, 0].Style.BackColor = Color.AntiqueWhite;
                dataGridView1[3, 0].Style.BackColor = Color.AntiqueWhite;
                break;

            case 1:     //Разноритмичный поток
                dataGridView1.Columns.Add("Column1", "Ритм бригады");
                dataGridView1.Columns.Add("Column2", "Рабочие");
                dataGridView1.Columns.Add("Column3", "Стоимость");
                dataGridView1.Columns[0].Width = 115;
                dataGridView1.Columns[1].Width = 115;
                for (int i = 0; i < MDIParent.p; i++)
                {
                    dataGridView1.Rows.Add("Процесс" + (i + 1));
                }
                break;

            case 2:     //Неритмичный поток
                dataGridView1.Columns.Add("Column1", "Рабочие");
                dataGridView1.Columns.Add("Column2", "Стоимость");
                dataGridView1.Columns[0].Width = 115;
                DataGridViewTextBoxColumn _col;
                for (int i = 0; i < (MDIParent.z); i++)
                {
                    _col = new DataGridViewTextBoxColumn
                    {
                        Name       = "Column" + dataGridView1.ColumnCount,
                        HeaderText = (dataGridView1.ColumnCount - 2).ToString(),
                        Width      = 35,
                        SortMode   = DataGridViewColumnSortMode.Programmatic
                    };
                    dataGridView1.Columns.Insert(dataGridView1.Columns.Count - 2, _col);
                    _col.Dispose();
                }
                for (int i = 0; i < MDIParent.p; i++)
                {
                    dataGridView1.Rows.Add("Процесс" + (i + 1));
                }
                break;
            }
        }
示例#7
0
        private void LoadData()
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                BindingCollection <modActionScoresSummary> list = _dal.GetActionScoresSummary(string.Empty, dtpFrom.Text, dtpTo.Text, out Util.emsg);
                if (list != null && list.Count > 0)
                {
                    ArrayList arr    = new ArrayList();
                    ArrayList arrman = new ArrayList();
                    foreach (modActionScoresSummary mod in list)
                    {
                        if (arr == null || arr.Count == 0)
                        {
                            arr.Add(mod.ActionType);
                            arrman.Add(mod.ActionMan);
                        }
                        else
                        {
                            bool exists = false;
                            for (int i = 0; i < arr.Count; i++)
                            {
                                if (arr[i].ToString() == mod.ActionType)
                                {
                                    exists = true;
                                    break;
                                }
                            }
                            if (!exists)
                            {
                                arr.Add(mod.ActionType);
                            }

                            exists = false;
                            for (int i = 0; i < arrman.Count; i++)
                            {
                                if (arrman[i].ToString() == mod.ActionMan)
                                {
                                    exists = true;
                                    break;
                                }
                            }
                            if (!exists)
                            {
                                arrman.Add(mod.ActionMan);
                            }
                        }
                    }
                    DBGrid.Rows.Clear();
                    DBGrid.Columns.Clear();
                    DBGrid.AlternatingRowsDefaultCellStyle.BackColor = Color.Empty;
                    DBGrid.ReadOnly = true;

                    DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn();
                    col.HeaderText       = clsTranslate.TranslateString("ActionMan");
                    col.DataPropertyName = "ActionMan";
                    col.Name             = "ActionMan";
                    col.Width            = 120;
                    col.ReadOnly         = false;
                    DBGrid.Columns.Add(col);
                    col.Dispose();

                    for (int i = 0; i < arr.Count; i++)
                    {
                        col                            = new DataGridViewTextBoxColumn();
                        col.HeaderText                 = arr[i].ToString();
                        col.DataPropertyName           = arr[i].ToString();
                        col.Name                       = arr[i].ToString();
                        col.Width                      = 70;
                        col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                        col.ReadOnly                   = true;
                        DBGrid.Columns.Add(col);
                        col.Dispose();
                    }
                    col                            = new DataGridViewTextBoxColumn();
                    col.HeaderText                 = clsTranslate.TranslateString("Sum");
                    col.DataPropertyName           = "Sum";
                    col.Name                       = "Sum";
                    col.Width                      = 70;
                    col.ReadOnly                   = true;
                    col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                    col.DefaultCellStyle.BackColor = frmOptions.ALTERNATING_BACKCOLOR;
                    DBGrid.Columns.Add(col);
                    col.Dispose();

                    for (int i = 0; i < arrman.Count; i++)
                    {
                        DataGridViewRow row = new DataGridViewRow();
                        row.CreateCells(DBGrid);
                        row.Cells[0].Value             = arrman[i].ToString();
                        row.DefaultCellStyle.BackColor = Color.Empty;
                        DBGrid.Rows.Add(row);
                    }
                    DataGridViewRow rowsum = new DataGridViewRow();
                    rowsum.CreateCells(DBGrid);
                    rowsum.Cells[0].Value             = clsTranslate.TranslateString("Sum");
                    rowsum.DefaultCellStyle.BackColor = frmOptions.ALTERNATING_BACKCOLOR;
                    DBGrid.Rows.Add(rowsum);

                    foreach (modActionScoresSummary mod in list)
                    {
                        for (int i = 0; i < DBGrid.RowCount; i++)
                        {
                            if (mod.ActionMan == DBGrid.Rows[i].Cells[0].Value.ToString())
                            {
                                for (int j = 0; j < DBGrid.ColumnCount; j++)
                                {
                                    if (mod.ActionType == DBGrid.Columns[j].Name)
                                    {
                                        DBGrid.Rows[i].Cells[j].Value = mod.Scores;
                                        break;
                                    }
                                }
                                break;
                            }
                        }
                    }
                    decimal sum;
                    for (int i = 0; i < DBGrid.RowCount - 1; i++)
                    {
                        sum = Convert.ToDecimal("0");
                        for (int j = 1; j < DBGrid.ColumnCount - 1; j++)
                        {
                            if (DBGrid.Rows[i].Cells[j].Value != null)
                            {
                                sum += Convert.ToDecimal(DBGrid.Rows[i].Cells[j].Value);
                            }
                        }
                        DBGrid.Rows[i].Cells[DBGrid.ColumnCount - 1].Value = sum;
                    }

                    for (int j = 1; j < DBGrid.ColumnCount; j++)
                    {
                        sum = Convert.ToDecimal("0");
                        for (int i = 0; i < DBGrid.RowCount - 1; i++)
                        {
                            if (DBGrid.Rows[i].Cells[j].Value != null)
                            {
                                sum += Convert.ToDecimal(DBGrid.Rows[i].Cells[j].Value);
                            }
                        }
                        DBGrid.Rows[DBGrid.RowCount - 1].Cells[j].Value = sum;
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(Util.emsg))
                    {
                        MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
示例#8
0
        private void LoadData()
        {
            DBGrid.Columns.Clear();
            ArrayList arrHeader = new ArrayList();
            ArrayList arrTitle  = new ArrayList();

            arrHeader.Add(clsTranslate.TranslateString("GroupId"));
            arrHeader.Add(clsTranslate.TranslateString("TaskCode"));
            arrHeader.Add(clsTranslate.TranslateString("TaskName"));
            arrTitle.Add(clsTranslate.TranslateString("GroupId"));
            arrTitle.Add(clsTranslate.TranslateString("TaskCode"));
            arrTitle.Add(clsTranslate.TranslateString("TaskName"));
            dalUserList blluser = new dalUserList();
            BindingCollection <modUserList> listuser = blluser.GetIList(true, out Util.emsg);

            if (listuser != null && listuser.Count > 0)
            {
                foreach (modUserList mod in listuser)
                {
                    arrHeader.Add(mod.UserId);
                    arrTitle.Add(mod.UserName);
                }
            }
            for (int i = 0; i < arrHeader.Count; i++)
            {
                //if (i <= 1)
                //{
                DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn();
                col.HeaderText       = arrTitle[i].ToString();
                col.DataPropertyName = arrHeader[i].ToString();
                col.Name             = arrHeader[i].ToString();
                if (i == 1)
                {
                    col.Visible = false;
                }
                else if (i == 0 || i == 2)
                {
                    col.Width = 120;
                }
                else
                {
                    col.Width = 30;
                }
                col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                DBGrid.Columns.Add(col);
                col.Dispose();
                //}
                //else
                //{
                //    DataGridViewCheckBoxColumn col = new DataGridViewCheckBoxColumn();
                //    col.HeaderText = arrTitle[i].ToString();
                //    col.DataPropertyName = arrHeader[i].ToString();
                //    col.Width = 70;
                //    DBGrid.Columns.Add(col);
                //    col.Dispose();
                //}
            }

            DataGridViewRow row;
            dalTaskList     bll = new dalTaskList();
            BindingCollection <modTaskList> list = bll.GetIList(string.Empty, false, false, out Util.emsg);

            if (list != null && list.Count > 0)
            {
                foreach (modTaskList mod in list)
                {
                    row = new DataGridViewRow();
                    row.CreateCells(DBGrid);
                    row.Cells[0].Value = clsTranslate.TranslateString(mod.GroupId);
                    row.Cells[1].Value = mod.TaskCode;
                    row.Cells[2].Value = clsTranslate.TranslateString(mod.TaskName);
                    DBGrid.Rows.Add(row);
                    row.Dispose();
                }
            }
            for (int iCol = 3; iCol < DBGrid.ColumnCount; iCol++)
            {
                dalTaskGrant blltg = new dalTaskGrant();
                BindingCollection <modTaskGrant> listtg = blltg.GetUserGrantData(false, false, DBGrid.Columns[iCol].Name, string.Empty, string.Empty, out Util.emsg);
                if (listtg != null && listtg.Count > 0)
                {
                    foreach (modTaskGrant mod in listtg)
                    {
                        for (int iRow = 0; iRow < DBGrid.RowCount; iRow++)
                        {
                            if (mod.TaskCode.CompareTo(DBGrid.Rows[iRow].Cells[1].Value.ToString()) == 0)
                            {
                                DBGrid.Rows[iRow].Cells[iCol].Value = "√";
                                break;
                            }
                        }
                    }
                }
            }
            DBGrid.Columns[2].Frozen = true;
            DBGrid.AlternatingRowsDefaultCellStyle.BackColor = Color.Empty;
            DBGrid.Columns[0].DefaultCellStyle.BackColor     = frmOptions.ALTERNATING_BACKCOLOR;
            DBGrid.Columns[1].DefaultCellStyle.BackColor     = frmOptions.ALTERNATING_BACKCOLOR;
            DBGrid.Columns[2].DefaultCellStyle.BackColor     = frmOptions.ALTERNATING_BACKCOLOR;
            DBGrid.MergeColumnNames.Add(arrHeader[0].ToString());
            DBGrid.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.True;
        }
示例#9
0
        private void But_connect_Click(object sender, EventArgs e)
        {
            connection = new SqlConnection(connectString);
            connection.Open();
            //MessageBox.Show(connection.State.ToString());

            ds = new DataSet("Northwind");

            SqlCommand command;

            daState = new SqlDataAdapter();
            command = new SqlCommand("Select * From State", connection);
            daState.SelectCommand = command;

            dtState = ds.Tables.Add("State");
            daState.Fill(dtState);


            daCustomer = new SqlDataAdapter();

            // - SELECT
            command = new SqlCommand("Select ':)' as Etykieta,* From Customer", connection);
            daCustomer.SelectCommand = command;
            // - INSERT
            command = new SqlCommand("INSERT INTO Customer (FirstName,LastName,Address,City,State,ZipCode,AccountNumber) VALUES (@FirstName,@LastName,@Address,@City,@State,@ZipCode,@AccountNumber)", connection);
            //command.Parameters.Add("@id", SqlDbType.Int, 0, "id");
            command.Parameters.Add("@FirstName", SqlDbType.NVarChar, 40, "FirstName");
            command.Parameters.Add("@LastName", SqlDbType.NVarChar, 40, "LastName");
            command.Parameters.Add("@Address", SqlDbType.NVarChar, 40, "Address");
            command.Parameters.Add("@City", SqlDbType.NVarChar, 40, "City");
            command.Parameters.Add("@State", SqlDbType.NVarChar, 40, "State");
            command.Parameters.Add("@ZipCode", SqlDbType.NVarChar, 40, "ZipCode");
            command.Parameters.Add("@AccountNumber", SqlDbType.NVarChar, 40, "AccountNumber");
            daCustomer.InsertCommand = command;
            // - UPDATE
            command = new SqlCommand("UPDATE Customer SET FirstName = @FirstName, LastName = @LastName, Address = @Address, City = @City, State = @State, ZipCode = @ZipCode, AccountNumber = @AccountNumber WHERE id = @oldid", connection);
            //command.Parameters.Add("@id", SqlDbType.NChar, 5, "id");
            command.Parameters.Add("@FirstName", SqlDbType.NVarChar, 40, "FirstName");
            command.Parameters.Add("@LastName", SqlDbType.NVarChar, 40, "LastName");
            command.Parameters.Add("@Address", SqlDbType.NVarChar, 40, "Address");
            command.Parameters.Add("@City", SqlDbType.NVarChar, 40, "City");
            command.Parameters.Add("@State", SqlDbType.NVarChar, 40, "State");
            command.Parameters.Add("@ZipCode", SqlDbType.NVarChar, 40, "ZipCode");
            command.Parameters.Add("@AccountNumber", SqlDbType.NVarChar, 40, "AccountNumber");
            SqlParameter parameter = command.Parameters.Add("@oldid", SqlDbType.Int, 0, "id");

            parameter.SourceVersion  = DataRowVersion.Original;
            daCustomer.UpdateCommand = command;
            // - DELETE
            command = new SqlCommand("DELETE FROM Customer WHERE id = @id", connection);
            // Add the parameters for the DeleteCommand.
            parameter = command.Parameters.Add("@id", SqlDbType.Int, 0, "id");
            parameter.SourceVersion  = DataRowVersion.Original;
            daCustomer.DeleteCommand = command;

            dtCustomer = ds.Tables.Add("Customer");
            daCustomer.Fill(dtCustomer);

            bsCustomer            = new BindingSource();
            bsCustomer.DataSource = dtCustomer;
            //bsCustomer.CurrentChanged += new EventHandler(Current_Changed);

            GridCustomer.AutoSize           = false;
            GridCustomer.DataSource         = bsCustomer;
            NavigatorCustomer.BindingSource = bsCustomer;

            GridCustomer.Use(p =>
            {
                p.ColumnHeadersDefaultCellStyle.Font      = new Font("Tahoma", 9, FontStyle.Bold);
                p.ColumnHeadersDefaultCellStyle.ForeColor = Color.Black;
                p.ColumnHeadersDefaultCellStyle.BackColor = Color.Yellow;
                p.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.TopLeft;
                p.EnableHeadersVisualStyles = false;
                p.AutoGenerateColumns       = false;
                p.Columns.Clear();
                int iCol;
                iCol = p.Columns.Add("col_FirstName", "Imię");
                p.Columns[iCol].DataPropertyName = "FirstName";
                iCol = p.Columns.Add("col_LastName", "Nazwisko");
                p.Columns[iCol].DataPropertyName = "LastName";
                iCol = p.Columns.Add("col_Address", "Ulica");
                p.Columns[iCol].DataPropertyName = "Address";
                iCol = p.Columns.Add("col_City", "Miejscowość");
                p.Columns[iCol].DataPropertyName = "City";

                //iCol = p.Columns.Add("col_State", "Województwo");
                //p.Columns[iCol].DataPropertyName = "State";

                DataGridViewComboBoxColumn cb = new DataGridViewComboBoxColumn();
                cb.HeaderText       = "Województwo";
                cb.DataPropertyName = "State";
                cb.Name             = "col_State";
                cb.MaxDropDownItems = 4;
                cb.DisplayStyle     = DataGridViewComboBoxDisplayStyle.Nothing;
                //cb.Items.Add("Śląskie");
                //cb.Items.Add("Małopolskie");
                cb.DataSource    = dtState;
                cb.ValueMember   = "name";
                cb.DisplayMember = "name";
                p.Columns.Add(cb);

                iCol = p.Columns.Add("col_ZipCode", "Kod pocztowy");
                p.Columns[iCol].DataPropertyName = "ZipCode";
                iCol = p.Columns.Add("col_AccountNumber", "Nr konta");
                p.Columns[iCol].DataPropertyName = "AccountNumber";
                //p.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            });

            daOrder = new SqlDataAdapter();
            // - SELECT
            command = new SqlCommand("Select * From Orders", connection);
            daOrder.SelectCommand = command;
            // - INSERT
            command = new SqlCommand("INSERT INTO ORDERS (CustomerId,OrderDate,Invoice,Paymend,Price) VALUES (@CustomerId,@OrderDate,@Invoice,@Paymend,@Price)", connection);
            command.Parameters.Add("@CustomerId", SqlDbType.Int, 0, "CustomerId");
            command.Parameters.Add("@OrderDate", SqlDbType.Date, 0, "OrderDate");
            command.Parameters.Add("@Invoice", SqlDbType.NVarChar, 100, "Invoice");
            command.Parameters.Add("@Paymend", SqlDbType.Int, 0, "Paymend");
            command.Parameters.Add("@Price", SqlDbType.Money, 0, "Price");
            daOrder.InsertCommand = command;
            // - UPDATE
            command = new SqlCommand("UPDATE ORDERS SET OrderDate = @OrderDate, Invoice = @Invoice, Paymend = @Paymend, Price = @Price WHERE id = @oldid", connection);
            command.Parameters.Add("@OrderDate", SqlDbType.Date, 0, "OrderDate");
            command.Parameters.Add("@Invoice", SqlDbType.NVarChar, 100, "Invoice");
            command.Parameters.Add("@Paymend", SqlDbType.Int, 0, "Paymend");
            command.Parameters.Add("@Price", SqlDbType.Money, 0, "Price");
            parameter = command.Parameters.Add("@oldid", SqlDbType.Int, 0, "id");
            parameter.SourceVersion = DataRowVersion.Original;
            daOrder.UpdateCommand   = command;
            // - DELETE
            command = new SqlCommand("DELETE FROM ORDERS WHERE id = @id", connection);
            // Add the parameters for the DeleteCommand.
            parameter = command.Parameters.Add("@id", SqlDbType.Int, 0, "id");
            parameter.SourceVersion = DataRowVersion.Original;
            daOrder.DeleteCommand   = command;

            dtOrder = ds.Tables.Add("Orders");
            daOrder.Fill(dtOrder);

            DataRelation relCustOrder = new DataRelation("CustomersOrders", dtCustomer.Columns["id"], dtOrder.Columns["customerID"]);

            // Add the relation to the DataSet.
            ds.Relations.Add(relCustOrder);

            bsOrder            = new BindingSource();
            bsOrder.DataSource = bsCustomer;
            bsOrder.DataMember = "CustomersOrders";

            // --
            NavigatorOrder.BindingSource = bsOrder;

            GridOrder.Use(p =>
            {
                p.DataSource = bsOrder;
                p.AutoSize   = false;
                p.ColumnHeadersDefaultCellStyle.Font      = new Font("Tahoma", 9, FontStyle.Bold);
                p.ColumnHeadersDefaultCellStyle.ForeColor = Color.Black;
                p.ColumnHeadersDefaultCellStyle.BackColor = Color.Yellow;
                p.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.TopLeft;
                p.EnableHeadersVisualStyles = false;
                p.AutoGenerateColumns       = false;
                p.Columns.Clear();
                //p.Columns.Add("OrderDate", "Data zamówienia");
                DataGridViewColumn col1 = new DataGridViewTextBoxColumn();
                col1.DataPropertyName   = "Invoice";
                col1.Name       = "Invoice";
                col1.HeaderText = "Nr paragonu";
                col1.ValueType  = typeof(string);
                p.Columns.Add(col1);
                col1.Dispose();
                //DataGridViewColumn col2 = new DataGridViewTextBoxColumn();
                CalendarColumn col2   = new CalendarColumn();
                col2.DataPropertyName = "OrderDate";
                col2.Name             = "OrderDate";
                col2.HeaderText       = "Data zamówienia";
                col2.ValueType        = typeof(DateTime);
                p.Columns.Add(col2);
                col2.Dispose();
                DataGridViewCheckBoxColumn chbox = new DataGridViewCheckBoxColumn();
                chbox.DataPropertyName           = "Paymend";
                chbox.Name       = "Paymend";
                chbox.HeaderText = "Czy zapłacone";
                chbox.ValueType  = typeof(int);
                p.Columns.Add(chbox);

                DataGridViewTextBoxColumn col4 = new DataGridViewTextBoxColumn();
                col4.DataPropertyName          = "Price";
                col4.Name       = "Price";
                col4.HeaderText = "Kwota";
                col4.ValueType  = typeof(float);
                col4.DefaultCellStyle.Format = "c";
                p.Columns.Add(col4);

                DataGridViewImageColumn img = new DataGridViewImageColumn();
                img.Name           = "Image";
                img.HeaderText     = "Ikona";
                img.ValuesAreIcons = true;
                p.Columns.Add(img);
            });
            ControlsStat();
        }
示例#10
0
        private void LoadDBGrid()
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                DBGrid.Rows.Clear();
                DBGrid.Columns.Clear();
                DBGrid.ReadOnly              = false;
                DBGrid.AllowUserToAddRows    = false;
                DBGrid.AllowUserToDeleteRows = false;
                DBGrid.ReadOnly              = false;
                DBGrid.SelectionMode         = DataGridViewSelectionMode.CellSelect;
                DBGrid.AlternatingRowsDefaultCellStyle.BackColor = Color.Empty;

                DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn();
                col.HeaderText       = clsTranslate.TranslateString("ProductId");
                col.DataPropertyName = "ProductId";
                col.Name             = "ProductId";
                col.ReadOnly         = false;
                col.Visible          = false;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                  = new DataGridViewTextBoxColumn();
                col.HeaderText       = clsTranslate.TranslateString("ProductName");
                col.DataPropertyName = "ProductName";
                col.Name             = "ProductName";
                col.Width            = 200;
                col.ReadOnly         = true;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                  = new DataGridViewTextBoxColumn();
                col.HeaderText       = clsTranslate.TranslateString("Barcode");
                col.DataPropertyName = "Barcode";
                col.Name             = "Barcode";
                col.Visible          = false;
                col.ReadOnly         = true;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                  = new DataGridViewTextBoxColumn();
                col.HeaderText       = clsTranslate.TranslateString("UnitNo");
                col.DataPropertyName = "UnitNo";
                col.Name             = "UnitNo";
                col.Width            = 50;
                col.ReadOnly         = true;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                            = new DataGridViewTextBoxColumn();
                col.HeaderText                 = clsTranslate.TranslateString("Qty");
                col.DataPropertyName           = "Qty";
                col.Name                       = "Qty";
                col.Width                      = 80;
                col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                col.ReadOnly                   = false;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                            = new DataGridViewTextBoxColumn();
                col.HeaderText                 = clsTranslate.TranslateString("Price");
                col.DataPropertyName           = "Price";
                col.Name                       = "Price";
                col.Width                      = 100;
                col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                col.ReadOnly                   = false;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                            = new DataGridViewTextBoxColumn();
                col.HeaderText                 = clsTranslate.TranslateString("Amount");
                col.DataPropertyName           = "Amount";
                col.Name                       = "Amount";
                col.Width                      = 120;
                col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                col.DefaultCellStyle.ForeColor = Color.LightGray;
                col.ReadOnly                   = true;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                  = new DataGridViewTextBoxColumn();
                col.HeaderText       = clsTranslate.TranslateString("Remark");
                col.DataPropertyName = "Remark";
                col.Name             = "Remark";
                col.Width            = 150;
                col.ReadOnly         = false;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                  = new DataGridViewTextBoxColumn();
                col.HeaderText       = clsTranslate.TranslateString("Specify");
                col.DataPropertyName = "Specify";
                col.Name             = "Specify";
                col.Visible          = false;
                col.ReadOnly         = true;
                DBGrid.Columns.Add(col);
                col.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
示例#11
0
        private void LoadData()
        {
            if (cboAccName.ComboBox.SelectedValue == null || cboExpenseType.ComboBox.SelectedValue == null)
            {
                return;
            }

            DBGrid.Columns.Clear();

            DataGridViewTextBoxColumn col0 = new DataGridViewTextBoxColumn();

            col0.HeaderText       = "月";
            col0.DataPropertyName = "Month";
            col0.Name             = "Month";
            col0.Width            = 50;
            DBGrid.Columns.Add(col0);

            DataGridViewTextBoxColumn col1 = new DataGridViewTextBoxColumn();

            col1.HeaderText       = "日";
            col1.DataPropertyName = "Day";
            col1.Name             = "Day";
            col1.Width            = 50;
            DBGrid.Columns.Add(col1);

            DataGridViewTextBoxColumn col2 = new DataGridViewTextBoxColumn();

            col2.HeaderText       = "凭证号";
            col2.DataPropertyName = "AccSeq";
            col2.Name             = "AccSeq";
            col2.Width            = 50;
            DBGrid.Columns.Add(col2);

            DataGridViewTextBoxColumn col3 = new DataGridViewTextBoxColumn();

            col3.HeaderText       = "摘要";
            col3.DataPropertyName = "Digest";
            col3.Name             = "Digest";
            col3.Width            = 220;
            DBGrid.Columns.Add(col3);

            DataGridViewTextBoxColumn col4 = new DataGridViewTextBoxColumn();

            col4.HeaderText                 = "小计";
            col4.DataPropertyName           = "RowSum";
            col4.Name                       = "RowSum";
            col4.Width                      = 120;
            col4.DefaultCellStyle.BackColor = frmOptions.ALTERNATING_BACKCOLOR;
            //col4.DefaultCellStyle.ForeColor = Color.Red;
            col4.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            DBGrid.Columns.Add(col4);

            dalAccExpenseForm dal = new dalAccExpenseForm();
            BindingCollection <modAccExpenseColumn> list = dal.GetExpenseColumn(cboAccName.ComboBox.SelectedValue.ToString(), cboExpenseType.ComboBox.SelectedValue.ToString(), out Util.emsg);

            if (list != null && list.Count > 0)
            {
                var p = list.Select(c => c.ExpenseName).Distinct();
                foreach (string expenseName in p)
                {
                    DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn();
                    col.HeaderText                 = expenseName;
                    col.DataPropertyName           = expenseName;
                    col.Name                       = expenseName;
                    col.Width                      = 100;
                    col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                    DBGrid.Columns.Add(col);
                    col.Dispose();
                }

                var q = list.Select(c => new { Month = c.FormDate.Month, Day = c.FormDate.Day, AccSeq = c.AccSeq, Digest = c.Digest }).OrderBy(a => a.Month).OrderBy(a => a.Day).OrderBy(a => a.AccSeq).Distinct().ToList();
                q.ForEach(item =>
                {
                    DataGridViewRow row = new DataGridViewRow();
                    row.CreateCells(DBGrid);
                    row.Height         = 36;
                    row.Cells[0].Value = item.Month;
                    row.Cells[1].Value = item.Day;
                    row.Cells[2].Value = item.AccSeq;
                    row.Cells[3].Value = item.Digest;
                    decimal rowSum     = 0;
                    for (int i = 5; i < DBGrid.ColumnCount; i++)
                    {
                        var t = list.Where(a => a.FormDate.Day == item.Day && a.AccSeq == item.AccSeq && a.Digest == item.Digest && a.ExpenseName == DBGrid.Columns[i].Name).Select(c => c.ExpenseMny).FirstOrDefault();
                        if (t != 0)
                        {
                            row.Cells[i].Value = t;
                            rowSum            += t;
                        }
                    }
                    row.Cells[4].Value = rowSum;
                    DBGrid.Rows.Add(row);
                    row.Dispose();
                });

                DataGridViewRow rowTotal = new DataGridViewRow();
                rowTotal.CreateCells(DBGrid);
                rowTotal.Height         = 36;
                rowTotal.Cells[2].Value = "合  计";
                for (int i = 4; i < DBGrid.ColumnCount; i++)
                {
                    decimal colSum = 0;
                    for (int j = 0; j < DBGrid.RowCount; j++)
                    {
                        colSum += DBGrid.Rows[j].Cells[i].Value == null ? 0 : decimal.Parse(DBGrid.Rows[j].Cells[i].Value.ToString());
                    }
                    rowTotal.Cells[i].Value = colSum;
                }
                rowTotal.DefaultCellStyle.BackColor = frmOptions.ALTERNATING_BACKCOLOR;
                DBGrid.Rows.Add(rowTotal);
            }
            else
            {
                if (!string.IsNullOrEmpty(Util.emsg))
                {
                    MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
示例#12
0
        private void LoadDBGrid()
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                DBGrid.Rows.Clear();
                DBGrid.Columns.Clear();
                DBGrid.ReadOnly              = false;
                DBGrid.AllowUserToAddRows    = false;
                DBGrid.AllowUserToDeleteRows = false;
                DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn();
                col.HeaderText       = clsTranslate.TranslateString("ProductId");
                col.DataPropertyName = "ProductId";
                col.Name             = "ProductId";
                col.Visible          = false;
                col.ReadOnly         = true;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                  = new DataGridViewTextBoxColumn();
                col.HeaderText       = clsTranslate.TranslateString("ProductName");
                col.DataPropertyName = "ProductName";
                col.Name             = "ProductName";
                col.Width            = 160;
                col.ReadOnly         = true;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                            = new DataGridViewTextBoxColumn();
                col.HeaderText                 = clsTranslate.TranslateString("Qty");
                col.DataPropertyName           = "Qty";
                col.Name                       = "Qty";
                col.Width                      = 60;
                col.ReadOnly                   = true;
                col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                            = new DataGridViewTextBoxColumn();
                col.HeaderText                 = clsTranslate.TranslateString("Current Price");
                col.DataPropertyName           = "Current Price";
                col.Name                       = "Current Price";
                col.Width                      = 90;
                col.ReadOnly                   = true;
                col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                            = new DataGridViewTextBoxColumn();
                col.HeaderText                 = clsTranslate.TranslateString("True Price");
                col.DataPropertyName           = "True Price";
                col.Name                       = "True Price";
                col.Width                      = 80;
                col.ReadOnly                   = false;
                col.DefaultCellStyle.ForeColor = Color.Red;
                col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                            = new DataGridViewTextBoxColumn();
                col.HeaderText                 = clsTranslate.TranslateString("Current Mny");
                col.DataPropertyName           = "Current Mny";
                col.Name                       = "Current Mny";
                col.Width                      = 80;
                col.ReadOnly                   = true;
                col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                            = new DataGridViewTextBoxColumn();
                col.HeaderText                 = clsTranslate.TranslateString("True Mny");
                col.DataPropertyName           = "True Mny";
                col.Name                       = "True Mny";
                col.Width                      = 90;
                col.ReadOnly                   = true;
                col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                            = new DataGridViewTextBoxColumn();
                col.HeaderText                 = clsTranslate.TranslateString("Differ");
                col.DataPropertyName           = "Differ";
                col.Name                       = "Differ";
                col.Width                      = 90;
                col.ReadOnly                   = true;
                col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                  = new DataGridViewTextBoxColumn();
                col.HeaderText       = clsTranslate.TranslateString("Remark");
                col.DataPropertyName = "Remark";
                col.Name             = "Remark";
                col.Width            = 80;
                col.ReadOnly         = false;
                DBGrid.Columns.Add(col);
                col.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
示例#13
0
        private void LoadDBGrid()
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                DBGrid.Rows.Clear();
                DBGrid.Columns.Clear();
                DBGrid.ReadOnly              = false;
                DBGrid.AllowUserToAddRows    = false;
                DBGrid.AllowUserToDeleteRows = false;
                DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn();
                col.HeaderText       = clsTranslate.TranslateString("SubjectId");
                col.DataPropertyName = "SubjectId";
                col.Name             = "SubjectId";
                col.Width            = 60;
                col.ReadOnly         = true;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                  = new DataGridViewTextBoxColumn();
                col.HeaderText       = clsTranslate.TranslateString("SubjectName");
                col.DataPropertyName = "SubjectName";
                col.Name             = "SubjectId";
                col.Width            = 110;
                col.ReadOnly         = true;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                  = new DataGridViewTextBoxColumn();
                col.HeaderText       = clsTranslate.TranslateString("DetailId");
                col.DataPropertyName = "DetailId";
                col.Name             = "DetailId";
                col.Width            = 110;
                col.ReadOnly         = true;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                  = new DataGridViewTextBoxColumn();
                col.HeaderText       = clsTranslate.TranslateString("DetailName");
                col.DataPropertyName = "DetailName";
                col.Name             = "DetailName";
                col.Width            = 50;
                col.ReadOnly         = false;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                  = new DataGridViewTextBoxColumn();
                col.HeaderText       = clsTranslate.TranslateString("Currency");
                col.DataPropertyName = "Currency";
                col.Name             = "Currency";
                col.Width            = 40;
                col.ReadOnly         = true;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                            = new DataGridViewTextBoxColumn();
                col.HeaderText                 = clsTranslate.TranslateString("Mny");
                col.DataPropertyName           = "Mny";
                col.Name                       = "Mny";
                col.Width                      = 60;
                col.ReadOnly                   = false;
                col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                            = new DataGridViewTextBoxColumn();
                col.HeaderText                 = clsTranslate.TranslateString("ExchangeRate");
                col.DataPropertyName           = "ExchangeRate";
                col.Name                       = "ExchangeRate";
                col.Width                      = 60;
                col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                col.ReadOnly                   = true;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                            = new DataGridViewTextBoxColumn();
                col.HeaderText                 = clsTranslate.TranslateString("CheckNo");
                col.DataPropertyName           = "CheckNo";
                col.Name                       = "CheckNo";
                col.Width                      = 60;
                col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                col.ReadOnly                   = false;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                            = new DataGridViewTextBoxColumn();
                col.HeaderText                 = clsTranslate.TranslateString("CheckType");
                col.DataPropertyName           = "CheckType";
                col.Name                       = "CheckType";
                col.Width                      = 60;
                col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                col.ReadOnly                   = true;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                            = new DataGridViewTextBoxColumn();
                col.HeaderText                 = clsTranslate.TranslateString("BankName");
                col.DataPropertyName           = "BankName";
                col.Name                       = "BankName";
                col.Width                      = 60;
                col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                col.ReadOnly                   = true;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                            = new DataGridViewTextBoxColumn();
                col.HeaderText                 = clsTranslate.TranslateString("PromiseDate");
                col.DataPropertyName           = "PromiseDate";
                col.Name                       = "PromiseDate";
                col.Width                      = 90;
                col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                col.ReadOnly                   = false;
                DBGrid.Columns.Add(col);
                col.Dispose();

                col                  = new DataGridViewTextBoxColumn();
                col.HeaderText       = clsTranslate.TranslateString("Remark");
                col.DataPropertyName = "Remark";
                col.Name             = "Remark";
                col.Width            = 80;
                col.ReadOnly         = false;
                DBGrid.Columns.Add(col);
                col.Dispose();

                string[] showcell = { "SubjectId", "CheckType", "BankName" };
                DBGrid.SetParam(showcell);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }