public static string AddProduct(string category, string selectedImage, string txtType, string txtPrice,
                                        string txtName, string txtDescription, string txtQuant)
        {
            if (selectedImage == null || txtType == "" || txtPrice == "" || txtName == "" ||
                txtDescription == "" || txtQuant == "")
            {
                return("One of fields is empty");
            }
            string name = txtName;
            string des  = txtDescription;
            //int price = ConvertToNumber(txtPrice.Text);
            int price = LogicClass.ConvertToNumber(txtPrice);

            if (price <= 0)
            {
                return("Price can't be negative or zero");
            }
            string date  = DateTime.Now.ToString("d.M.yyyy");
            string type  = txtType;
            string img   = "Images/" + selectedImage;
            int    quant = ConvertToNumber(txtQuant);

            if (quant < 0)
            {
                return("Quantity must be zero or more");
            }
            //string category = drpProductType.SelectedValue.ToString();
            Item pr = new Item(1, category, name, quant, img, des, date, price, type);

            ConnectionClass.AddProduct(pr);
            //lblResult.Text = "";
            return("Product was successfully added!");
        }
Пример #2
0
        private void FillPage()
        {
            LinkedList <Item> des = new LinkedList <Item>();

            if (!IsPostBack)
            {
                des = ConnectionClass.GetAllDesktopByProccess();
            }
            else
            {
                des = ConnectionClass.GetDesktopByProccess(DropDownList1.SelectedValue);
            }

            /*
             * string sb = "";
             * foreach (Item d in des)
             * {
             *      sb += @"<table class='desktopTable'>" +
             *      "<tr><th rowspan='3' width='150px'><a href='/Buy.aspx?id=" + d.ID + "'><img runat='server' src='" + d.Image + "' /></a></th>" +
             *      "<th width='50px'>Name: </td><td>" + d.Type + " " + d.Name + "</td>" +
             *      "<th rowspan='3' width='50px'>" +
             *      "<button type='button' onclick='redirect(" + d.ID + ")' name='buy' class='css3button'>buy</button>" +
             *      //"<asp:Button CssClass='css3button' onclick='redirect(" + d.ID + ")'  runat='server' Text='buy' />"+
             *      "</th></tr><tr><th>Price: </th><td>" + d.Price + " $</td></tr>" +
             *      "<tr><th>Description: </th><td>" + d.Description + "</td></tr></table>";
             * }
             */
            lblOutput.Text = LogicClass.GetDesktopProducts(des);
        }
Пример #3
0
        // get product from database and create html table to view the information
        private void ViewInfo()
        {
            lblChoose.Text = LogicClass.ViewInfoBeforeBuyProduct(ProductID);

            /*
             * Item item = ConnectionClass.GetProductByID(ProductID);
             * if (item == null)
             * {
             *      lblChoose.Text = "Sorry this product doesnt exist.";
             *      //Response.Redirect("/Default.aspx");
             *      return;
             * }
             * string[] des = item.Description.Split(',');
             * for (int i = 0; i < des.Length; i++)
             * {
             *      des[i] = des[i].Substring(0, des[i].LastIndexOf(' '));
             * }
             * string outStr = "";
             * if (item.Category.Equals("Desktop"))
             * {
             *      outStr += "<table class='buyTable'>" +
             *                      "<tr><td rowspan='9'><img runat='server' src='" + item.Image + "' /></td>" +
             *                      "<td colspan='2' style='text-align:center'><b>" + item.Category + " " + item.Type + " " + item.Name + "</b></td></tr>" +
             *                      "<tr bgcolor='#eeeeee'><td>Proccessor</td><td>" + des[0] + "</td></tr>" +
             *                      "<tr><td>Motherboard</td><td>" + des[1] + "</td></tr>" +
             *                      "<tr bgcolor='#eeeeee'><td>Video</td><td>NVIDIA GeForce GTX650 1GB</td></tr>" +
             *                      "<tr><td>RAM</td><td>" + des[2] + "</td></tr>" +
             *                      "<tr bgcolor='#eeeeee'><td>Memory</td><td>" + des[3] + "</td></tr>" +
             *                      "<tr><td>PSU</td><td>Seasonic 620W</td></tr>" +
             *                      "<tr bgcolor='#eeeeee'><td>Disc Drive</td><td>LG SATA 22X SUPER-MULTI DVD Burner</td></tr>" +
             *                      "<tr><td>Warranty</td><td>15 Years</td></tr>" +
             *              "</table>";
             * }
             * if (item.Category.Equals("Notebook"))
             * {
             *      outStr += "<table class='buyTable' style='width: 80%;'>" +
             *                      "<tr><td rowspan='9'><img runat='server' src='" + item.Image + "' /></td>" +
             *                      "<td colspan='2' style='text-align:center'><b>" + item.Category + " " + item.Type + " " + item.Name + "</b></td></tr>" +
             *                      "<tr bgcolor='#eeeeee'><td>Proccessor</td><td>" + des[0] + "</td></tr>" +
             *                      "<tr><td>Video</td><td>Intel® HD Graphics</td></tr>" +
             *                      "<tr bgcolor='#eeeeee'><td>RAM</td><td>" + des[1] + "</td></tr>" +
             *                      "<tr><td>Memory</td><td>" + des[2] + "</td></tr>" +
             *                      "<tr bgcolor='#eeeeee'><td>Disc Drive</td><td>LG SATA 22X SUPER-MULTI DVD Burner</td></tr>" +
             *                      "<tr><td>Varranty</td><td>15 Years</td></tr>" +
             *              "</table>";
             * }
             * if (item.Category.Equals("Tablet"))
             * {
             *      outStr += "<table class='buyTable' style='width: 80%;'>" +
             *                      "<tr><td rowspan='9'><img runat='server' src='" + item.Image + "' /></td>" +
             *                      "<td colspan='2' style='text-align:center'><b>" + item.Category + " " + item.Type + " " + item.Name + "</b></td></tr>" +
             *                      "<tr colspan='2'><td>Proccessor</td><td>" + item.Description + "</td></tr>" +
             *              "</table>";
             * }
             *
             * lblChoose.Text = outStr;
             */
        }
Пример #4
0
        // order the product for user
        // function that takes money from client doesn't exist for yet
        // redirect to client orders page
        protected void cmdBuy_Click(object sender, EventArgs e)
        {
            lblOut.Text = LogicClass.BuyItem(ProductID, Convert.ToInt32(Session["id"].ToString()), txtAddress.Text);
            if (lblOut.Text == "")
            {
                Response.Redirect("/Orders.aspx");
            }

            /*
             * // place for fields validation
             * Item item = ConnectionClass.GetProductByID(ProductID);
             * if(item == null){
             *      lblOut.Text = "Cannot buy this product. Please try other one.";
             * }
             * User user = ConnectionClass.GetUserByID(Convert.ToInt32(Session["id"].ToString()));
             * Ordder order = new Ordder(1, user.Id, ProductID, 1, item.Price, DateTime.Now.ToString("d.M.yyyy"), txtAddress.Text);
             * ConnectionClass.AddOrder(order);
             * // function that draws money from client
             * Response.Redirect("/Orders.aspx");
             */
        }
        // check ll fields and if everything is ok store information about new product to database
        protected void cmdSave_Click(object sender, EventArgs e)
        {
            lblResult.Text = LogicClass.AddProduct(drpProductType.SelectedValue.ToString(), drpImage.SelectedValue,
                                                   txtType.Text, txtPrice.Text, txtName.Text, txtDescription.Text, txtQuant.Text);
            ClearAllFields();

            /*
             * if (drpImage.SelectedValue == null || txtType.Text == "" || txtPrice.Text == "" || txtName.Text == "" ||
             *                                                              txtDescription.Text == "" || txtQuant.Text == "")
             * {
             *      lblResult.Text = "One of fields is empty";
             *      return;
             * }
             * string name = txtName.Text;
             * string des = txtDescription.Text;
             * //int price = ConvertToNumber(txtPrice.Text);
             * int price = LogicClass.ConvertToNumber(txtPrice.Text);
             * if (price <= 0)
             * {
             *      lblResult.Text = "Price can't be negative or zero";
             *      return;
             * }
             * string date = DateTime.Now.ToString("d.M.yyyy");
             * string type = txtType.Text;
             * string img = "Images/" + drpImage.SelectedValue;
             * int quant = ConvertToNumber(txtQuant.Text);
             * if(quant < 0)
             * {
             *      lblResult.Text = "Quantity must be zero or more";
             *      return;
             * }
             * string category = drpProductType.SelectedValue.ToString();
             * Item pr = new Item(1, category, name, quant, img, des, date, price, type);
             * ConnectionClass.AddProduct(pr);
             * lblResult.Text = "";
             */
        }