Esempio n. 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("Are you sure! you want to update this Product?", "Save Product", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    string cid = "";

                    sqlcon.Open();
                    cm = new SqlCommand("Select id from  tblCategory where category like '" + cboCategory.Text + "'", sqlcon);
                    dr = cm.ExecuteReader();
                    dr.Read();

                    if (dr.HasRows)
                    {
                        cid = dr[0].ToString();
                    }
                    dr.Close();

                    sqlcon.Close();



                    sqlcon.Open();
                    cm = new SqlCommand("INSERT INTO tblProduct (code, detail, cid, price,quantity) VALUES(@pcode, @detail, @cid, @price,@quantity) ", sqlcon);
                    cm.Parameters.AddWithValue("@pcode ", txtCode.Text);
                    cm.Parameters.AddWithValue("@detail ", txtDetail.Text);
                    cm.Parameters.AddWithValue("@cid ", cid);
                    cm.Parameters.AddWithValue("@price", txtPrice.Text);
                    cm.Parameters.AddWithValue("@code ", txtCode.Text);
                    cm.Parameters.AddWithValue("@quantity ", txtQuantity.Text);
                    cm.ExecuteNonQuery();

                    sqlcon.Close();
                    MessageBox.Show("Product has been successfully Saved!");
                    Clear();
                    flist.LoadRecord();
                    this.Dispose();
                }
            }
            catch (Exception ex)
            {
                sqlcon.Close();

                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
        private void btnProduct_Click(object sender, EventArgs e)
        {
            fromProductLsit frm = new fromProductLsit();

            frm.TopLevel = false;
            panel3.Controls.Add(frm);
            frm.BringToFront();

            frm.LoadRecord();
            frm.Show();
        }