Ejemplo n.º 1
0
    protected void AddProd_Click(object sender, EventArgs e)
    {
        AddProduct1 prodmodel = new AddProduct1();
        Product     product   = CreateProduct();

        lblresult1.Text = prodmodel.AddProduct(product);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Email"] == null)
        {
            Response.Redirect("Login.aspx");
        }
        if (!Page.IsPostBack)
        {
            if (Request.QueryString["Id"] != null)
            {
                int         prodid = Convert.ToInt32(Request.QueryString["Id"]);
                AddProduct1 ap     = new AddProduct1();
                Product     prod   = ap.GetProduct(prodid);
                idproduct.Value = Request.QueryString["Id"];
                productselect1.SelectedValue = prod.name;
                priceselect1.SelectedValue   = prod.price;
                pdesc1.Text = prod.description;


                imageproduct.Value = prod.image1;
            }
            else
            {
                Response.Redirect("Ad_ViewProd.aspx");
            }
        }
    }
    protected void UpdateProd_Click(object sender, EventArgs e)
    {
        string  imagename = "";
        Product prod      = new Product();

        prod.Id   = Convert.ToInt32(idproduct.Value);
        prod.name = productselect1.SelectedItem.Value;


        prod.description = pdesc1.Text;
        prod.price       = priceselect1.SelectedItem.Value;
        System.Diagnostics.Debug.WriteLine(prod.name + prod.description + prod.price);


        if (productpic1.HasFile)
        {
            string file_name4 = productpic1.FileName.ToString() + "";
            productpic1.PostedFile.SaveAs(Server.MapPath("~/images/") + file_name4);
            string filePath4 = productpic1.PostedFile.FileName;
            imagename = Path.GetFileName(filePath4);
            string ext4         = Path.GetExtension(imagename);
            string contenttype4 = String.Empty;
            switch (ext4)
            {
            case ".jpg":
                contenttype4 = "image/jpg";
                break;

            case ".png":
                contenttype4 = "image/png";
                break;

            case ".gif":
                contenttype4 = "image/gif";
                break;
            }
            Stream       fs4    = productpic1.PostedFile.InputStream;
            BinaryReader br4    = new BinaryReader(fs4);
            Byte[]       bytes4 = br4.ReadBytes((Int32)fs4.Length);
        }
        else
        {
            imagename = imageproduct.Value;
        }

        prod.image1 = imagename;

        AddProduct1 ap      = new AddProduct1();
        String      promise = ap.UpdateProduct(prod);

        lblresult1.Text = promise;
    }
Ejemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Email"] == null)
        {
            Response.Redirect("Login.aspx");
        }
        if (Request.QueryString["payid"] != null)
        {
            payid = Convert.ToInt32(Request.QueryString["payid"]);                                  //this is to get the pay id based on the previous page
            Payment1    payclass     = new Payment1();
            Payment     payment      = payclass.GetPayment(payid);                                  //get the specific payment data using the pay id
            AddProduct1 productclass = new AddProduct1();
            Product     product      = productclass.GetProduct(Convert.ToInt32(payment.productId)); //get the product name using the product id stated in the payment data
            Plan        plan         = productclass.GetPlan(Convert.ToInt32(payment.planId));
            Login1      userclass    = new Login1();
            User        user         = userclass.GetUser(Convert.ToInt32(payment.userId)); //get the user name using the user id stated in the payment data

            productprice = Convert.ToDouble(product.price);
            planprice    = Convert.ToDouble(plan.Price.ToString()); //convert to double cuz price is string in data so to add numbers, convert to double first
            subtotal     = planprice + productprice;
            double tax = 0.06 * subtotal;
            total = subtotal + tax;

            fullname    = user.fullName;
            email       = user.email;
            companyname = user.companyName; //based on variable declared, this is equal to what will be displayed in front end
            country     = user.country;
            cardno      = payment.CardNumber;
            cardname    = payment.NameCard;
            productname = product.name;
            prodid      = product.Id;
            planname    = plan.name;
            datepayment = payment.datePayment.ToString();
        }
        else
        {
            Response.Redirect("ProductCatalogue.aspx");
        }
    }