Ejemplo n.º 1
0
        private void button3_Click(object sender, EventArgs e)
        {
            checkflag = 0;
            BarCode   = barcode_txt.Text.ToString();
            if (barcode_txt.Text != "")
            {
                checkflag = ClsAddProduct.CheckProd(BarCode);
                if (checkflag == 0)
                {
                    MessageBox.Show("Prouduct Was Not found In The Stock\nPleaze Added It Here");
                    AddProduct AddproSt = new AddProduct();
                    AddproSt.Show();
                    Hide();
                }
                else
                {
                    MessageBox.Show("Prouduct Was found In The Stock\nYou Can Change The Properties Now");
                    SqlCommand cmd = new SqlCommand();
                    cmd.Connection  = clset.cn;
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "ProdFormSP1";
                    cmd.Parameters.Add("@BarCode", SqlDbType.VarChar, 100).Value = barcode_txt.Text;
                    DataTable      dt1 = new DataTable();
                    SqlDataAdapter da  = new SqlDataAdapter(cmd);
                    da.Fill(dt1);
                    clset.cn.Open();
                    dt.Load(cmd.ExecuteReader());
                    if (dt.Rows.Count > 0)
                    {
                        barcode_txt.Text     = dt.Rows[0][0].ToString();
                        prod_txt.Text        = dt.Rows[0][2].ToString();
                        company_txt.Text     = dt.Rows[0][1].ToString();
                        price_txt.Text       = dt.Rows[0][3].ToString();
                        qty_txt.Text         = dt.Rows[0][4].ToString();
                        barcode_txt.ReadOnly = true;
                        prod_txt.ReadOnly    = false;
                        company_txt.ReadOnly = false;
                        price_txt.ReadOnly   = false;
                        qty_txt.ReadOnly     = false;
                    }
                    clset.cn.Close();
                }
            }
            else

            {
                MessageBox.Show("No Barcode has Inserted\nPleaze Insert The Barcode");
                ActiveControl        = barcode_txt;
                barcode_txt.ReadOnly = false;
                prod_txt.ReadOnly    = true;
                company_txt.ReadOnly = true;
                price_txt.ReadOnly   = true;
                qty_txt.ReadOnly     = true;
                barcode_txt.Text     = "";
                prod_txt.Text        = "";
                company_txt.Text     = "";
                price_txt.Text       = "";
                qty_txt.Text         = "";
            }
        }
Ejemplo n.º 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     checkflag = ClsAddProduct.CheckProd(BarCode);
     if (checkflag == 1)
     {
         SqlCommand cmd = new SqlCommand();
         cmd.Connection  = clset.cn;
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.CommandText = "UpdateProd";
         cmd.Parameters.Add("@ProdName", SqlDbType.VarChar, 10).Value = prod_txt.Text;
         int   qty   = int.Parse(qty_txt.Text);
         float price = float.Parse(price_txt.Text);
         cmd.Parameters.Add("@Qty", SqlDbType.Int).Value = qty;
         cmd.Parameters.Add("@ProdPrice", SqlDbType.Decimal, 18).Value = price;
         cmd.Parameters.Add("@Company", SqlDbType.VarChar, 10).Value   = company_txt.Text;
         clset.cn.Open();
         cmd.ExecuteNonQuery();
         MessageBox.Show("Update Broduct Was Success");
         clset.cn.Close();
         MessageBox.Show("You Can Ubdate Another Product");
         ActiveControl        = barcode_txt;
         barcode_txt.ReadOnly = false;
         prod_txt.ReadOnly    = true;
         company_txt.ReadOnly = true;
         price_txt.ReadOnly   = true;
         qty_txt.ReadOnly     = true;
         barcode_txt.Text     = "";
         prod_txt.Text        = "";
         company_txt.Text     = "";
         price_txt.Text       = "";
         qty_txt.Text         = "";
     }
     else
     {
         if (barcode_txt.Text != "")
         {
             MessageBox.Show("Prouduct Was Not found In The Stock\nPleaze Added It Here");
             AddProduct AddproSt = new AddProduct();
             AddproSt.Show();
             Hide();
         }
         else
         {
             MessageBox.Show("No Barcode has Inserted\nPleaze Insert The Barcode");
             ActiveControl        = barcode_txt;
             barcode_txt.ReadOnly = false;
             prod_txt.ReadOnly    = true;
             company_txt.ReadOnly = true;
             price_txt.ReadOnly   = true;
             qty_txt.ReadOnly     = true;
             barcode_txt.Text     = "";
             prod_txt.Text        = "";
             company_txt.Text     = "";
             price_txt.Text       = "";
             qty_txt.Text         = "";
         }
     }
 }
Ejemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            int checkflag = 0;

            checkflag = ClsAddProduct.CheckProd(barcode_txt.Text);
            if (checkflag == 0)
            {
                if (barcode_txt.Text != "" && name_txt.Text != "" && company_txt.Text != "" && price_txt.Text != "" &&
                    qty_txt.Text != "" && weight_txt.Text != "")
                {
                    int          Qty       = int.Parse(qty_txt.Text);
                    float        prodprice = float.Parse(price_txt.Text);
                    float        Weight    = float.Parse(weight_txt.Text);
                    FileStream   fs        = new FileStream(imgloc, FileMode.Open, FileAccess.Read);
                    BinaryReader br        = new BinaryReader(fs);
                    byte[]       img       = null;
                    img = br.ReadBytes((int)fs.Length);
                    ClsAddProduct.Addprodex(barcode_txt.Text, company_txt.Text, Qty, name_txt.Text, prodprice, img, Weight, chooseexpdate.Text, chooseDatein.Text);
                    barcode_txt.Text  = "";
                    name_txt.Text     = "";
                    company_txt.Text  = "";
                    price_txt.Text    = "";
                    qty_txt.Text      = "";
                    weight_txt.Text   = "";
                    pictureBox1.Image = null;
                    barcode_txt.Focus();
                }
            }
            else
            {
                //if found in expdate
                checkflag = ClsAddProduct.Checkexp(chooseexpdate.Text);
                if (checkflag == 1)
                {
                    if (MessageBox.Show("Prouduct Was found In The Stock\nDo Youn Want Edit It ?", "Edit Product", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        EditProduct Addpro = new EditProduct();
                        Addpro.Show();
                        Hide();
                    }
                    else
                    {
                        barcode_txt.Text  = "";
                        name_txt.Text     = "";
                        company_txt.Text  = "";
                        price_txt.Text    = "";
                        qty_txt.Text      = "";
                        weight_txt.Text   = "";
                        pictureBox1.Image = null;
                        barcode_txt.Focus();
                    }
                }
                else
                {
                    SqlCommand cmd2 = new SqlCommand();
                    cmd2.Connection  = clset.cn;
                    cmd2.CommandType = CommandType.StoredProcedure;
                    cmd2.CommandText = "InsertExpdateex2";
                    cmd2.Parameters.Add("@BarCode", SqlDbType.VarChar, 100).Value = barcode_txt.Text;
                    cmd2.Parameters.Add("@ProdName", SqlDbType.VarChar, 10).Value = name_txt.Text;
                    FileStream   fs  = new FileStream(imgloc, FileMode.Open, FileAccess.Read);
                    BinaryReader br  = new BinaryReader(fs);
                    byte[]       img = null;
                    img = br.ReadBytes((int)fs.Length);
                    cmd2.Parameters.Add("@ProdImage", SqlDbType.Image).Value     = img;
                    cmd2.Parameters.Add("@expdate", SqlDbType.VarChar, 15).Value = chooseexpdate.Text;

                    cmd2.Parameters.Add("@Company", SqlDbType.VarChar, 10).Value   = company_txt.Text;
                    cmd2.Parameters.Add("@ProdPrice", SqlDbType.Decimal, 18).Value = price_txt.Text;
                    cmd2.Parameters.Add("@Qty", SqlDbType.Int).Value            = qty_txt.Text;
                    cmd2.Parameters.Add("@datein", SqlDbType.VarChar, 15).Value = chooseDatein.Text;
                    clset.cn.Open();
                    cmd2.ExecuteNonQuery();
                    clset.cn.Close();
                    MessageBox.Show("Added Broduct Was Success");
                    barcode_txt.Text  = "";
                    name_txt.Text     = "";
                    company_txt.Text  = "";
                    price_txt.Text    = "";
                    qty_txt.Text      = "";
                    weight_txt.Text   = "";
                    pictureBox1.Image = null;
                    barcode_txt.Focus();
                }
            }
        }