Esempio n. 1
0
        private void dataGridProduct_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            string colName = dataGridProduct.Columns[e.ColumnIndex].Name;

            if (colName == "colSelect")
            {
                if (slist.txtRefNo.Text == string.Empty)
                {
                    MessageBox.Show("Please Enter Reference No", stitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    slist.txtRefNo.Focus();
                    return;
                }
                if (slist.txtStockInBy.Text == string.Empty)
                {
                    MessageBox.Show("Please Enter Stock In By", stitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    slist.txtStockInBy.Focus();
                    return;
                }
                if (MessageBox.Show("Add This Item ?", stitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)

                {
                    string productPcode = dataGridProduct.Rows[e.RowIndex].Cells[1].Value.ToString();
                    cn.Open();
                    cm = new SqlCommand("insert into tblStockIn(refno, pcode, sdate, stockinby)values(@refno, @pcode, @sdate, @stockinby)", cn); //* from tblProduct pcode like '" + dataGridProduct.Rows[e.RowIndex].Cells[1].Value.ToString() + "'", cn);
                    cm.Parameters.AddWithValue("@refno", slist.txtRefNo.Text);
                    cm.Parameters.AddWithValue("@pcode", productPcode);
                    cm.Parameters.AddWithValue("@sdate", slist.date1.Value);
                    cm.Parameters.AddWithValue("@stockinby", slist.txtStockInBy.Text);
                    cm.ExecuteNonQuery();
                    cn.Close();

                    MessageBox.Show("successfully Added", stitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    slist.loadStockIn();
                }
            }
        }