Beispiel #1
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            string colName = dataGridView1.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.txtBy.Text == string.Empty)
                {
                    MessageBox.Show("Please enter stock in by", stitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); slist.txtRefNo.Focus(); return;
                }

                if (MessageBox.Show("Add this item?", stitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    cn.Open();
                    cm = new SQLiteCommand("insert into tblstockin (refno, pcode, qty, sdate, stockinby) values (@refno, @pcode, @qty, @sdate, @stockinby)", cn);
                    cm.Parameters.AddWithValue("@refno", slist.txtRefNo.Text);
                    cm.Parameters.AddWithValue("@pcode", dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString());
                    cm.Parameters.AddWithValue("@qty", Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[3].Value));
                    cm.Parameters.AddWithValue("@sdate", slist.dt1.Value.ToString("yyyy-MM-dd HH:mm:ss"));
                    cm.Parameters.AddWithValue("@stockinby", slist.txtBy.Text);
                    cm.ExecuteNonQuery();
                    cn.Close();

                    MessageBox.Show("Successfully added!", stitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    slist.LoadStockIn();
                }
            }
        }
        private void btnStockIn_Click(object sender, System.EventArgs e)
        {
            frmStockIn frm = new frmStockIn();

            frm.TopLevel = false;
            panel4.Controls.Add(frm);
            frm.BringToFront();
            frm.Show();
            frm.LoadStockIn();
        }