Example #1
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");
            }
        }
Example #2
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");
            }
        }
Example #3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            ProductType productType = productTypeRepo.GetById(ToSQL.SQLToInt(Request.QueryString["ID"]));

            if (productType != null)
            {
                lbMessage.Text   = "";
                productType.Name = txtName.Text;
                productType.DescriptionTemplate = CKEditorControlDescriptionType.Text;
                productType.Note     = txtNote.Text;
                productType.IsActive = ToSQL.SQLToBool(chkActive.Checked);
                int i = productTypeRepo.UpdateProductType(productType);
                Response.Redirect("~/Admincp/Management-ProductType.aspx");
            }
            else
            {
                Response.Redirect("~/Admincp/Management-ProductType.aspx");
            }
        }
Example #4
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");
            }
        }
Example #5
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");
            }
        }
Example #6
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();
         }
     }
 }
Example #7
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");
            }
        }
Example #8
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");
            }
        }