Beispiel #1
0
    protected void egvProducts_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Product product        = e.Row.DataItem as Product;
            Image   productPicture = e.Row.FindControl("ProductPicture") as Image;
            Literal ltComming      = e.Row.FindControl("ltComming") as Literal;

            if (productPicture != null)
            {
                productPicture.ImageUrl = product.GetDefaultImageUrl((int)productPicture.Width.Value, (int)productPicture.Height.Value);
            }
            HyperLink hyName = e.Row.FindControl("hlProductName") as HyperLink;
            Company   c      = Users.GetUser(product.CreateUser).Company;
            if (c != null && c.CompanyID != 0)
            {
                ProductSupply ps = ProductSupplyManager.GetProductSupply(product.ProductID, c.CompanyID);
                ltComming.Text = "[<a class=\"navCompany\" href='javascript:{}' onclick=\"showSupply(" + ps.SupplyID + ")\">" + c.CompanyName + "</a>]&nbsp;&nbsp;";
            }
            else
            {
                ltComming.Text = "华宏";
            }

            if (hyName != null)
            {
                hyName.Text        = product.ProductName;
                hyName.NavigateUrl = GlobalSettings.RelativeWebRoot + "pages/view.aspx?product-product&ID=" + GlobalSettings.Encrypt(product.ProductID.ToString());
            }
        }
    }
    void BindSupply()
    {
        int           id = int.Parse(Request.QueryString["ID"]);
        ProductSupply ps = ProductSupplyManager.GetProductSupply(id);
        Company       c  = Companys.GetCompany(ps.SupplierID);
        Area          a  = Areas.GetArea(c.CompanyRegion);
        string        AN = "--";

        if (a != null)
        {
            AN = a.RegionName;
        }
        ltCompanyName.Text = "<a class=\"navCompany\" href=\"javascript:{}\">[" + c.CompanyName +
                             "]<div class=\"companyDetailsRemark_s\">" +
                             "<div>区域:" + AN + "</div>" +
                             "<div>组织机构代码:" + c.Orgcode + "</div>" +
                             "<div>工商注册号码:" + c.Regcode + "</div>" +
                             "<div>联系电话:" + c.Phone + "</div>" +
                             "<div>公司传真:" + c.Fax + "</div>" +
                             "<div>联系地址:" + c.Address + "</div>" +
                             "<div>邮政编码:" + c.Zipcode + "</div>" +
                             "<div>公司主页:" + c.Website + "</div>" +
                             "</div></a>";
        ltFaxRate.Text = ps.ApplyTaxRate.ToString("P2");
        dsDeliverySpan.DateSpanValue = ps.DeliverySpan;
        ltCreateTime.Text            = ps.CreateTime.ToShortDateString();
        ltCreateUser.Text            = Users.GetUser(ps.CreateUser).UserName;
        ltHasfeight.Text             = (ps.IncludeFreight == FreightIncludeType.Include ? "是" : "<span class='needed'>否</span>");
        ltIncludeTax.Text            = (ps.IncludeTax == TaxIncludeType.Include ? "是" : "<span class='needed'>否</span>");

        if (ps.SupplyRegion == null)
        {
            ltRegion.Text = "全国";
        }
        else
        {
            AN = string.Empty;
            a  = Areas.GetArea(ps.SupplyRegion.Value);
            if (a != null)
            {
                AN = a.RegionName;
            }
            ltRegion.Text = a.RegionName;
        }

        ltStartTime.Text    = ps.QuoteFrom.ToShortDateString();
        ltEndTime.Text      = ps.QuoteEnd.ToShortDateString();
        ltAmount.Text       = (ps.QuoteMOQ == null ? "无要求" : ps.QuoteMOQ.Value.ToString());
        ltPrice.Text        = GlobalSettings.GetPrice(ps.QuotePrice);
        ltQuoteRenewal.Text = (ps.QuoteRenewal == 0 ? "无" : ps.QuoteRenewal + "月");
        dsWS.DateSpanValue  = ps.WarrantySpan;
        ltSupply.Text       = (ps.SupplyStatus == ComponentStatus.Enabled ? "是" : "<span class='needed'>否</span>");
    }
    /// <summary>
    /// 绑定信息
    /// </summary>
    public void BindData()
    {
        int     productID = Convert.ToInt32(Request.QueryString["ProductID"]);
        Product product   = Products.GetProduct(productID);

        if (product == null)
        {
            throw new HHException(ExceptionType.ProductNotFound);
        }
        else
        {
            // 根据产品ID和公司ID查找产品供应信息
            ProductSupply ps = ProductSupplyManager.GetProductSupply(product.ProductID, Profile.AccountInfo.CompanyID);

            if (ps == null)
            {
                throw new HHException(ExceptionType.ProductSupplyNotFound);
            }
            else
            {
                // 产品名称
                lblProductName.Text = product.ProductName;

                // TODO: 产品型号

                // 最短供货时间
                txtDeliverySpan.DateSpanValue = ps.DeliverySpan;

                // 产品保修期
                txtWarrantySpan.DateSpanValue = ps.WarrantySpan;

                // 供货单价
                txtQuotePrice.Text = ps.QuotePrice.HasValue ? ps.QuotePrice.Value.ToString() : string.Empty;

                // 最小订货量
                txtQuoteMOQ.Text = ps.QuoteMOQ.HasValue ? ps.QuoteMOQ.Value.ToString() : string.Empty;

                // 包含运费
                ilIncludeFreight.SelectedValue = ps.IncludeFreight.HasValue ? (PriceIncludeType)ps.IncludeFreight : PriceIncludeType.Include;

                // 包含税
                ilIncludeTax.SelectedValue = (PriceIncludeType)ps.IncludeTax;

                // 供货税率
                txtApplyTaxRate.Text = ps.ApplyTaxRate.ToString();

                // 供应区域
                if (ps.SupplyRegion.HasValue)
                {
                    hfRegionCode.Value = ps.SupplyRegion.Value.ToString();

                    try
                    {
                        Area a = Areas.GetArea(ps.SupplyRegion.Value);
                        txtRegion.Text = a.RegionName;
                    }
                    catch { }
                }

                // 报价起始日期
                if (ps.QuoteFrom == GlobalSettings.MinValue)
                {
                    txtQuoteFrom.Text = string.Empty;
                }
                else
                {
                    txtQuoteFrom.Text = ps.QuoteFrom.ToString("yyyy年MM月dd日");
                }

                // 报价截止日期
                if (ps.QuoteEnd == GlobalSettings.MaxValue)
                {
                    txtQuoteEnd.Text = string.Empty;
                }
                else
                {
                    txtQuoteEnd.Text = ps.QuoteEnd.ToString("yyyy年MM月dd日");
                }

                // 报价自动续期周期
                txtQuoteRenewal.Text = ps.QuoteRenewal.ToString();

                // 是否启用
                csSupplyStatus.SelectedValue = ps.SupplyStatus;
            }
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        int     productID = Convert.ToInt32(Request.QueryString["ProductID"]);
        Product product   = Products.GetProduct(productID);

        if (product == null)
        {
            throw new HHException(ExceptionType.ProductNotFound);
        }
        else
        {
            // 根据产品ID和公司ID查找产品供应信息
            ProductSupply ps = ProductSupplyManager.GetProductSupply(product.ProductID, Profile.AccountInfo.CompanyID);

            if (ps == null)
            {
                throw new HHException(ExceptionType.ProductSupplyNotFound);
            }
            else
            {
                // 产品名称
                product.ProductName = lblProductName.Text;

                // TODO: 产品型号

                // 最短供货时间
                ps.DeliverySpan = txtDeliverySpan.DateSpanValue;

                // 产品保修期
                ps.WarrantySpan = txtWarrantySpan.DateSpanValue;

                // 供货单价
                if (string.IsNullOrEmpty(txtQuotePrice.Text))
                {
                    ps.QuotePrice = null;
                }
                else
                {
                    ps.QuotePrice = Convert.ToDecimal(txtQuotePrice.Text);
                }

                // 最小订货量
                if (string.IsNullOrEmpty(txtQuoteMOQ.Text))
                {
                    ps.QuoteMOQ = null;
                }
                else
                {
                    ps.QuoteMOQ = Convert.ToInt32(txtQuoteMOQ.Text);
                }

                // 包含运费
                ps.IncludeFreight = (FreightIncludeType)ilIncludeFreight.SelectedValue;

                // 包含税
                ps.IncludeTax = (TaxIncludeType)ilIncludeTax.SelectedValue;

                // 供货税率
                ps.ApplyTaxRate = Convert.ToDecimal(txtApplyTaxRate.Text);

                // 供应区域
                int regionID = Convert.ToInt32(hfRegionCode.Value);
                if (regionID <= 0)
                {
                    ps.SupplyRegion = null;
                }
                else
                {
                    ps.SupplyRegion = regionID;
                }

                // 报价起始日期
                ps.QuoteFrom = DateTime.Parse(txtQuoteFrom.Text);

                // 报价截止日期
                ps.QuoteEnd = DateTime.Parse(txtQuoteEnd.Text);

                // 报价自动续期周期
                ps.QuoteRenewal = Convert.ToInt32(txtQuoteRenewal.Text);

                // 是否启用
                ps.SupplyStatus = csSupplyStatus.SelectedValue;

                // 开始更新
                DataActionStatus state = ProductSupplyManager.Update(ps);

                if (state == DataActionStatus.Success)
                {
                    throw new HHException(ExceptionType.Success, "修改成功!");
                }
                else
                {
                    throw new HHException(ExceptionType.Failed, "修改失败,请确认信息是否正确!");
                }
            }
        }
    }