Beispiel #1
0
        private void textBox3_DoubleClick(object sender, EventArgs e)
        {
            ProductSelect PS = new ProductSelect();

            PS.ShowDialog();
            textBox3.Text = irow.ToString();
        }
Beispiel #2
0
 private void dataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
 {
     if (e.ColumnIndex == 1 && dataGridView1.CurrentRow.IsNewRow)
     {
         MachineSelect fm = new MachineSelect();
         fm.ShowDialog();
         if (_irow == 0)
         {
             return;
         }
         dataGridView1.AllowUserToAddRows = false;
         bs.AddNew();
         dataGridView1[e.ColumnIndex, e.RowIndex].Value = _irow;
         _irow = 0;
         dataGridView1.AllowUserToAddRows = true;
     }
     else if (e.ColumnIndex == 1)
     {
         MachineSelect fm = new MachineSelect();
         fm.ShowDialog();
         if (_irow == 0)
         {
             return;
         }
         dataGridView1[e.ColumnIndex, e.RowIndex].Value = _irow;
         _irow = 0;
         dataGridView1.AllowUserToAddRows = true;
     }
     else if (e.ColumnIndex == 2)
     {
         ProductSelect ps = new ProductSelect();
         ps.ShowDialog();
         if (_irow == 0)
         {
             return;
         }
         dataGridView1[e.ColumnIndex, e.RowIndex].Value = _irow;
         _irow = 0;
     }
 }
Beispiel #3
0
        private void dataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
        {
            if (e.ColumnIndex == dataGridView1.Columns["品號"].Index && dataGridView1.CurrentRow.IsNewRow)
            {
                ProductSelect fm = new ProductSelect();
                DataRow       dr;
                fm.ShowDialog();
                try {
                    dataGridView1.AllowUserToAddRows = false;
                    scheduleBs.AddNew();
                    dataGridView1[e.ColumnIndex, e.RowIndex].Value = irow;
                    dr = myds.Tables["產品資料表"].Rows.Find(dataGridView1["品號", e.RowIndex].Value.ToString());
                    dataGridView1["品名", e.RowIndex].Value     = dr["品名"];
                    dataGridView1["規格", e.RowIndex].Value     = dr["規格"];
                    dataGridView1["單價", e.RowIndex].Value     = dr["單價"];
                    dataGridView1["目前庫存數量", e.RowIndex].Value = dr["庫存量"].ToString();
                    dataGridView1.AllowUserToAddRows          = true;
                    dataGridView1.CurrentCell = dataGridView1[dataGridView1.Columns["數量"].Index, e.RowIndex];
                    _irow = new int();
                }
                catch
                {
                    dataGridView1.Rows.RemoveAt(e.RowIndex);
                    dataGridView1.AllowUserToAddRows = true;
                }
            }
            else if (e.ColumnIndex == dataGridView1.Columns["品號"].Index)
            {
                ProductSelect fm = new ProductSelect();
                fm.ShowDialog();
                //dataGridView1.AllowUserToAddRows = false;
                if (!dataGridView1[e.ColumnIndex, e.RowIndex].Value.ToString().Equals(_irow.ToString()))
                {
                    DataRow dr = myds.Tables["訂單明細資料表"].NewRow();
                    int     old;
                    int     old2;
                    try
                    {
                        old = int.Parse(myds.Tables["訂單明細資料表"].Rows[e.RowIndex]["品號"].ToString());
                    }
                    catch
                    {
                        old = 0;
                    }

                    try
                    {
                        old2 = int.Parse(myds.Tables["訂單明細資料表"].Rows[e.RowIndex]["數量"].ToString());
                    }
                    catch
                    {
                        old2 = 0;
                    }
                    dr["品號"] = _irow;
                    myds.Tables["訂單明細資料表"].Rows.Add(dr);
                    try
                    {
                        dataGridView1.Rows.Remove(dataGridView1.CurrentRow);
                        dr = myds.Tables["產品資料表"].Rows.Find(dataGridView1["品號", e.RowIndex].Value.ToString());
                        dataGridView1["品名", e.RowIndex].Value     = dr["品名"];
                        dataGridView1["規格", e.RowIndex].Value     = dr["規格"];
                        dataGridView1["單價", e.RowIndex].Value     = dr["單價"];
                        dataGridView1["目前庫存數量", e.RowIndex].Value = dr["庫存量"].ToString();
                        _irow = new int();
                    }
                    catch
                    {
                        dr       = myds.Tables["訂單明細資料表"].NewRow();
                        dr["品號"] = old;
                        myds.Tables["訂單明細資料表"].Rows.Add(dr);
                        dataGridView1.Rows.Remove(dataGridView1.CurrentRow);
                        dr = myds.Tables["產品資料表"].Rows.Find(dataGridView1["品號", e.RowIndex].Value.ToString());
                        if (old2 != 0)
                        {
                            dataGridView1["數量", e.RowIndex].Value = old2;
                        }
                        try
                        {
                            dataGridView1["品名", e.RowIndex].Value     = dr["品名"];
                            dataGridView1["規格", e.RowIndex].Value     = dr["規格"];
                            dataGridView1["單價", e.RowIndex].Value     = dr["單價"];
                            dataGridView1["目前庫存數量", e.RowIndex].Value = dr["庫存量"].ToString();
                        }
                        catch
                        {
                        }
                        _irow = new int();
                    }
                }
            }
        }