Exemplo n.º 1
0
        private void LoadView()
        {
            SupplierUI supplier = SupplierController.GetSupplierUIForSupplierProfile(SuppliersSessionHelper.SupplierId());

            txtbusiness.Text       = supplier.BusinessName;
            txtbusiness.ToolTip    = supplier.BusinessName;
            txtContactName.Text    = supplier.ContactName;
            txtContactName.ToolTip = supplier.ContactName;
            txtContactPhone.Text   = supplier.ContactPhone;
            txtEmail.Text          = supplier.Email;
            txtNumber.Text         = supplier.HouseNum;
            txtStreet.Text         = supplier.Street;
            txtStreet.ToolTip      = supplier.Street;
            //City c = City.FetchByID(supplier.CityId);
            txtCity.Text      = supplier.CityName;
            txtCity.ToolTip   = supplier.CityName;
            txtPhone.Text     = supplier.Phone;
            lvCity.DataSource = supplier.citiesSupplied;
            lvCity.DataBind();
            lvHomeCity.DataSource = supplier.citiesHomeService;
            lvHomeCity.DataBind();
            showHideServiceFields(supplier.IsService);
            if (supplier.IsService)
            {
                txtDescription.Text = supplier.Description;
                txtDiscount.Text    = supplier.Discount;
                string ImageFile = "";
                ImageFile = Snoopi.core.MediaUtility.GetImagePath("Supplier", supplier.ProfileImage, 0, 225, 225);
                if (ImageFile.ToLower().Contains(".jpg") || ImageFile.ToLower().Contains(".jpeg") || ImageFile.ToLower().Contains(".png"))
                {
                    imgImage.ImageUrl = ImageFile;
                }
            }
        }
Exemplo n.º 2
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }
            Membership.UserAuthenticateResults results = SuppliersSessionHelper.Login(txtEmail.Text.Trim(), txtPassword.Text, false);
            switch (results)
            {
            case Membership.UserAuthenticateResults.Success:
            {
                string ReturnUrl = Request.QueryString[@"ReturnUrl"] ?? "";
                ReturnUrl = ReturnUrl.Trim();
                if (ReturnUrl.Length == 0 || !Http.IsLocalUrl(ReturnUrl))
                {
                    ReturnUrl = @"/";
                }
                Response.Redirect(ReturnUrl, true);
            }
            break;

            default:
            case Membership.UserAuthenticateResults.NoMatch:
            case Membership.UserAuthenticateResults.LoginError:
                Master.MessageCenter.DisplayErrorMessage(LoginPageStrings.GetText(@"ErrorGeneral"));
                break;

            case Membership.UserAuthenticateResults.Locked:
                Master.MessageCenter.DisplayErrorMessage(LoginPageStrings.GetText(@"ErrorLocked"));
                break;
            }
        }
Exemplo n.º 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (SuppliersSessionHelper.IsAuthenticated())
         {
             Response.Redirect(@"/", true);
         }
     }
 }
Exemplo n.º 4
0
        private void LoadView()
        {
            SupplierUI supplier = SupplierController.GetSupplierUIForSupplierProfile(SuppliersSessionHelper.SupplierId());

            txtbusiness.Text     = supplier.BusinessName;
            txtContactName.Text  = supplier.ContactName;
            txtContactPhone.Text = supplier.ContactPhone;
            txtEmail.Text        = supplier.Email;
            txtEmail.Enabled     = false;
            txtNumber.Text       = supplier.HouseNum;
            txtStreet.Text       = supplier.Street;

            ddlCity.DataSource = CityCollection.FetchAll();
            ddlCity.DataBind();
            if (supplier.CityId != 0)
            {
                ddlCity.SelectedValue = supplier.CityId.ToString();
            }
            txtPhone.Text = supplier.Phone;

            rptCity.DataSource = CityController.GetAllCityUIBy(SuppliersSessionHelper.SupplierId(), false);
            rptCity.DataBind();


            rptHomeCity.DataSource = CityController.GetAllCityUIBy(SuppliersSessionHelper.SupplierId(), true);
            rptHomeCity.DataBind();

            showHideServiceFields(supplier.IsService);
            if (supplier.IsService)
            {
                txtDescription.Text = supplier.Description;
                txtDiscount.Text    = supplier.Discount;
                string ImageFile = "";
                ImageFile = Snoopi.core.MediaUtility.GetImagePath("Supplier", supplier.ProfileImage, 0, 225, 225);
                if (ImageFile.ToLower().Contains(".jpg") || ImageFile.ToLower().Contains(".jpeg") || ImageFile.ToLower().Contains(".png"))
                {
                    ImageFileHandler(fuImage, imgImage, btnDeleteImage, ImageFile);
                }
            }
            if (supplier.ApprovedTermsDate == null && supplier.IsService)
            {
                IsApprovedTerms.Value = "false";
            }
            else
            {
                IsApprovedTerms.Value = "true";
            }
        }
Exemplo n.º 5
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }
            Int64       SupplierId = SuppliersSessionHelper.SupplierId();
            AppSupplier supplier   = AppSupplier.FetchByID(SupplierId);

            if (supplier.ApprovedTermsDate != null || !supplier.IsService)
            {
                Save(supplier);
            }
            else
            {
                Master.MessageCenter.DisplayErrorMessage(SupplierProfileStrings.GetText(@"ErrorApproveTerms"));
            }
        }
Exemplo n.º 6
0
        protected void btnCities_Click(object sender, EventArgs e)
        {
            Int64 SupplierId = SuppliersSessionHelper.SupplierId();

            SupplierController.DeleteAllSupplierCity(SupplierId);

            foreach (RepeaterItem rItem in rptCity.Items)
            {
                foreach (ListItem item in ((CheckBoxList)rItem.FindControl("cblCities")).Items)
                {
                    if (item.Selected == true)
                    {
                        SupplierCity sc = new SupplierCity();
                        sc.CityId     = Convert.ToInt64(item.Value);
                        sc.SupplierId = SupplierId;
                        sc.Save();
                    }
                }
            }
        }
Exemplo n.º 7
0
 protected void btnTerms_Click(object sender, EventArgs e)
 {
     termsLoader.Visible = true;
     if (!Page.IsValid)
     {
         return;
     }
     if (ApproveTermsCb.Checked)
     {
         Int64       SupplierId = SuppliersSessionHelper.SupplierId();
         AppSupplier supplier   = AppSupplier.FetchByID(SupplierId);
         Save(supplier);
     }
     else
     {
         Response.Redirect("EditMyProfile.aspx");
         Master.MessageCenter.DisplayErrorMessage(SupplierProfileStrings.GetText(@"ErrorApproveTerms"));
     }
     termsLoader.Visible = false;
 }
        private void ReadCSVFile(string filePath)
        {
            using (FileStream fs = new FileStream(filePath, FileMode.Open))
            {
                using (CsvReader csv = new CsvReader(fs))
                {
                    string[] _values = null;

                    CsvDataTable = new DataTable();
                    CsvDataTable.Columns.Add(new DataColumn("Line", typeof(int)));
                    CsvDataTable.Columns.Add(new DataColumn("ProductName", typeof(string)));
                    CsvDataTable.Columns.Add(new DataColumn("ProductCode", typeof(string)));
                    CsvDataTable.Columns.Add(new DataColumn("Amount", typeof(string)));
                    CsvDataTable.Columns.Add(new DataColumn("RecomendedPrice", typeof(string)));
                    CsvDataTable.Columns.Add(new DataColumn("Description", typeof(string)));
                    CsvDataTable.Columns.Add(new DataColumn("AnimalType", typeof(string)));
                    CsvDataTable.Columns.Add(new DataColumn("Price", typeof(string)));
                    //CsvDataTable.Columns.Add(new DataColumn("CategoryId", typeof(string)));
                    //CsvDataTable.Columns.Add(new DataColumn("SubCategoryId", typeof(string)));
                    CsvDataTable.Columns.Add(new DataColumn("Comments", typeof(string)));

                    bool bErrors             = false;
                    int  line                = -1;
                    int  numProductsToImport = 0;
                    _values = csv.ReadRow();
                    while (_values != null)
                    {
                        if (++line == 0)
                        {
                            _values = csv.ReadRow();
                            continue;
                        }

                        DataRow DR       = CsvDataTable.NewRow();
                        string  comments = "";

                        try
                        {
                            DR["Line"]        = line;
                            DR["ProductName"] = _values[0] == "" ? "" : _values[0].Trim();
                            DR["ProductCode"] = _values[1] == "" ? "" : _values[1].Trim();
                            //DR["ProductNum"] = _values[2] == "" ? "" : _values[2].Trim();
                            DR["Amount"]          = _values[2] == "" ? "" : _values[2].Trim();
                            DR["RecomendedPrice"] = _values[3] == "" ? "" : _values[3].Trim();
                            DR["Description"]     = _values[4] == "" ? "" : _values[4].Trim();
                            DR["AnimalType"]      = _values[5] == "" ? "" : _values[5].Trim();
                            DR["Price"]           = _values[6] == "" ? "" : _values[6].Trim();


                            if (DR["ProductCode"] == null || DR["ProductCode"].ToString() == "")
                            {
                                comments = ProductsStrings.GetText(@"MessageProductCodeEmpty");
                            }
                            else
                            {
                                //Code must be unique
                                if (Product.FetchByCode(DR["ProductCode"].ToString()) != null)
                                {
                                    Product prod = Product.FetchByCode(DR["ProductCode"].ToString());
                                    if (SupplierProduct.FetchByID(SuppliersSessionHelper.SupplierId(), prod.ProductId) != null)
                                    {
                                        //Update
                                        if (DR["Price"] == null || DR["Price"].ToString() == "")
                                        {
                                            //delete from SupplierProduct
                                            comments = ProductsStrings.GetText(@"MessageCodeRemoveProductFromSupplier");//MessageCodeRemoveProductFromSupplier
                                            numProductsToImport++;
                                        }
                                        else //Update price

                                        {
                                            comments = ProductsStrings.GetText(@"MessageCodeUppdatePriceInSupplier");
                                            numProductsToImport++;
                                        }
                                    }
                                    else
                                    {
                                        //insert
                                        if (DR["Price"] == null || DR["Price"].ToString() == "")
                                        {
                                            //if (comments != "") comments += "<br />";
                                            comments = ProductsStrings.GetText(@"MessageCodeNotInsertProductToSupplierMissingPrice");
                                        }
                                        else
                                        {
                                            comments = ProductsStrings.GetText(@"MessageCodeInsertProductToSupplier");
                                            numProductsToImport++;
                                        }
                                    }
                                }
                            }
                        }

                        catch (Exception e)
                        {
                            comments = ProductsStrings.GetText(@"MessageLineParsingError") + ": " + e.Message;
                        }

                        //if (comments != "")
                        //{
                        //    bErrors = true;
                        //    comments += "<br />" + ProductsStrings.GetText(@"MessageProductsWillNotImported");
                        //}
                        //else
                        //{
                        //    numProductsToImport++;
                        //}

                        DR["Comments"] = comments;
                        CsvDataTable.Rows.Add(DR);

                        _values = csv.ReadRow();
                    }

                    if (bErrors)
                    {
                        lblErrors.Text = ProductsStrings.GetText(@"ImportErrorsLabel");
                    }
                    else
                    {
                        lblErrors.Text = ProductsStrings.GetText(@"ImportNoErrorsLabel");;
                    }

                    dgProducts.DataSource = CsvDataTable;
                    dgProducts.DataBind();
                    lblTotal.Text         = CsvDataTable.Rows.Count.ToString();
                    lblTotalToImport.Text = numProductsToImport.ToString();
                    btnImport.Enabled     = numProductsToImport == 0 ? false : true;
                }
            }
        }
        protected void btnImport_Click(object sender, EventArgs e)
        {
            if (CsvDataTable != null)
            {
                int count = 0;
                try
                {
                    foreach (DataRow productRow in CsvDataTable.Rows)
                    {
                        if (productRow["Comments"].ToString() != "")
                        {
                            SupplierProduct suplierprod = null;
                            Product         prod        = null;
                            if ((productRow["Comments"].ToString()).Equals(ProductsStrings.GetText(@"MessageCodeRemoveProductFromSupplier")))
                            {
                                //Delete product from Supplier
                                prod = Product.FetchByCode(productRow["ProductCode"].ToString());
                                if (prod != null)
                                {
                                    suplierprod = SupplierProduct.FetchByID(SuppliersSessionHelper.SupplierId(), prod.ProductId);
                                    if (suplierprod != null)
                                    //delete
                                    {
                                        SupplierProduct.Delete(SuppliersSessionHelper.SupplierId(), suplierprod.ProductId);
                                        count++;
                                    }
                                }
                            }

                            else if ((productRow["Comments"].ToString()).Equals(ProductsStrings.GetText(@"MessageCodeInsertProductToSupplier")))
                            {
                                //Insert product to supplier
                                prod = Product.FetchByCode(productRow["ProductCode"].ToString());
                                if (prod != null)
                                {
                                    if (!ProductController.IsSupplierProduct(prod.ProductId, SuppliersSessionHelper.SupplierId()))
                                    {
                                        SupplierProduct sp = new SupplierProduct();
                                        sp.SupplierId = SuppliersSessionHelper.SupplierId();
                                        sp.ProductId  = prod.ProductId;
                                        sp.CreateDate = DateTime.UtcNow;
                                        sp.Price      = Convert.ToDecimal(productRow["Price"]);
                                        sp.Gift       = "";
                                        sp.Save();
                                        check_price_deviation(sp);
                                        count++;
                                    }
                                }
                            }
                            else if ((productRow["Comments"].ToString()).Equals(ProductsStrings.GetText(@"MessageCodeUppdatePriceInSupplier")))
                            {
                                //Update price
                                prod = Product.FetchByCode(productRow["ProductCode"].ToString());
                                if (prod != null)
                                {
                                    if (ProductController.IsSupplierProduct(prod.ProductId, SuppliersSessionHelper.SupplierId()))
                                    {
                                        SupplierProduct sp = new SupplierProduct();
                                        sp.SupplierId = SuppliersSessionHelper.SupplierId();
                                        sp.Price      = Convert.ToDecimal(productRow["Price"]);
                                        sp.ProductId  = prod.ProductId;
                                        sp.CreateDate = DateTime.UtcNow;
                                        sp.Gift       = "";
                                        sp.Update();
                                        check_price_deviation(sp);
                                        count++;
                                    }
                                }
                            }
                        }
                    }

                    lblImportResult.Text = ProductsStrings.GetText(@"MessageImportSuccess");
                }
                catch (Exception ex)
                {
                    lblImportResult.Text = ProductsStrings.GetText(@"MessageImportFailedUnknown");
                }

                phImportResult.Visible = true;
                lblTotalImported.Text  = count.ToString();
                btnImport.Enabled      = false;
                //   btnAcceptFile.Visible = false;
                phErrors.Visible       = false;
                phProductsList.Visible = false;
            }
        }