예제 #1
0
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            formProduct frm = new formProduct(this);

            frm.btnSave.Enabled   = true;
            frm.btnUpdate.Enabled = false;

            frm.LaodCategory();
            frm.ShowDialog();
        }
예제 #2
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            string colname = dataGridView1.Columns[e.ColumnIndex].Name;



            if (colname == "Edit")
            {
                formProduct frm = new formProduct(this);


                frm.btnSave.Enabled   = false;
                frm.btnUpdate.Enabled = true;

                frm.txtCode.Text     = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
                frm.txtDetail.Text   = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
                frm.txtPrice.Text    = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString();
                frm.cboCategory.Text = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
                frm.txtQuantity.Text = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();
                frm.txtCode.Focus();
                frm.ShowDialog();
            }


            else
            {
                if (MessageBox.Show("Are you sure want too delete this Category?", "Delete Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    sqlcon.Open();
                    cm = new SqlCommand("delete from tblProduct where code like '" + dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString() + "'", sqlcon);
                    cm.ExecuteNonQuery();
                    sqlcon.Close();
                    LoadRecord();
                }
            }
        }