Example #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("Are you sure to save this Product?", "Save Product", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    string bid = ""; string cid = "";
                    //Getting the id of brand
                    cn.Close();
                    cn.Open();
                    cm = new SqlCommand("select id from tblBrand where brand like '" + cboBrands.Text + "'", cn);
                    dr = cm.ExecuteReader();
                    dr.Read();
                    if (dr.HasRows)
                    {
                        bid = dr[0].ToString();
                    }
                    dr.Close();
                    cn.Close();
                    //getting the id of category
                    cn.Open();
                    cm = new SqlCommand("select id from tblCategory where Category like '" + cboCategory.Text + "'", cn);
                    dr = cm.ExecuteReader();
                    dr.Read();
                    if (dr.HasRows)
                    {
                        cid = dr[0].ToString();
                    }
                    dr.Close();
                    cn.Close();
                    //Saving Product
                    cn.Open();
                    cm = new SqlCommand("INSERT INTo tblProduct(pcode,barcode, pdesc, bid, cid, price, reorder)VALUES(@pcode,@barcode, @pdesc, @bid, @cid, @price, @reorder)", cn);
                    cm.Parameters.AddWithValue("@pcode", txtPCode.Text);
                    cm.Parameters.AddWithValue("@barcode", txtBarcode.Text);
                    cm.Parameters.AddWithValue("@pdesc", txtDescription.Text);
                    cm.Parameters.AddWithValue("@bid", bid);
                    cm.Parameters.AddWithValue("@cid", cid);
                    cm.Parameters.AddWithValue("@price", Double.Parse(txtPrice.Text));
                    cm.Parameters.AddWithValue("@reorder", int.Parse(txtReorder.Text));
                    cm.ExecuteNonQuery();

                    cn.Close();
                    MessageBox.Show("Product has been successfully saved.", "Product Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    clear();
                    plist.LoadProducts();
                }
            }
            catch (Exception ex)
            {
                cn.Close();
                MessageBox.Show(ex.Message);
            }
        }
 private void btnSave_Click(object sender, EventArgs e)
 {
     try {
         cn.Open();
         cm = new SqlCommand("Select * from tblProduct", cn);
         dr = cm.ExecuteReader();
         dr.Read();
         if (dr.HasRows)
         {
             cn.Close();
             cn.Open();
             cm = new SqlCommand("update tblProduct set disc_per = @disc_per", cn);
             cm.Parameters.AddWithValue("@disc_per", double.Parse(txtDiscount.Text));
             cm.ExecuteNonQuery();
             cn.Close();
             MessageBox.Show("Discount updated Successfully", "Discount", MessageBoxButtons.OK, MessageBoxIcon.Information);
             f.LoadProducts();
             this.Dispose();
         }
         else
         {
             MessageBox.Show("You have no Product in Record");
         }
     }
     catch (Exception ex) {
         cn.Close();
         MessageBox.Show(ex.Message);
     }
 }
Example #3
0
        private void btnProduct_Click(object sender, EventArgs e)
        {
            frmProductList frmProduct = new frmProductList();

            frmProduct.TopLevel = false;
            MainPanel.Controls.Add(frmProduct);
            frmProduct.BringToFront();
            frmProduct.LoadProducts();
            //frmProduct.loadRecords();
            frmProduct.Show();
        }
Example #4
0
        private void btnProduct_Click(object sender, EventArgs e)
        {
            ReferenceBtn.Enabled = true;
            ReferenceFrm.Dispose();
            btnProduct.Enabled = false;
            frmProductList frmProduct = new frmProductList();

            ReferenceFrm        = frmProduct;
            ReferenceBtn        = btnProduct;
            frmProduct.TopLevel = false;
            MainPanel.Controls.Add(frmProduct);
            frmProduct.BringToFront();
            frmProduct.LoadProducts();
            //frmProduct.loadRecords();
            frmProduct.Show();
        }