예제 #1
0
        public Form2(Order currentDemandItem)
        //: this()
        {
            //replace : this() by real code and fix modify issues

            actionToTake    = RecordOptions.ModifyRecord;
            button1.Enabled = false;
            button3.Enabled = false;

            this.Text    = RecordOptions.ModifyRecord.ToString();
            currentIndex = currentDemandItem.Id;

            ShowDBRecordInGridView(currentDemandItem);
            ShowStatusForm2(actionToTake.ToString());

            this.Activated += Form2_Activated;
            this.dataGridView2.DataError += this.DataGridView2_DataError;
        }
예제 #2
0
        public Form2()
        {
            InitializeComponent();
            var createdOn = DateTime.Now;

            actionToTake = RecordOptions.AddRecord;

            button1.Enabled = false;
            button3.Enabled = false;
            this.ControlBox = false;

            DataGridViewCellStyle headerStyle = dataGridView2.ColumnHeadersDefaultCellStyle;

            headerStyle.BackColor = Color.Navy;
            headerStyle.ForeColor = Color.White;
            headerStyle.Font      = new Font(dataGridView2.Font, FontStyle.Bold);

            this.Text = RecordOptions.AddRecord.ToString();

            //read header from SQL

            string[] gridHeader   = readGridHeader();
            string[] statusCBCell = readstatusCBCell();

            //dataGridView2.RowCount = 1;
            dataGridView2.ColumnCount = gridHeader.Length;
            dataGridView2.ReadOnly    = false;

            DataGridViewRow sampleRow = new DataGridViewRow();

            for (int i = 0; i < gridHeader.Length; i++)
            {
                dataGridView2.Columns[i].Name = gridHeader[i];
                if (i == 0)
                {
                    DataGridViewTextBoxCell textCell = new DataGridViewTextBoxCell();
                    textCell.Value = null;
                    sampleRow.Cells.Add(textCell);
                }
                else
                {
                    if (i == 4 || i == 8)
                    {
                        DataGridViewTextBoxCell textCell = new DataGridViewTextBoxCell();
                        textCell.Value = null;
                        sampleRow.Cells.Add(textCell);
                    }
                    else
                    {
                        if (i == 6)
                        {
                            DataGridViewComboBoxCell cbCell = new DataGridViewComboBoxCell();
                            cbCell.Items.AddRange(statusCBCell);
                            cbCell.Value = statusCBCell[0];
                            sampleRow.Cells.Add(cbCell);
                        }
                        else
                        {
                            DataGridViewTextBoxCell textCell = new DataGridViewTextBoxCell();
                            textCell.Value = null;
                            sampleRow.Cells.Add(textCell);
                        }
                    }
                }
            }
            dataGridView2.Rows.Add(sampleRow);
            //TODO ComboBox as GridCell

            dataGridView2.Rows[0].Cells[4].Value    = createdOn;
            dataGridView2.Rows[0].Cells[8].Value    = false;
            dataGridView2.Rows[0].Cells[4].ReadOnly = true;
            dataGridView2.Rows[0].Cells[8].ReadOnly = true;
            dataGridView2.Rows[0].Cells[0].ReadOnly = true;

            ShowStatusForm2(actionToTake.ToString());
            this.Activated += Form2_Activated;
            this.dataGridView2.DataError += this.DataGridView2_DataError;
        }