示例#1
0
 public void AddButton(string buttonClass, string buttonText, string href, string[] allowedPermissions)
 {
     if (allowedPermissions.Length == 0 || Permissions.UserHasAnyPermissionIn(SuppliersSessionHelper.SupplierId(), allowedPermissions))
     {
         AddButton(buttonClass, buttonText, href);
     }
 }
示例#2
0
    protected void btnExport_Click(object sender, EventArgs e)
    {
        System.Data.DataTable dt = new System.Data.DataTable();

        dt.Columns.Add(new System.Data.DataColumn(SupplierProfileStrings.GetText(@"OrderId"), typeof(string)));
        dt.Columns.Add(new System.Data.DataColumn(SupplierProfileStrings.GetText(@"OrderDate"), typeof(string)));
        dt.Columns.Add(new System.Data.DataColumn(SupplierProfileStrings.GetText(@"BidId"), typeof(string)));
        dt.Columns.Add(new System.Data.DataColumn(SupplierProfileStrings.GetText(@"TotalPrice"), typeof(string)));
        dt.Columns.Add(new System.Data.DataColumn(SupplierProfileStrings.GetText(@"ApprovedDeal"), typeof(string)));
        dt.Columns.Add(new System.Data.DataColumn(SupplierProfileStrings.GetText(@"DealDetails"), typeof(string)));


        int      year  = Convert.ToInt32(ddlyear.SelectedValue);
        int      month = Convert.ToInt32(ddlMonth.SelectedValue);
        int      from  = Convert.ToInt32(ddlDayFrom.SelectedValue);
        int      to    = Convert.ToInt32(ddlDayTo.SelectedValue);
        DateTime?start = null;
        DateTime?end   = null;

        if (year != 0 && month != 0 && from != 0)
        {
            start = new DateTime(year, month, from); end = (to != 0 ? new DateTime(year, month, to) : end = new DateTime(year, month, DateTime.DaysInMonth(year, month)));
        }
        else if (year != 0 && month != 0)
        {
            start = new DateTime(year, month, 1); end = new DateTime(year, month, DateTime.DaysInMonth(year, month));
        }
        else if (year != 0)
        {
            start = new DateTime(year, 1, 1); end = new DateTime(year, 12, 31);
        }
        List <OrderUI> orders = OrderController.GetOrderSupplierHistoryExcel(SuppliersSessionHelper.SupplierId(), start, end);

        foreach (OrderUI order in orders)
        {
            int i = 0;
            System.Data.DataRow row = dt.NewRow();
            row[i++] = order.OrderId;
            row[i++] = order.OrderDate;
            row[i++] = order.BidId;
            row[i++] = order.Price;
            row[i++] = GlobalStrings.GetYesNo(order.IsPayed);
            row[i++] = ListTostring(order.LstProduct);
            dt.Rows.Add(row);
        }

        SpreadsheetWriter ex = SpreadsheetWriter.FromDataTable(dt, true, true);

        Response.Clear();
        Response.AddHeader(@"content-disposition", @"attachment;filename=Deals_" + DateTime.UtcNow.ToString(@"yyyy_MM_dd_HH_mm_ss") + "." + ex.FileExtension);
        Response.Charset         = @"UTF-8";
        Response.ContentEncoding = System.Text.Encoding.UTF8;
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.ContentType = ex.FileContentType;
        Response.BinaryWrite(System.Text.Encoding.UTF8.GetPreamble());
        Response.Write(ex.ToString());
        Response.End();
    }
示例#3
0
    public void LoadItem()
    {
        Int64 AnimalId      = (ddlAnimalType.SelectedValue != null && Int64.TryParse(ddlAnimalType.SelectedValue, out AnimalId) && AnimalId > 0 ? AnimalId : 0);
        Int64 CategoryId    = (ddlCategory.SelectedValue != null && Int64.TryParse(ddlCategory.SelectedValue, out CategoryId) && CategoryId > 0 ? CategoryId : 0);
        Int64 SubCategoryId = (ddlSubCategory.SelectedValue != null && Int64.TryParse(ddlSubCategory.SelectedValue, out SubCategoryId) && SubCategoryId > 0 ? SubCategoryId : 0);

        dgProducts.DataSource = ProductController.GetAllProductBySupplier(SuppliersSessionHelper.SupplierId(), AnimalId, CategoryId, SubCategoryId, txtSearch.Text.Trim(), cbIsExists.Checked);
        dgProducts.DataBind();
    }
示例#4
0
    protected void btnExport_Click(object sender, EventArgs e)
    {
        System.Data.DataTable dt = new System.Data.DataTable();

        dt.Columns.Add(new System.Data.DataColumn(ProductsStrings.GetText(@"ProductName"), typeof(string)));
        dt.Columns.Add(new System.Data.DataColumn(ProductsStrings.GetText(@"ProductCode"), typeof(string)));
        dt.Columns.Add(new System.Data.DataColumn(ProductsStrings.GetText(@"Amount"), typeof(string)));
        dt.Columns.Add(new System.Data.DataColumn(ProductsStrings.GetText(@"RecomendedPrice"), typeof(string)));
        dt.Columns.Add(new System.Data.DataColumn(ProductsStrings.GetText(@"Description"), typeof(string)));
        dt.Columns.Add(new System.Data.DataColumn(ProductsStrings.GetText(@"AnimalType"), typeof(string)));
        dt.Columns.Add(new System.Data.DataColumn(ProductsStrings.GetText(@"ProductPrice"), typeof(string)));
        //dt.Columns.Add(new System.Data.DataColumn(ProductsStrings.GetText(@"Category"), typeof(string)));
        //  dt.Columns.Add(new System.Data.DataColumn(ProductsStrings.GetText(@"SubCategory"), typeof(string)));
        // dt.Columns.Add(new System.Data.DataColumn(ProductsStrings.GetText(@"ProductRate"), typeof(string)));

        string searchCode = "%" + txtSearch.Text.Trim() + "%";

        List <ProductUI> products = ProductController.GetAllProductUI(searchCode, Int64.Parse(ddlCategory.SelectedValue), Int64.Parse(ddlSubCategory.SelectedValue));

        foreach (ProductUI product in products)
        {
            int i = 0;
            System.Data.DataRow row = dt.NewRow();
            row[i++] = product.ProductName;
            row[i++] = product.ProductCode;
            row[i++] = product.Amount;
            row[i++] = product.RecomendedPrice;
            row[i++] = product.Description;
            row[i++] = ProductController.ConvertListToString(product.AnimalLst);
            SupplierProduct sup_prd = SupplierProduct.FetchByID(SuppliersSessionHelper.SupplierId(), product.ProductId);
            if (sup_prd != null)
            {
                row[i++] = sup_prd.Price;
            }


            //row[i++] = product.CategoryName;
            // row[i++] = product.SubCategoryName;
            // row[i++] = product.ProductRate;
            dt.Rows.Add(row);
        }

        SpreadsheetWriter ex = SpreadsheetWriter.FromDataTable(dt, false, true);

        Response.Clear();
        Response.AddHeader(@"content-disposition", @"attachment;filename=ProductsExport_" + DateTime.UtcNow.ToString(@"yyyy_MM_dd_HH_mm_ss") + "." + ex.FileExtension);
        Response.Charset         = @"UTF-8";
        Response.ContentEncoding = System.Text.Encoding.UTF8;
        Response.Cache.SetCacheability(HttpCacheability.NoCache);

        Response.ContentType = ex.FileContentType;
        Response.BinaryWrite(System.Text.Encoding.UTF8.GetPreamble());
        Response.Write(ex.ToString());
        Response.End();
    }
示例#5
0
    protected void btnResetAll_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid)
        {
            return;
        }

        Int64 SupplierId = SuppliersSessionHelper.SupplierId();

        (new Query(SupplierProduct.TableSchema).Where(SupplierProduct.Columns.SupplierId, SupplierId).Delete()).Execute();
        LoadItem();
    }
示例#6
0
    //protected void NumericOnly_ServerValidate(object source, ServerValidateEventArgs args)
    //{
    //    string pattern = @"^[0-9]*$";

    //    Regex rgx = new Regex(pattern, RegexOptions.IgnoreCase);
    //    bool result = true;
    //    string[] arr = hfProductIds.Value.Split(',');

    //    foreach (DataGridItem item in dgProducts.Items)
    //    {
    //        if (result)
    //        {
    //            object obj = dgProducts.DataKeys[item.ItemIndex];
    //            if (obj != null && !arr.Contains(obj.ToString())) continue;
    //            TextBox txtPrice = item.FindControl("txtPrice") as TextBox;

    //            MatchCollection matches = rgx.Matches(txtPrice.Text);
    //            if (matches.Count == 0 && txtPrice.Text != "") result = false;

    //            if (result == false)
    //            {
    //                args.IsValid = result;
    //                Master.MessageCenter.DisplayErrorMessage(ProductsStrings.GetText(@"NumericOnly"));

    //                // txtPrice.Text = ProductsStrings.GetText(@"NumericOnly");
    //            }
    //        }

    //    }

    //}

    protected void btnImport_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid)
        {
            return;
        }
        if (!SuppliersSessionHelper.IsProductSupplier())
        {
            return;
        }
        if (SuppliersSessionHelper.SupplierId() == 0)
        {
            return;
        }

        Response.Redirect(@"ImportProductsForSupplier.aspx", true);
    }
示例#7
0
    protected void btnSaveAll_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid)
        {
            return;
        }

        Int64 SupplierId = SuppliersSessionHelper.SupplierId();

        (new Query(SupplierProduct.TableSchema).Where(SupplierProduct.Columns.SupplierId, SupplierId).Delete()).Execute();
        ProductCollection pcol = ProductCollection.FetchByQuery(new Query(Product.TableSchema).Where(Product.Columns.IsDeleted, false));

        foreach (Product item in pcol)
        {
            SupplierProduct sp = new SupplierProduct();
            sp.SupplierId = SupplierId;
            sp.ProductId  = item.ProductId;
            sp.Gift       = "";
            sp.Save();
            check_price_deviation(sp);
        }
        LoadItem();
    }
示例#8
0
    public void LoadItem()
    {
        int      year  = Convert.ToInt32(ddlyear.SelectedValue);
        int      month = Convert.ToInt32(ddlMonth.SelectedValue);
        int      from  = Convert.ToInt32(ddlDayFrom.SelectedValue);
        int      to    = Convert.ToInt32(ddlDayTo.SelectedValue);
        DateTime?start = null;
        DateTime?end   = null;

        if (year != 0 && month != 0 && from != 0)
        {
            start = new DateTime(year, month, from); end = (to != 0 ? new DateTime(year, month, to) : end = new DateTime(year, month, DateTime.DaysInMonth(year, month)));
        }
        else if (year != 0 && month != 0)
        {
            start = new DateTime(year, month, 1); end = new DateTime(year, month, DateTime.DaysInMonth(year, month));
        }
        else if (year != 0)
        {
            start = new DateTime(year, 1, 1); end = new DateTime(year, 12, 31);
        }
        dgOrders.DataSource = OrderController.GetOrderSupplierHistory(SuppliersSessionHelper.SupplierId(), start, end);
        dgOrders.DataBind();
    }
示例#9
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid)
        {
            return;
        }
        bool result = false;

        string[] arr = hfProductIds.Value.Split(',');

        foreach (DataGridItem item in dgProducts.Items)
        {
            object obj = dgProducts.DataKeys[item.ItemIndex];
            if (obj != null && !arr.Contains(obj.ToString()))
            {
                continue;
            }
            CheckBox cb        = item.FindControl("cbIsExist") as CheckBox;
            TextBox  txtGift   = item.FindControl("txtGift") as TextBox;
            TextBox  txtPrice  = item.FindControl("txtPrice") as TextBox;
            Int64    ProductId = obj != null?Convert.ToInt64(obj) : 0;

            SupplierProduct sp = SupplierProduct.FetchByID(SuppliersSessionHelper.SupplierId(), ProductId);
            if (sp != null && cb != null && cb.Checked)
            {
                if (txtGift != null)
                {
                    sp.Gift = txtGift.Text;
                }
                if (txtPrice != null && !String.IsNullOrEmpty(txtPrice.Text))
                {
                    sp.Price = Convert.ToDecimal(txtPrice.Text);
                }
                if (sp.Price > 0)
                {
                    sp.Save();
                    result = true;
                    check_price_deviation(sp);
                }
            }
            else if (sp == null && cb != null && cb.Checked)
            {
                sp = new SupplierProduct();
                if (txtGift != null)
                {
                    sp.Gift = txtGift.Text;
                }
                if (txtPrice != null && !String.IsNullOrEmpty(txtPrice.Text))
                {
                    sp.Price = Convert.ToDecimal(txtPrice.Text);
                }
                sp.SupplierId = SuppliersSessionHelper.SupplierId();
                sp.ProductId  = ProductId;
                sp.CreateDate = DateTime.UtcNow;
                sp.Save();
                result = true;
                check_price_deviation(sp);
            }
            else if (sp != null && cb != null && !cb.Checked)
            {
                SupplierProduct.Delete(SuppliersSessionHelper.SupplierId(), ProductId);
                result = true;
            }
        }
        if (result)
        {
            Master.MessageCenter.DisplaySuccessMessage(ProductsStrings.GetText("SaveSuccess"));
        }
        LoadItem();
    }
示例#10
0
    public void LoadItem()
    {
        int      year  = Convert.ToInt32(ddlyear.SelectedValue);
        int      month = Convert.ToInt32(ddlMonth.SelectedValue);
        int      from  = Convert.ToInt32(ddlDayFrom.SelectedValue);
        int      to    = Convert.ToInt32(ddlDayTo.SelectedValue);
        DateTime start = DateTime.MinValue;
        DateTime end   = DateTime.MinValue;

        if (year != 0 && month != 0 && from != 0)
        {
            start = new DateTime(year, month, from); end = (to != 0 ? new DateTime(year, month, to) : end = new DateTime(year, month, DateTime.DaysInMonth(year, month)));
        }
        else if (year != 0 && month != 0)
        {
            start = new DateTime(year, month, 1); end = new DateTime(year, month, DateTime.DaysInMonth(year, month));
        }
        else if (year != 0)
        {
            start = new DateTime(year, 1, 1); end = new DateTime(year, 12, 31);
        }
        //    dgOrders.DataSource = OrderController.GetOrderSupplierHistory(SuppliersSessionHelper.SupplierId(), start, end);
        //     dgOrders.DataBind();
        SupplierServiceUI serviceSupplier = ServiceController.GetServiceSuppliersAndNumEvents(SuppliersSessionHelper.SupplierId(), start, end);

        txtClickNum.Text = serviceSupplier != null?serviceSupplier.ClickNum.ToString() : "0";

        txtClicksToCallNum.Text = serviceSupplier != null?serviceSupplier.ClickToCallNum.ToString() : "0";
    }
示例#11
0
        public string BuildMenuConfigItems(MenuConfig MenuConfig)
        {
            Int64 UserId = SuppliersSessionHelper.SupplierId();

            string[] permissions = Permissions.PermissionsForUser(UserId);


            RenderSideMenuDelegate mainMenuDelegate = null;

            mainMenuDelegate = delegate(MenuConfig.MenuConfigItem[] subItems, int level, out bool isSelected)
            {
                bool opened = false, bIsSelected, bHide, firstSelection = true;
                isSelected = false;
                StringBuilder sb = null;
                string        name, href, subMenu;
                foreach (MenuConfig.MenuConfigItem item in subItems)
                {
                    bHide = false;

                    if (bHide == false && item.Allow != null && item.Allow.Length > 0)
                    {
                        bHide = true;
                        foreach (string perm in item.Allow)
                        {
                            if (permissions.Contains(perm))
                            {
                                bHide = false;
                                break;
                            }
                        }
                    }
                    //if (!bHide)
                    //{
                    //    if (item.SpecialCondition != null)
                    //    {
                    //        if (item.SpecialCondition.Contains(@"special...") && conditions...) bHide = true;
                    //    }
                    //}
                    if (!bHide)
                    {
                        if (sb == null)
                        {
                            sb = new StringBuilder();
                        }
                        if (!opened && level > 0)
                        {
                            sb.Append(@"<ul>");
                            opened = true;
                        }
                        name = Resources.Menu.ResourceManager.GetString(item.Name);
                        href = Page.ResolveUrl(item.Link);

                        string onclick = "";
                        if (!string.IsNullOrEmpty(item.OnClick))
                        {
                            onclick = @" onclick=""" + item.OnClick.ToHtml() + @"""";
                        }

                        subMenu = mainMenuDelegate(item.Items, level + 1, out bIsSelected);
                        if (bIsSelected)
                        {
                            isSelected = true;
                        }
                        if (!bIsSelected && item.Name == ActiveMenu)
                        {
                            bIsSelected = isSelected = true;
                        }
                        if (bIsSelected && firstSelection)
                        {
                            sb.AppendFormat(@"<li class=""active""><a href=""{0}""{2}><span>{1}</span></a>", href.ToHtml(), name.ToHtml(), onclick);
                            firstSelection = false;
                        }
                        else
                        {
                            sb.AppendFormat(@"<li><a href=""{0}""{2}><span>{1}</span></a>", href.ToHtml(), name.ToHtml(), onclick);
                        }
                        if (subMenu != null)
                        {
                            sb.Append(subMenu);
                        }
                        sb.Append(@"</li>");
                    }
                }
                if (opened)
                {
                    sb.Append(@"</ul>");
                }
                if (sb != null)
                {
                    return(sb.ToString());
                }
                return(null);
            };

            bool tempIsSelected;

            return(mainMenuDelegate(MenuConfig.MenuItems, 0, out tempIsSelected));
        }