Example #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     localhost.Service1 sc = new localhost.Service1();
     foreach (localhost.Store s in sc.shoowstores())
     {
         if (comboBox1.GetItemText(comboBox1.SelectedItem) == s.Name)
         {
             localhost.Product p = new localhost.Product();
             bool yes            = true;
             bool yes2           = true;
             sc.addStoreProducts(s, txtproductname.Text, int.Parse(txtprice.Text), yes2, int.Parse(txtquantity.Text), yes);
         }
     }
     MessageBox.Show("Product is Added to" + comboBox1.Text);
     txtprice.Text       = "";
     txtproductname.Text = "";
     txtquantity.Text    = "";
 }
    protected void btnAddProduct_Click(object sender, EventArgs e)
    {
        localhost.Product p = new localhost.Product();

        p.Id = txtId.Text;

        p.Name = txtName.Text;

        p.Information = txtInformation.Text;

        p.MinCap = int.Parse(txtMinCap.Text);

        p.MaxCap = int.Parse(txtMaxCap.Text);

        p.CurCap = int.Parse(txtCurCap.Text);

        p.Price = int.Parse(txtPrice.Text);

        p.MyPrice = int.Parse(txtMyPrice.Text);

        string provider = dropProvider.SelectedValue;

        p.Provider = s.GetProviderId(provider);


        if (fuImage.HasFile)
        {
            p.Pic = fuImage.FileName;

            fuImage.SaveAs(Server.MapPath("pics/products/" + fuImage.FileName));
        }

        else
        {
            p.Pic = "default.png";
        }


        p.Status = 1;

        s.AddNewProduct(p);

        Response.Write(Functions.AlertRedirect("The product added", "Home.aspx"));
    }
Example #3
0
 private void gvshowproducts_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     localhost.Service1 sc = new localhost.Service1();
     localhost.Product  p  = new localhost.Product();
     foreach (localhost.Store sto in sc.shoowstores())
     {
         if (sto.Name == comboBox1.Text)
         {
             p = sto.Products[e.RowIndex];
         }
     }
     sc.getproduct(comboBox1.Text, p);
     foreach (localhost.Store s in sc.shoowstores())
     {
         if (s.Name == comboBox1.Text)
         {
             BindingSource source = new BindingSource();
             source.DataSource         = s.Products;
             gvshowproducts.DataSource = source;
         }
     }
 }
Example #4
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        int provider;

        if (btnUpdate.Text.Equals("Update"))
        {
            AllowUpdate(true);
            btnUpdate.Text = "Save";
        }

        else
        {
            dtProduct = s.SearchProductById(lblId.Text);
            //Update
            localhost.Product p = new localhost.Product();

            p.Id = lblId.Text;

            if (txtName.Text.Length == 0)
            {
                p.Name = dtProduct.Rows[0][1].ToString();
            }

            else
            {
                p.Name = txtName.Text;
            }

            if (txtInformation.Text.Length == 0)
            {
                p.Information = dtProduct.Rows[0][2].ToString();
            }

            else
            {
                p.Information = txtInformation.Text;
            }

            if (txtMinCap.Text.Length == 0)
            {
                p.MinCap = int.Parse(dtProduct.Rows[0][3].ToString());
            }

            else
            {
                p.MinCap = int.Parse(txtMinCap.Text);
            }

            if (txtMaxCap.Text.Length == 0)
            {
                p.MaxCap = int.Parse(dtProduct.Rows[0][4].ToString());
            }

            else
            {
                p.MaxCap = int.Parse(txtMaxCap.Text);
            }

            if (txtCurCap.Text.Length == 0)
            {
                p.CurCap = int.Parse(dtProduct.Rows[0][5].ToString());
            }

            else
            {
                p.CurCap = int.Parse(txtCurCap.Text);
            }

            if (txtPrice.Text.Length == 0)
            {
                p.Price = int.Parse(dtProduct.Rows[0][6].ToString());
            }

            else
            {
                p.Price = int.Parse(txtPrice.Text);
            }

            if (txtMyPrice.Text.Length == 0)
            {
                p.MyPrice = int.Parse(dtProduct.Rows[0][7].ToString());
            }

            else
            {
                p.MyPrice = int.Parse(txtMyPrice.Text);
            }

            if (dropProvider.SelectedIndex == 0)
            {
                provider = int.Parse(dtProduct.Rows[0][6].ToString());
            }

            else
            {
                provider = s.GetProviderId(dropProvider.SelectedValue);
            }

            p.Provider = provider;
            if (fuImage.HasFile)
            {
                p.Pic = fuImage.FileName;

                fuImage.SaveAs(Server.MapPath("pics/products/" + fuImage.FileName));
            }

            else
            {
                p.Pic = dtProduct.Rows[0][9].ToString();
            }


            p.Status = int.Parse(dtProduct.Rows[0][10].ToString());

            s.UpdateProduct(p);

            AllowUpdate(false);
            btnUpdate.Text = "Update";

            Response.Write(Functions.AlertRedirect("The product has updated", "ShowProduct.aspx?id=" + lblId.Text));
        }
    }