示例#1
0
        protected void rptOrderDetail_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            OrderDetail orderDetail = (OrderDetail)e.Item.DataItem;

            if (orderDetail != null)
            {
                Label lbProductName = (Label)e.Item.FindControl("lbProductName");
                if (lbProductName != null && orderDetail.Product != null)
                {
                    lbProductName.Text = ToSQL.EmptyNull(orderDetail.Product.Name);
                }
                Image imgProduct = (Image)e.Item.FindControl("imgProduct");
                if (imgProduct != null)
                {
                    string image = (new ProductImageRepo()).GetImageDefaultAllByProductId(ToSQL.SQLToInt(orderDetail.Product_ID));
                    if (CheckFileShared.CheckImageExist(image))
                    {
                        imgProduct.ImageUrl = "~/Resources/ImagesProduct/" + image;
                    }
                    else
                    {
                        imgProduct.ImageUrl = "~/Resources/ImagesProduct/no-image.png";
                    }
                }
            }
        }
示例#2
0
        private void LoadManufacturer()
        {
            int Id = ToSQL.SQLToInt(Request.QueryString["Id"]);

            if (Id > 0)
            {
                Manufacturer manufacturer = manufacturerRepo.GetById(Id);
                if (manufacturer != null)
                {
                    txtName.Text      = ToSQL.EmptyNull(manufacturer.Name);
                    txtPhone.Text     = ToSQL.EmptyNull(manufacturer.Phone);
                    txtWebsite.Text   = ToSQL.EmptyNull(manufacturer.Website);
                    txtNote.Text      = ToSQL.EmptyNull(manufacturer.Note);
                    chkActive.Checked = ToSQL.SQLToBool(manufacturer.IsActive);
                    if (manufacturer.Address != null)
                    {
                        txtStreet1.Text = ToSQL.EmptyNull(manufacturer.Address.Street1);
                        txtStreet2.Text = ToSQL.EmptyNull(manufacturer.Address.Street2);
                        txtCity.Text    = ToSQL.EmptyNull(manufacturer.Address.City);
                        txtState.Text   = ToSQL.EmptyNull(manufacturer.Address.State);
                        txtCountry.Text = ToSQL.EmptyNull(manufacturer.Address.Country);
                        txtZipCode.Text = ToSQL.EmptyNull(manufacturer.Address.ZipCode);
                    }
                }
                else
                {
                    Response.Redirect("Management-Manafacturer.aspx");
                }
            }
            else
            {
                Response.Redirect("Management-Manafacturer.aspx");
            }
        }
示例#3
0
 public string SetImage(string s)
 {
     if (CheckFileShared.CheckImageExist(ToSQL.EmptyNull(s)))
     {
         return("Resources/ImagesProduct/" + ToSQL.EmptyNull(s));
     }
     else
     {
         return("Resources/ImagesProduct/no-image.png");
     }
 }
示例#4
0
        protected void btnOrder_Click(object sender, EventArgs e)
        {
            Order order = new Order();

            order.DateCreated    = DateTime.Now;
            order.Note           = ToSQL.EmptyNull(txtNotes.Text);
            order.OrderStatus_ID = 1;
            if (Session["Customer"] != null)
            {
                order.Customer_ID = ((Customer)Session["Customer"]).ID;
            }
            order.ShippingAddress = new ShippingAddress()
            {
                Name    = ToSQL.EmptyNull(txtFullName.Text),
                Email   = ToSQL.EmptyNull(txtEmail.Text),
                Phone   = ToSQL.EmptyNull(txtPhone.Text),
                Address = new Address()
                {
                    Street1 = ToSQL.EmptyNull(txtStreet.Text),
                    City    = ToSQL.EmptyNull(txtCity.Text),
                    State   = ToSQL.EmptyNull(txtState.Text),
                    Country = ToSQL.EmptyNull(txtCountry.Text),
                    ZipCode = ToSQL.EmptyNull(txtZipCode.Text),
                }
            };
            order.Payment_ID = tabContainer.ActiveTabIndex + 1;
            List <Cart>        carts        = (List <Cart>)Session["Carts"];
            List <OrderDetail> orderDetails = new List <OrderDetail>();

            foreach (var item in carts)
            {
                OrderDetail orderDetail = new OrderDetail()
                {
                    Product_ID = item.ProductID,
                    Quantity   = item.Quantity,
                    Price      = item.Price
                };
                orderDetails.Add(orderDetail);
            }
            order.OrderDetails = orderDetails;
            int          i        = new OrderRepo().CreateOrder(order);
            OrderHistory orderHis = new OrderHistory();

            orderHis.Order_ID       = order.ID;
            orderHis.OrderStatus_ID = Const.Pendding;
            orderHis.DateCreated    = DateTime.Now;
            int x = new OrderHistoryRepo().CreateOrderHistory(orderHis);

            Session["Order"]    = order;
            Session["Subtotal"] = lbTotalPrice.Text;
            Session["Carts"]    = null;
            Response.Redirect("OrderComplete.aspx");
        }
示例#5
0
        public string ShortString(object o)
        {
            string s = ToSQL.EmptyNull(o);

            if (s.Length <= 20)
            {
                return(s);
            }
            else
            {
                return(s.Substring(0, 18) + "...");
            }
        }
示例#6
0
        private void LoadCart()
        {
            List <Cart> carts = (List <Cart>)Session["Carts"];
            Cart        cart  = new Cart(carts);

            grvViewCart.DataKeyNames = new string[] { "ProductID" };
            grvViewCart.DataSource   = carts;
            grvViewCart.DataBind();

            cart = new Cart(carts);
            lbTotalQuantity.Text = ToSQL.EmptyNull(cart.TotalQuantity);
            lbTotalPrice.Text    = ToSQL.EmptyNull(cart.TotalPrice.ToString("$#,###.##"));
        }
示例#7
0
        public string GetToString(Address A)
        {
            string s = "";

            if (ToSQL.EmptyNull(A.Street1) != "")
            {
                s += ToSQL.EmptyNull(A.Street1);
            }
            if (ToSQL.EmptyNull(A.Street2) != "")
            {
                if (s != "")
                {
                    s += ", ";
                }
                s += ToSQL.EmptyNull(A.Street2);
            }
            if (ToSQL.EmptyNull(A.City) != "")
            {
                if (s != "")
                {
                    s += ", ";
                }
                s += ToSQL.EmptyNull(A.City);
            }
            if (ToSQL.EmptyNull(A.State) != "")
            {
                if (s != "")
                {
                    s += ", ";
                }
                s += ToSQL.EmptyNull(A.State);
            }
            if (ToSQL.EmptyNull(A.ZipCode) != "")
            {
                if (s != "")
                {
                    s += ", ";
                }
                s += ToSQL.EmptyNull(A.ZipCode);
            }
            if (ToSQL.EmptyNull(A.Country) != "")
            {
                if (s != "")
                {
                    s += ", ";
                }
                s += ToSQL.EmptyNull(A.Country);
            }
            return(s);
        }
示例#8
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            ProductType productType = new ProductType();

            productType.Name                = ToSQL.EmptyNull(txtName.Text);
            productType.Note                = ToSQL.EmptyNull(txtNote.Text);
            productType.IsActive            = true;
            productType.SortId              = 0;
            productType.DateCreated         = DateTime.Now;
            productType.DescriptionTemplate = CKEditorControlDescriptionType.Text;

            int i = productTypeRepo.CreateProductType(productType);

            Response.Redirect("Management-ProductType.aspx");
        }
示例#9
0
        private void LoadProductType()
        {
            ProductType pt = productTypeRepo.GetById(ToSQL.SQLToInt(Request.QueryString["ID"]));

            if (pt != null)
            {
                txtName.Text = ToSQL.EmptyNull(pt.Name);
                txtNote.Text = ToSQL.EmptyNull(pt.Note);
                CKEditorControlDescriptionType.Text = ToSQL.EmptyNull(pt.DescriptionTemplate);
                chkActive.Checked = ToSQL.SQLToBool(pt.IsActive);
            }
            else
            {
                Response.Redirect("~/Admincp/Management-ProductType.aspx");
            }
        }
示例#10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Page.User.Identity.IsAuthenticated == false)
                {
                    Response.Redirect("~/Admincp/Login.aspx");
                }

                User user = new UserRepo().GetUserByUsername(ToSQL.EmptyNull(Page.User.Identity.Name));
                if (user != null && user.LastLogin != null)
                {
                    lbLastlogin.Text = user.LastLogin.Value.ToString("MM-dd-yyyy hh:mm");
                }
            }
        }
示例#11
0
        private void LoadOrder()
        {
            Order order = orderRepo.GetById(ToSQL.SQLToInt(Request.QueryString["ID"]));

            if (order != null)
            {
                lbOrderID.Text = ToSQL.EmptyNull(order.ID);
                if (order.OrderStatu != null)
                {
                    lbOrderStatus.Text = ToSQL.EmptyNull(order.OrderStatu.Name);
                    SetButton(order.OrderStatus_ID);
                }
                lbCreatedDate.Text = ToSQL.EmptyNull(order.DateCreated.ToString("yyyy-MM-dd HH:mm"));
                if (order.Customer != null)
                {
                    lbCustomer.Text = ToSQL.EmptyNull(order.Customer.FirstName + " " + order.Customer.LastName);
                }
                if (order.Payment != null)
                {
                    lbPaymentType.Text = ToSQL.EmptyNull(order.Payment.Name);
                }
                txtNote.Text = ToSQL.EmptyNull(order.Note);
                if (order.ShippingAddress != null)
                {
                    lbName.Text  = ToSQL.EmptyNull(order.ShippingAddress.Name);
                    lbEmail.Text = ToSQL.EmptyNull(order.ShippingAddress.Email);
                    lbPhone.Text = ToSQL.EmptyNull(order.ShippingAddress.Phone);
                    if (order.ShippingAddress.Address != null)
                    {
                        lbAddress.Text = ToSQL.EmptyNull(new AddressRepo().GetToString(order.ShippingAddress.Address));
                    }
                }
                if (order.OrderDetails != null)
                {
                    grvOrderProduct.DataSource = order.OrderDetails;
                    grvOrderProduct.DataBind();
                    lbSubtotal.Text = ToSQL.EmptyNull(order.OrderDetails.Sum(o => o.Quantity * o.Price).ToString("$#,###.00"));
                }
            }
            else
            {
                Response.Redirect("~/Admincp/Management-Order.aspx");
            }
        }
示例#12
0
        protected void rptOrder_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            Order order = (Order)e.Item.DataItem;

            if (order != null)
            {
                Label lbTotalPrice = (Label)e.Item.FindControl("lbTotalPrice");
                if (lbTotalPrice != null)
                {
                    lbTotalPrice.Text = ToSQL.EmptyNull(order.OrderDetails.Sum(o => o.Price * o.Quantity).ToString("$#,###.00"));
                }
                Repeater rptOrderDetail = (Repeater)e.Item.FindControl("rptOrderDetail");
                if (rptOrderDetail != null)
                {
                    rptOrderDetail.DataSource = order.OrderDetails;
                    rptOrderDetail.DataBind();
                }
            }
        }
示例#13
0
 private void LoadCustomer()
 {
     if (Session["Customer"] != null)
     {
         Customer customer = (Customer)Session["Customer"];
         txtFullName.Text = ToSQL.EmptyNull(customer.FirstName) + " " + ToSQL.EmptyNull(customer.LastName);
         txtPhone.Text    = ToSQL.EmptyNull(customer.Phone);
         txtEmail.Text    = ToSQL.EmptyNull(customer.Email);
         if (customer.Address != null)
         {
             Address address = customer.Address;
             txtStreet.Text  = ToSQL.EmptyNull(address.Street1);
             txtCity.Text    = ToSQL.EmptyNull(address.City);
             txtState.Text   = ToSQL.EmptyNull(address.State);
             txtCountry.Text = ToSQL.EmptyNull(address.Country);
             txtZipCode.Text = ToSQL.EmptyNull(address.ZipCode);
         }
     }
 }
示例#14
0
        protected void btnAddress_Click(object sender, EventArgs e)
        {
            Customer customer = (Customer)Session["Customer"];

            customer = customerRepo.GetById(customer.ID);
            if (customer.Address == null)
            {
                customer.Address = new Address();
            }
            customer.Address.Street1 = ToSQL.EmptyNull(txtStreet1.Text);
            customer.Address.Street2 = ToSQL.EmptyNull(txtStreet2.Text);
            customer.Address.City    = ToSQL.EmptyNull(txtCity.Text);
            customer.Address.State   = ToSQL.EmptyNull(txtState.Text);
            customer.Address.Country = ToSQL.EmptyNull(txtCountry.Text);
            customer.Address.ZipCode = ToSQL.EmptyNull(txtZipCode.Text);

            int i = customerRepo.UpdateCustomer(customer);

            Session["Customer"] = customerRepo.GetById(customer.ID);
        }
示例#15
0
        protected void btnCreditCard_Click(object sender, EventArgs e)
        {
            Customer customer = (Customer)Session["Customer"];

            customer = customerRepo.GetById(customer.ID);
            if (customer.CreditCard == null)
            {
                customer.CreditCard             = new CreditCard();
                customer.CreditCard.DateCreated = DateTime.Now;
            }
            customer.CreditCard.CardNumber        = ToSQL.EmptyNull(txtCardNum.Text);
            customer.CreditCard.SecurityCode      = ToSQL.EmptyNull(txtCVCCode.Text);
            customer.CreditCard.ExpirationDate    = ToSQL.SQLToDateTime(drdYear.SelectedValue + "/" + ddlMonth.SelectedValue + "/" + "1");
            customer.CreditCard.CreditCardType_ID = ToSQL.SQLToIntNull(ddlTypeCard.SelectedValue);
            customer.CreditCard.Name = ToSQL.EmptyNull(txtFullName.Text);

            int i = customerRepo.UpdateCustomer(customer);

            Session["Customer"] = customerRepo.GetById(customer.ID);
        }
示例#16
0
        private void LoadCustomer()
        {
            Customer customer = customerRepo.GetById(ToSQL.SQLToInt(Request.QueryString["Id"]));

            if (customer != null)
            {
                lbUsername.Text           = ToSQL.EmptyNull(customer.Username);
                txtFirstName.Text         = ToSQL.EmptyNull(customer.FirstName);
                txtLastName.Text          = ToSQL.EmptyNull(customer.LastName);
                txtEmail.Text             = ToSQL.EmptyNull(customer.Email);
                txtPhone.Text             = ToSQL.EmptyNull(customer.Phone);
                txtDateOfBirth.Text       = ToSQL.SQLToDateTime(customer.DateOfBirth).ToShortDateString();
                rdbtnGender.SelectedIndex = ToSQL.SQLToBool(customer.Gender) ? 0 : 1;
                lbDateCreated.Text        = ToSQL.EmptyNull(customer.DateCreated);
            }
            else
            {
                Response.Redirect("Management-Customer.aspx");
            }
        }
示例#17
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int Id = ToSQL.SQLToInt(Request.QueryString["Id"]);

            if (Id > 0)
            {
                Manufacturer manufacturer = manufacturerRepo.GetById(Id);
                if (manufacturer != null)
                {
                    manufacturer.Name     = ToSQL.EmptyNull(txtName.Text);
                    manufacturer.Phone    = ToSQL.EmptyNull(txtPhone.Text);
                    manufacturer.Website  = ToSQL.EmptyNull(txtWebsite.Text);
                    manufacturer.Note     = ToSQL.EmptyNull(txtNote.Text);
                    manufacturer.IsActive = ToSQL.SQLToBool(chkActive.Checked);

                    if (manufacturer.Address == null)
                    {
                        manufacturer.Address = new Address();
                    }
                    manufacturer.Address.Street1 = ToSQL.EmptyNull(txtStreet1.Text);
                    manufacturer.Address.Street2 = ToSQL.EmptyNull(txtStreet2.Text);
                    manufacturer.Address.City    = ToSQL.EmptyNull(txtCity.Text);
                    manufacturer.Address.State   = ToSQL.EmptyNull(txtState.Text);
                    manufacturer.Address.Country = ToSQL.EmptyNull(txtCountry.Text);
                    manufacturer.Address.ZipCode = ToSQL.EmptyNull(txtZipCode.Text);

                    int i = manufacturerRepo.UpdateManufacturer(manufacturer);

                    Response.Redirect("Management-Manafacturer.aspx");
                }
                else
                {
                    Response.Redirect("Management-Manafacturer.aspx");
                }
            }
            else
            {
                Response.Redirect("Management-Manafacturer.aspx");
            }
        }
示例#18
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Manufacturer manufacturer = new Manufacturer();

            manufacturer.Name     = ToSQL.EmptyNull(txtName.Text);
            manufacturer.Phone    = ToSQL.EmptyNull(txtPhone.Text);
            manufacturer.Website  = ToSQL.EmptyNull(txtWebsite.Text);
            manufacturer.Note     = ToSQL.EmptyNull(txtNote.Text);
            manufacturer.IsActive = true;
            manufacturer.Address  = new Address()
            {
                Street1 = ToSQL.EmptyNull(txtStreet1.Text),
                Street2 = ToSQL.EmptyNull(txtStreet2.Text),
                City    = ToSQL.EmptyNull(txtCity.Text),
                State   = ToSQL.EmptyNull(txtState.Text),
                Country = ToSQL.EmptyNull(txtCountry.Text),
                ZipCode = ToSQL.EmptyNull(txtZipCode.Text)
            };
            int i = new ManufacturerRepo().CreateManufacturer(manufacturer);

            Response.Redirect("Management-Manafacturer.aspx");
        }
示例#19
0
 private void LoadCustomer()
 {
     if (Session["Customer"] != null)
     {
         Customer customer = (Customer)Session["Customer"];
         customer                  = customerRepo.GetById(customer.ID);
         lbUsername.Text           = ToSQL.EmptyNull(customer.Username);
         txtFirstName.Text         = ToSQL.EmptyNull(customer.FirstName);
         txtLastName.Text          = ToSQL.EmptyNull(customer.LastName);
         txtEmail.Text             = ToSQL.EmptyNull(customer.Email);
         txtPhone.Text             = ToSQL.EmptyNull(customer.Phone);
         txtDateOfBirth.Text       = ToSQL.SQLToDateTime(customer.DateOfBirth).ToShortDateString();
         rdbtnGender.SelectedIndex = ToSQL.SQLToBool(customer.Gender) ? 0 : 1;
         lbDateCreated.Text        = ToSQL.EmptyNull(customer.DateCreated);
         if (customer.Address != null)
         {
             txtStreet1.Text = ToSQL.EmptyNull(customer.Address.Street1);
             txtStreet2.Text = ToSQL.EmptyNull(customer.Address.Street2);
             txtCity.Text    = ToSQL.EmptyNull(customer.Address.City);
             txtState.Text   = ToSQL.EmptyNull(customer.Address.State);
             txtCountry.Text = ToSQL.EmptyNull(customer.Address.Country);
             txtZipCode.Text = ToSQL.EmptyNull(customer.Address.ZipCode);
         }
         if (customer.CreditCard != null)
         {
             txtCardNum.Text           = ToSQL.EmptyNull(customer.CreditCard.CardNumber);
             txtCVCCode.Text           = ToSQL.EmptyNull(customer.CreditCard.SecurityCode);
             ddlMonth.SelectedIndex    = ToSQL.SQLToInt(customer.CreditCard.ExpirationDate.Month);
             drdYear.SelectedValue     = ToSQL.EmptyNull(ToSQL.SQLToInt(customer.CreditCard.ExpirationDate.Year));
             ddlTypeCard.SelectedValue = ToSQL.EmptyNull(customer.CreditCard.CreditCardType_ID);
             txtFullName.Text          = ToSQL.EmptyNull(customer.CreditCard.Name);
         }
         if (customer.Orders != null)
         {
             rptOrder.DataSource = customer.Orders.OrderByDescending(o => o.ID);
             rptOrder.DataBind();
         }
     }
 }
示例#20
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["Order"] != null)
     {
         Order order = (Order)Session["Order"];
         if (order.ShippingAddress != null)
         {
             lbFullName.Text        = ToSQL.EmptyNull(order.ShippingAddress.Name);
             lbEmail.Text           = ToSQL.EmptyNull(order.ShippingAddress.Email);
             lbPhone.Text           = ToSQL.EmptyNull(order.ShippingAddress.Phone);
             lbShippingAddress.Text = new AddressRepo().GetToString(order.ShippingAddress.Address);
         }
         lbOrderID.Text     = ToSQL.EmptyNull(order.ID);
         lbDateCreated.Text = ToSQL.EmptyNull(order.DateCreated.ToShortDateString());
         Model.Payment payment = new PaymentRepo().GetById(order.Payment_ID);
         lbPaymentType.Text = ToSQL.EmptyNull(payment.Name);
     }
     if (Session["Subtotal"] != null)
     {
         lbTotalPrice.Text = ToSQL.EmptyNull(Session["Subtotal"]);
     }
 }
示例#21
0
        protected void btnGenaral_Click(object sender, EventArgs e)
        {
            Customer customer = (Customer)Session["Customer"];

            customer             = customerRepo.GetById(customer.ID);
            customer.FirstName   = ToSQL.EmptyNull(txtFirstName.Text);
            customer.LastName    = ToSQL.EmptyNull(txtLastName.Text);
            customer.Email       = ToSQL.EmptyNull(txtEmail.Text);
            customer.Phone       = ToSQL.EmptyNull(txtPhone.Text);
            customer.DateOfBirth = ToSQL.SQLToDateTime(txtDateOfBirth.Text);
            customer.Gender      = rdbtnGender.SelectedIndex == 0 ? true : false;

            int i = customerRepo.UpdateCustomer(customer);

            Session["Customer"] = customerRepo.GetById(customer.ID);
            Response.Redirect(Request.Url.PathAndQuery);
            //using (var context = new B2C_ECEntities())
            //{
            //    context.Customers.Find(customer.ID).LastName = "Phong 1989";
            //    context.SaveChanges();
            //}
        }
示例#22
0
        private void LoadProduct()
        {
            Product p = productRepo.GetById(ToSQL.SQLToInt(Request.QueryString["ID"]));

            if (p != null)
            {
                txtName.Text  = ToSQL.EmptyNull(p.Name);
                txtPrice.Text = ToSQL.EmptyNull(p.Price.ToString("###.##"));
                ddlManufacturer.SelectedValue   = ToSQL.EmptyNull(p.Manufacuturer_ID);
                ddlProductType.SelectedValue    = ToSQL.EmptyNull(p.ProductType_ID);
                CKEditorControlDescription.Text = ToSQL.EmptyNull(p.Description);
                gvImages.DataSource             = p.ProductImages;
                gvImages.DataBind();
                chkNew.Checked         = ToSQL.SQLToBool(p.IsNew);
                chkBestSelling.Checked = ToSQL.SQLToBool(p.IsBestSelling);
                chkSpecial.Checked     = ToSQL.SQLToBool(p.IsSpecial);
                chkActive.Checked      = ToSQL.SQLToBool(p.IsActive);
            }
            else
            {
                Response.Redirect("~/Admincp/Management-Products.aspx");
            }
        }
        private void BindItemsList()
        {
            List <ProductType> users = productTypeRepo.GetManagementProductTypes(ToSQL.EmptyNull(txtName.Text));

            _PageDataSource.DataSource       = users;
            _PageDataSource.AllowPaging      = true;
            _PageDataSource.PageSize         = 10;
            _PageDataSource.CurrentPageIndex = CurrentPage;
            ViewState["TotalPages"]          = _PageDataSource.PageCount;

            //this.lblPageInfo.Text = "Results: " + ProductList.Count.ToString() + "&nbsp;&nbsp;&nbsp;&nbsp;Page " + (CurrentPage + 1) + " of " + _PageDataSource.PageCount + "&nbsp;&nbsp;";

            this.btnPre.Visible  = !_PageDataSource.IsFirstPage;
            this.btnNext.Visible = !_PageDataSource.IsLastPage;
            //this.lbtnFirst.Visible = !_PageDataSource.IsFirstPage;
            //this.lbtnLast.Visible = !_PageDataSource.IsLastPage;

            this.gvProductType.DataSource = _PageDataSource;
            this.gvProductType.DataBind();
            this.gvProductType.UseAccessibleHeader    = true;
            this.gvProductType.HeaderRow.TableSection = TableRowSection.TableHeader;
            this.doPaging();
        }
示例#24
0
        private void BindItemsList()
        {
            List <Product> products = productRepo.GetManagementProducts(ToSQL.EmptyNull(txtName.Text), ToSQL.SQLToInt(ddlProductType.SelectedValue), ToSQL.SQLToInt(ddlManufacturer.SelectedValue));

            //_PageDataSource.DataSource = users;
            //_PageDataSource.AllowPaging = true;
            //_PageDataSource.PageSize = 20;
            //_PageDataSource.CurrentPageIndex = CurrentPage;
            //ViewState["TotalPages"] = _PageDataSource.PageCount;

            ////////this.lblPageInfo.Text = "Results: " + ProductList.Count.ToString() + "&nbsp;&nbsp;&nbsp;&nbsp;Page " + (CurrentPage + 1) + " of " + _PageDataSource.PageCount + "&nbsp;&nbsp;";

            //this.btnPre.Visible = !_PageDataSource.IsFirstPage;
            //this.btnNext.Visible = !_PageDataSource.IsLastPage;
            //////////this.lbtnFirst.Visible = !_PageDataSource.IsFirstPage;
            //////////this.lbtnLast.Visible = !_PageDataSource.IsLastPage;

            this.gvProducts.DataSource = products;
            this.gvProducts.DataBind();
            this.gvProducts.UseAccessibleHeader    = true;
            this.gvProducts.HeaderRow.TableSection = TableRowSection.TableHeader;
            //this.doPaging();
        }
示例#25
0
        protected void btnBack_Click(object sender, EventArgs e)
        {
            string url = (string.IsNullOrEmpty(ToSQL.EmptyNull(Session["ReferPage"]))) ? "index.aspx" : ToSQL.EmptyNull(Session["ReferPage"]);

            Response.Redirect(url);
        }
示例#26
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Product p = productRepo.GetById(ToSQL.SQLToInt(Request.QueryString["ID"]));

            if (p != null)
            {
                p.Name = ToSQL.EmptyNull(txtName.Text);
                decimal priceOld = p.Price;
                p.Price            = ToSQL.SQLToDecimal(txtPrice.Text);
                p.ProductType_ID   = ToSQL.SQLToIntNull(ddlProductType.SelectedValue);
                p.Manufacuturer_ID = ToSQL.SQLToIntNull(ddlManufacturer.SelectedValue);
                p.Description      = CKEditorControlDescription.Text;
                p.IsActive         = ToSQL.SQLToBool(chkActive.Checked);
                p.IsBestSelling    = ToSQL.SQLToBool(chkBestSelling.Checked);
                p.IsNew            = ToSQL.SQLToBool(chkNew.Checked);
                p.IsSpecial        = ToSQL.SQLToBool(chkSpecial.Checked);
                if (fulImageDefault.HasFile)
                {
                    ProductImage image = new ProductImage();
                    string       url   = CheckFileShared.UploadAndRsizeImage(fulImageDefault.PostedFile);
                    if (url != "")
                    {
                        var pi = p.ProductImages.FirstOrDefault(u => u.IsDefault.Value == true); if (pi != null)
                        {
                            pi.IsDefault = false;
                        }
                        image.Image     = url;
                        image.IsDefault = true;
                        p.ProductImages.Add(image);
                    }
                }

                foreach (HttpPostedFile uploadedFile in FileUploadJquery.PostedFiles)
                {
                    ProductImage image = new ProductImage();
                    string       url   = CheckFileShared.UploadAndRsizeImage(uploadedFile);
                    if (url != "")
                    {
                        image.Image     = url;
                        image.IsDefault = false;
                        p.ProductImages.Add(image);
                    }
                }
                if (productRepo.UpdateProduct(p) > 0)
                {
                    if (priceOld != p.Price)
                    {
                        ProductPriceHistory productPriceHistory = new ProductPriceHistory();
                        productPriceHistory.Product_ID  = p.ID;
                        productPriceHistory.Price       = p.Price;
                        productPriceHistory.DateCreated = DateTime.Now;
                        new ProductPriceHistoryRepo().CreateProductPriceHistory(productPriceHistory);
                    }
                    Response.Redirect("~/Admincp/Management-Products.aspx");
                }
                else
                {
                    lbMessage.Text = "Please check input data! Try again!";
                }
            }
            else
            {
                Response.Redirect("Management-Products.aspx");
            }
        }
示例#27
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     Model.User user = userRepo.GetById(ToSQL.SQLToInt(Request.QueryString["ID"]));
     if (user != null)
     {
         lbMessage.Text = "";
         if (userRepo.DoesEmailExist(txtEmail.Text) && !user.Email.ToLower().Equals(txtEmail.Text.ToLower()) && ToSQL.EmptyNull(txtEmail.Text) != "")
         {
             lbMessage.Text    = "Email already exists!";
             lbMessage.Visible = true;
             return;
         }
     }
     user.FirstName = txtFirstName.Text;
     user.LastName  = txtLastName.Text;
     user.Phone     = txtPhone.Text;
     user.Email     = txtEmail.Text;
     if (user.Address == null)
     {
         user.Address = new Address();
     }
     user.Address.Street1 = txtStreet1.Text;
     user.Address.Street2 = txtStreet2.Text;
     user.Address.City    = txtCity.Text;
     user.Address.State   = txtState.Text;
     user.Address.Country = txtCountry.Text;
     user.Address.ZipCode = txtZipCode.Text;
     if (userRepo.UpdateUser(user) > 0)
     {
         Response.Redirect("~/Admincp/Management-User.aspx");
     }
     else
     {
         lbMessage.Text = "Please check input data! Try again!";
     }
 }
示例#28
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Customer customer = customerRepo.GetById(ToSQL.SQLToInt(Request.QueryString["Id"]));

            if (customer != null)
            {
                lbMessage.Text = "";
                if (customerRepo.DoesEmailExist(txtEmail.Text) && !customer.Email.ToLower().Equals(txtEmail.Text.ToLower()) && ToSQL.EmptyNull(txtEmail.Text) != "")
                {
                    lbMessage.Text      = "Email already exists!";
                    lbMessage.ForeColor = System.Drawing.Color.Red;
                    txtEmail.Text       = "";
                    return;
                }

                customer.FirstName   = txtFirstName.Text;
                customer.LastName    = txtLastName.Text;
                customer.Email       = txtEmail.Text;
                customer.Phone       = txtPhone.Text;
                customer.DateOfBirth = ToSQL.SQLToDateTimeNull(txtDateOfBirth.Text);
                customer.Gender      = rdbtnGender.SelectedIndex == 0 ? true : false;
                int i = customerRepo.UpdateCustomer(customer);
                Response.Redirect("Management-Customer.aspx");
            }
            else
            {
                Response.Redirect("Management-Customer.aspx");
            }
        }
示例#29
0
 private void LoadSearch()
 {
     rptProducts.DataSource = (new ProductRepo()).GetListBySearch(ToSQL.EmptyNull(Request.QueryString["key"]));
     rptProducts.DataBind();
 }
示例#30
0
        public static string ShortString(object o)
        {
            string s = ToSQL.EmptyNull(o);

            return(ShortString(s));
        }