Ejemplo n.º 1
0
        protected void signup_btn_Click(object sender, EventArgs e)
        {
            ElectroDBEntities db      = new ElectroDBEntities();
            customer          newCust = new customer();

            newCust.f_name = f_name.Text;
            newCust.l_name = l_name.Text;
            newCust.gender = gender.SelectedItem.Text;
            if (cust_type.SelectedItem.Text == "Seller")
            {
                newCust.is_seller = true;
            }
            else
            {
                newCust.is_seller = false;
            }
            newCust.username = username.Text;
            newCust.pass     = pass.Text;
            if (p_img.PostedFile != null)
            {
                byte[] bytes;
                using (BinaryReader br = new BinaryReader(p_img.PostedFile.InputStream))
                {
                    bytes = br.ReadBytes(p_img.PostedFile.ContentLength);
                }

                newCust.cust_img = bytes;

                db.customers.Add(newCust);
                db.SaveChanges();
                creation_alert.Attributes.Remove("hidden");
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int returnId = Convert.ToInt16(Session["userID"].ToString());

            // Entity object
            ElectroDBEntities db             = new ElectroDBEntities();
            functions         user_functions = new functions();
            var review = from c in db.customers where c.cust_ID == returnId select c;

            var userss = review.FirstOrDefault();

            if (userss.cust_img != null)
            {
                Image1.ImageUrl = user_functions.image_retrive(userss.cust_ID);
            }
            user_id_label.Text  = userss.cust_ID.ToString();
            username_label.Text = userss.username;
            fullName_label.Text = userss.f_name + " " + userss.l_name;
            DB_label.Text       = userss.b_date.ToString();
            email_label.Text    = userss.gender;
            if (userss.is_seller == true)
            {
                customer_type.Text = "Seller";
            }
            if (userss.is_seller == false)
            {
                customer_type.Text = "Buyer";
            }
        }
Ejemplo n.º 3
0
        public void add_product_btn_Click1(object sender, EventArgs e)
        {
            string            userName = Session["userName"].ToString();
            int               sID      = Convert.ToInt16(Session["userID"].ToString());
            ElectroDBEntities db2      = new ElectroDBEntities();
            product           newitem  = new product();

            newitem.p_ID      = 100;
            newitem.p_name    = p_name.Text;
            newitem.p_cat     = p_category.SelectedItem.Text;
            newitem.p_price   = Convert.ToInt16(p_price.Text);
            newitem.seller_ID = sID;
            newitem.p_desc    = p_desc.InnerText;
            newitem.is_solled = false;


            if (imageUploader.PostedFile != null)
            {
                byte[] bytes;
                using (BinaryReader br = new BinaryReader(imageUploader.PostedFile.InputStream))
                {
                    bytes = br.ReadBytes(imageUploader.PostedFile.ContentLength);
                }

                newitem.p_img = bytes;
            }

            if (newitem != null)
            {
                db2.products.Add(newitem);
                db2.SaveChanges();
                Response.Redirect("sellerPage.aspx");
            }
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ElectroDBEntities db  = new ElectroDBEntities();
            functions         fun = new functions();
            int buyerid           = Convert.ToInt16(Session["userID"].ToString());
            var shippings         = db.shipping_card;

            foreach (var shipping in shippings)
            {
                if (shipping.buyer_ID == buyerid)
                {
                    call_shippings(shipping.p_ID, shipping.ID);
                }
            }
        }
Ejemplo n.º 5
0
        protected void username_btn_Click(object sender, EventArgs e)
        {
            LinkButton button   = (LinkButton)sender;
            string     buttonId = button.ID;
            string     ll       = button.ID;
            int        length   = ll.IndexOf("=");

            ElectroDBEntities db = new ElectroDBEntities();
            int rating_id        = Convert.ToInt16(button.ID.Substring(0, length));
            var review           = from c in db.customers where c.cust_ID == rating_id select c;

            var userss = review.FirstOrDefault();

            Session["userID"] = userss.cust_ID;
            HttpContext.Current.Response.Redirect("customer_acc.aspx");
        }
Ejemplo n.º 6
0
        protected void deleteBtn_Click(object sender, EventArgs e, int shid)
        {
            LinkButton button   = (LinkButton)sender;
            string     buttonId = button.ID;
            string     ll       = button.ID;
            int        length   = ll.IndexOf("=");

            ElectroDBEntities db = new ElectroDBEntities();
            int rating_id        = Convert.ToInt16(button.ID.Substring(0, length));
            var review           = from c in db.shipping_card where c.ID == rating_id select c;

            var userss = review.FirstOrDefault();

            db.shipping_card.Remove(userss);
            db.SaveChanges();
            HttpContext.Current.Response.Redirect("shippingCart.aspx");
        }
Ejemplo n.º 7
0
        public string image_retrive(int userid)
        {
            var myEntity = new ElectroDBEntities();

            var query = myEntity.customers.Where(p => p.cust_ID == userid)
                        .Select(p => p.cust_img).FirstOrDefault();

            if (query != null)
            {
                byte[] bytes        = query;
                string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);



                return("data:image/png;base64," + base64String);
            }
            else
            {
                return("item_logo.png");
            }
        }
Ejemplo n.º 8
0
        public string itemImage_retrive(int itemid)
        {
            var myEntity = new ElectroDBEntities();

            var query = myEntity.products.Where(p => p.p_ID == itemid)
                        .Select(p => p.p_img).FirstOrDefault();

            if (query != null)
            {
                byte[] bytes        = query;
                string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);



                return("data:image/png;base64," + base64String);
            }
            else
            {
                return("s20.jpg");
            }
        }
Ejemplo n.º 9
0
        public int login(customer user)
        {
            ElectroDBEntities db = new ElectroDBEntities();
            var myUser           = db.customers.FirstOrDefault(u => u.username == user.username && u.pass == user.pass);
            var user2            = from u in db.customers
                                   where u.username == user.username
                                   select u;
            var user3 = user2.FirstOrDefault <customer>();

            if (myUser != null && myUser.is_seller == false)    //User was found
            {
                string name = user.username;;
                Session["name"] = name;
                string userName = name;
                Session["userName"] = userName;
                string full_name = user3.f_name + "  " + user3.l_name;
                Session["full_name"] = full_name;
                Session["userID"]    = user3.cust_ID;
                Session["edit_user"] = user3;
                return(1);
            }
            else if (myUser != null && myUser.is_seller == true)   //User was not found
            {
                string name = user.username;;
                Session["name"] = name;
                string userName = name;
                Session["userName"] = userName;
                string full_name = user3.f_name + "  " + user3.l_name;
                Session["full_name"] = full_name;
                Session["userID"]    = user3.cust_ID;
                Session["edit_user"] = user3;
                return(2);
            }
            else
            {
                return(0);
            }
        }
Ejemplo n.º 10
0
        protected void orderBtn_Click(object sender, EventArgs e)
        {
            Button button = (Button)sender;

            string            buttonId = button.ID;
            ElectroDBEntities db       = new ElectroDBEntities();
            int rating_id = Convert.ToInt16(buttonId);
            var review    = from c in db.products where c.p_ID == rating_id select c;

            var userss = review.FirstOrDefault();

            Session["sellerID"] = userss.seller_ID;
            shipping_card shipping = new shipping_card();
            int           buyerID  = Convert.ToInt16(Session["buyerID"].ToString());
            int           sellerID = Convert.ToInt16(Session["sellerID"].ToString());

            shipping.buyer_ID    = buyerID;
            shipping.seller_ID   = sellerID;
            shipping.p_ID        = rating_id;
            shipping.is_approved = false;
            db.shipping_card.Add(shipping);
            db.SaveChanges();
        }
Ejemplo n.º 11
0
        public bool search_product(HtmlGenericControl p_box, TextBox search_box)
        {
            p_box.Controls.Clear();

            ElectroDBEntities db = new ElectroDBEntities();
            var products         = db.products;

            foreach (var product in products)
            {
                if ((search_box.Text != null) && (search_box.Text.Contains(product.p_name) || search_box.Text.Contains(product.p_cat)))
                {
                    HtmlGenericControl colSm = new HtmlGenericControl("div");
                    colSm.Attributes["class"] = "col-sm-3";

                    HtmlGenericControl figure = new HtmlGenericControl("figure");
                    figure.Attributes["class"] = "card card-product";

                    HtmlGenericControl wrap = new HtmlGenericControl("div");
                    wrap.Attributes["class"] = "img-wrap";

                    HtmlGenericControl image = new HtmlGenericControl("img");
                    image.Style.Add(HtmlTextWriterStyle.Width, "70%");
                    image.Style.Add(HtmlTextWriterStyle.Height, "40%");
                    image.Attributes["src"] = itemImage_retrive(product.p_ID);

                    HtmlGenericControl fig = new HtmlGenericControl("figcaption");
                    fig.Attributes["class"] = "info-wrap";

                    HtmlGenericControl h4 = new HtmlGenericControl("h4");
                    h4.Attributes["class"] = "title";
                    h4.InnerText           = product.p_name;



                    HtmlGenericControl h3 = new HtmlGenericControl("h3");
                    h3.Attributes["class"] = "title";
                    h3.InnerText           = product.p_cat;

                    HtmlGenericControl p = new HtmlGenericControl("p");
                    p.Attributes["class"] = "desc";
                    p.InnerText           = product.p_desc;

                    HtmlGenericControl bottomWrap = new HtmlGenericControl("div");
                    bottomWrap.Attributes["class"] = "bottom-wrap";

                    Button orderBtn = new Button();
                    orderBtn.ID       = product.p_ID.ToString();
                    orderBtn.CssClass = "btn btn-info btn-sm float-right";
                    orderBtn.Text     = "Order Now";
                    orderBtn.Click   += delegate(object sender, EventArgs e) { orderBtn_Click(sender, e); };

                    LinkButton h5 = new LinkButton();
                    h5.ID       = product.seller_ID.ToString() + "=" + product.p_ID.ToString();
                    h5.CssClass = "title";
                    h5.Text     = "Posted By: " + product.customer.username;
                    h5.Click   += delegate(object sender, EventArgs e) { username_btn_Click(sender, e); };

                    HtmlGenericControl bottom = new HtmlGenericControl("div");
                    bottom.Attributes["class"] = "price-wrap h5";
                    bottom.InnerText           = product.p_price.ToString() + "$";


                    wrap.Controls.Add(image);
                    figure.Controls.Add(wrap);
                    fig.Controls.Add(h5);
                    fig.Controls.Add(h4);
                    fig.Controls.Add(h3);
                    fig.Controls.Add(p);
                    figure.Controls.Add(fig);

                    bottomWrap.Controls.Add(bottom);
                    bottomWrap.Controls.Add(orderBtn);
                    figure.Controls.Add(bottomWrap);


                    colSm.Controls.Add(figure);

                    p_box.Controls.Add(colSm);
                }
            }
            return(false);
        }
Ejemplo n.º 12
0
        public void call_seller_products(HtmlGenericControl p_box)
        {
            ElectroDBEntities db = new ElectroDBEntities();
            var products         = db.products;

            foreach (var product in products)
            {
                int id = Convert.ToInt16(Session["userID"].ToString());
                if (product.seller_ID == id)
                {
                    HtmlGenericControl colSm = new HtmlGenericControl("div");
                    colSm.Attributes["class"] = "col-sm-3";

                    HtmlGenericControl figure = new HtmlGenericControl("figure");
                    figure.Attributes["class"] = "card card-product";

                    HtmlGenericControl wrap = new HtmlGenericControl("div");
                    wrap.Attributes["class"] = "img-wrap";

                    HtmlGenericControl image = new HtmlGenericControl("img");
                    image.Style.Add(HtmlTextWriterStyle.Width, "70%");
                    image.Style.Add(HtmlTextWriterStyle.Height, "40%");
                    image.Attributes["src"] = itemImage_retrive(product.p_ID);

                    HtmlGenericControl fig = new HtmlGenericControl("figcaption");
                    fig.Attributes["class"] = "info-wrap";

                    HtmlGenericControl h4 = new HtmlGenericControl("h4");
                    h4.Attributes["class"] = "title";
                    h4.InnerText           = product.p_name;

                    HtmlGenericControl h5 = new HtmlGenericControl("h5");
                    h5.Attributes["class"] = "title";
                    h5.InnerText           = "Posted By: " + product.customer.username;

                    HtmlGenericControl h3 = new HtmlGenericControl("h3");
                    h3.Attributes["class"] = "title";
                    h3.InnerText           = product.p_cat;

                    HtmlGenericControl p = new HtmlGenericControl("p");
                    p.Attributes["class"] = "desc";
                    p.InnerText           = product.p_desc;

                    HtmlGenericControl bottomWrap = new HtmlGenericControl("div");
                    bottomWrap.Attributes["class"] = "bottom-wrap";

                    Button orderBtn = new Button();
                    orderBtn.ID       = product.p_ID.ToString();
                    orderBtn.CssClass = "btn btn - sm btn - primary float-right";
                    orderBtn.Text     = "Order Now";

                    HtmlGenericControl bottom = new HtmlGenericControl("div");
                    bottom.Attributes["class"] = "price-wrap h5";
                    bottom.InnerText           = product.p_price.ToString() + "$";

                    HtmlGenericControl status = new HtmlGenericControl("div");
                    status.Attributes["class"] = "price-wrap h5";


                    if (product.is_solled == true)
                    {
                        status.Style.Add(HtmlTextWriterStyle.Color, "red");
                        status.InnerText = "Solled";
                    }
                    if (product.is_solled == false)
                    {
                        status.Style.Add(HtmlTextWriterStyle.Color, "blue");
                        status.InnerText = "Available";
                    }



                    wrap.Controls.Add(image);
                    figure.Controls.Add(wrap);
                    fig.Controls.Add(h5);
                    fig.Controls.Add(h4);
                    fig.Controls.Add(h3);
                    fig.Controls.Add(p);
                    figure.Controls.Add(fig);

                    bottomWrap.Controls.Add(bottom);
                    bottomWrap.Controls.Add(status);
                    // bottomWrap.Controls.Add(orderBtn);
                    figure.Controls.Add(bottomWrap);


                    colSm.Controls.Add(figure);
                    p_box.Controls.Add(colSm);
                }
            }
        }
Ejemplo n.º 13
0
        public void call_shippings(int id, int shID)
        {
            ElectroDBEntities db  = new ElectroDBEntities();
            functions         fun = new functions();
            var products          = db.products;

            foreach (var product in products)
            {
                if (product.p_ID == id)
                {
                    TextBox input = new TextBox();

                    total_price += product.p_price;
                    TableRow  tr = new TableRow();
                    TableCell th = new TableCell();


                    HtmlGenericControl row = new HtmlGenericControl("div");
                    row.Attributes["class"] = "row";

                    HtmlGenericControl colsm2 = new HtmlGenericControl("div");
                    colsm2.Attributes["class"] = "col-sm-2 hidden-xs";

                    HtmlGenericControl img = new HtmlGenericControl("img");
                    img.Style.Add(HtmlTextWriterStyle.Width, "100px");
                    img.Style.Add(HtmlTextWriterStyle.Height, "80px");
                    img.Attributes["class"] = "img-responsive";
                    img.Attributes["src"]   = fun.itemImage_retrive(product.p_ID);

                    HtmlGenericControl colsm10 = new HtmlGenericControl("div");
                    colsm10.Attributes["class"] = "col-sm-10";

                    HtmlGenericControl h4 = new HtmlGenericControl("h4");
                    h4.Attributes["class"] = "nomargin";
                    h4.InnerText           = product.p_name;

                    HtmlGenericControl p = new HtmlGenericControl("p");
                    p.InnerText = product.p_desc;
                    //////////////////////////////////////////////////////
                    TableCell td = new TableCell();
                    td.Attributes["data-th"] = "Price";
                    td.Text = product.p_price.ToString();


                    TableCell td2 = new TableCell();
                    td2.Attributes["data-th"] = "Quantity";



                    input.Attributes["class"] = "form-control text-center";


                    input.Text = textQ;

                    TableCell td3 = new TableCell();
                    td3.Attributes["data-th"] = "Subtotal";
                    td3.Attributes["class"]   = "text-center";

                    TableCell td4 = new TableCell();
                    td4.Attributes["class"] = "actions";



                    LinkButton delete = new LinkButton();
                    delete.CssClass = "btn btn-danger btn-sm";
                    delete.ID       = shID.ToString() + "=sh";
                    delete.Click   += delegate(object sender, EventArgs e) { deleteBtn_Click(sender, e, shID); };

                    LinkButton refresh = new LinkButton();
                    refresh.CssClass = "btn btn-danger btn-sm";
                    refresh.ID       = shID.ToString() + "=sh1";
                    refresh.Click   += delegate(object sender, EventArgs e) { refreshBtn_Click(sender, e, input, td3, td); };

                    HtmlGenericControl i1 = new HtmlGenericControl("i");
                    i1.Attributes["class"] = "fa fa-refresh";

                    HtmlGenericControl i2 = new HtmlGenericControl("i");
                    i2.Attributes["class"]   = "fa fa-trash-o";
                    th.Attributes["data-th"] = "Product";


                    colsm2.Controls.Add(img);

                    colsm10.Controls.Add(h4);
                    colsm10.Controls.Add(p);
                    td2.Controls.Add(input);

                    delete.Controls.Add(i2);
                    refresh.Controls.Add(i1);
                    td4.Controls.Add(refresh);
                    td4.Controls.Add(delete);
                    row.Controls.Add(colsm2);
                    row.Controls.Add(colsm10);
                    tr.Controls.Add(th);
                    tr.Controls.Add(td);
                    tr.Controls.Add(td2);
                    tr.Controls.Add(td3);
                    tr.Controls.Add(td4);
                    tr.ID = shID.ToString();
                    th.Controls.Add(row);
                    table_body.Controls.Add(tr);
                }
            }
        }