Ejemplo n.º 1
0
            public OrderDetail(PBM_OrderDetail m)
            {
                DetailID          = m.ID;
                Product           = m.Product;
                Price             = m.Price;
                DiscountRate      = m.DiscountRate;
                BookQuantity      = m.BookQuantity;
                ConfirmQuantity   = m.ConfirmQuantity;
                DeliveredQuantity = m.DeliveredQuantity;
                Remark            = m.Remark;

                PDT_Product p = new PDT_ProductBLL(Product).Model;

                if (p == null)
                {
                    return;
                }

                ProductName = p.ShortName;

                if (p.ConvertFactor == 0)
                {
                    p.ConvertFactor = 1;
                }
                ConvertFactor = p.ConvertFactor;

                if (p.Category > 0)
                {
                    CategoryName = PDT_CategoryBLL.GetFullCategoryName(p.Category);
                }

                #region 获取字典表名称
                try
                {
                    if (m.SalesMode > 0)
                    {
                        Dictionary_Data dic = DictionaryBLL.GetDicCollections("PBM_SalseMode")[m.SalesMode.ToString()];
                        if (dic != null)
                        {
                            SalesModeName = dic.Name;
                        }
                    }
                    if (p.TrafficPackaging > 0)
                    {
                        PackingName_T = DictionaryBLL.GetDicCollections("PDT_Packaging")[p.TrafficPackaging.ToString()].ToString();
                    }
                    if (p.Packaging > 0)
                    {
                        PackingName_P = DictionaryBLL.GetDicCollections("PDT_Packaging")[p.Packaging.ToString()].ToString();
                    }
                }
                catch (System.Exception err)
                {
                    LogWriter.WriteLog("MCSFramework.WSI.OrderDetail", err);
                }
                #endregion
            }
Ejemplo n.º 2
0
    protected void gv_List_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        if (ViewState["Details"] == null)
        {
            return;
        }
        ListTable <PBM_OrderDetail> Details = (ListTable <PBM_OrderDetail>)ViewState["Details"];

        int id = (int)gv_List.DataKeys[e.NewSelectedIndex]["ID"];

        PBM_OrderDetail d = Details[id.ToString()];

        PDT_Product product = new PDT_ProductBLL(d.Product, true).Model;

        if (product == null)
        {
            return;
        }

        //RadComboBox1.SelectedValue = d.Product.ToString();
        //RadComboBox1.Text = product.FullName;
        //RadComboBox1_SelectedIndexChanged(null, null);
        select_Product.SelectText  = product.FullName;
        select_Product.SelectValue = product.ID.ToString();
        select_Product_SelectChange(null, null);

        if (d.BookQuantity % product.ConvertFactor == 0)
        {
            ddl_Unit.SelectedValue = "T";
            tbx_Price.Text         = (d.Price * product.ConvertFactor).ToString("0.##");
            tbx_Quantity.Text      = (d.BookQuantity / product.ConvertFactor).ToString();
        }
        else
        {
            ddl_Unit.SelectedValue = "P";
            tbx_Price.Text         = d.Price.ToString("0.##");
            tbx_Quantity.Text      = d.BookQuantity.ToString();
        }
        ddl_SalesMode.SelectedValue = d.SalesMode.ToString();
        ViewState["SelectedDetail"] = d;
        bt_AddDetail.Text           = "修 改";
    }
Ejemplo n.º 3
0
    protected void bt_AddDetail_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["ID"] == 0)
        {
            return;
        }
        PBM_OrderBLL _bll = new PBM_OrderBLL((int)ViewState["ID"]);

        if (ViewState["Details"] == null)
        {
            return;
        }
        ListTable <PBM_OrderDetail> Details = (ListTable <PBM_OrderDetail>)ViewState["Details"];

        int product = 0;

        int.TryParse(select_Product.SelectValue, out product);
        //int.TryParse(RadComboBox1.SelectedValue, out product);
        if (product != 0)
        {
            PDT_ProductBLL productbll = new PDT_ProductBLL(product, true);
            if (productbll.Model == null)
            {
                return;
            }
            if (productbll.Model.ConvertFactor == 0)
            {
                productbll.Model.ConvertFactor = 1;
                productbll.Update();
            }

            int     quantity = 0;
            decimal price    = 0;

            int.TryParse(tbx_Quantity.Text, out quantity);
            decimal.TryParse(tbx_Price.Text, out price);

            if (ddl_Unit.SelectedValue == "T")
            {
                //整件单位
                quantity = quantity * productbll.Model.ConvertFactor;
                price    = price / productbll.Model.ConvertFactor;
            }

            if (quantity == 0)
            {
                MessageBox.Show(this, "请填写数量!");
                return;
            }

            PBM_OrderDetail d = null;

            if (ViewState["SelectedDetail"] != null)
            {
                d = (PBM_OrderDetail)ViewState["SelectedDetail"];
            }
            else
            {
                d         = new PBM_OrderDetail();
                d.OrderID = (int)ViewState["ID"];

                if (Details.GetListItem().Count == 0)
                {
                    d.ID = 1;
                }
                else
                {
                    d.ID = Details.GetListItem().Max(p => p.ID) + 1;
                }
            }

            d.Product           = product;
            d.Price             = price;        //实际销售价
            d.DiscountRate      = 1;            //默认全价
            d.ConvertFactor     = productbll.Model.ConvertFactor;
            d.BookQuantity      = quantity;
            d.ConfirmQuantity   = quantity;
            d.DeliveredQuantity = 0;
            d.SalesMode         = int.Parse(ddl_SalesMode.SelectedValue);
            if (d.SalesMode == 2)
            {
                d.Price = 0;
            }

            if (ViewState["SelectedDetail"] != null)
            {
                Details.Update(d);
                ViewState["SelectedDetail"] = null;
                bt_AddDetail.Text           = "新 增";
                gv_List.SelectedIndex       = -1;
            }
            else
            {
                Details.Add(d);
            }

            tbx_Quantity.Text = "0";

            BindGrid();
        }
    }
Ejemplo n.º 4
0
    protected void gv_List_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (ViewState["Details"] == null)
        {
            return;
        }
        ListTable <PBM_OrderDetail> Details = (ListTable <PBM_OrderDetail>)ViewState["Details"];

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            int             id = (int)gv_List.DataKeys[e.Row.RowIndex]["ID"];
            PBM_OrderDetail d  = Details[id.ToString()];

            PDT_Product product = new PDT_ProductBLL(d.Product, true).Model;
            if (product == null)
            {
                return;
            }
            Dictionary <string, Dictionary_Data> dic = DictionaryBLL.GetDicCollections("PDT_Packaging");
            string _T = dic[product.TrafficPackaging.ToString()].Name;
            string _P = dic[product.Packaging.ToString()].Name;

            #region 显示产品价格包装信息
            Label lb_Price = (Label)e.Row.FindControl("lb_Price");
            if (lb_Price != null)
            {
                lb_Price.Text = (d.Price * product.ConvertFactor).ToString("0.##") + "元 / " + _T + "(" + product.ConvertFactor.ToString() + _P + ")";
            }
            #endregion

            #region 显示产品数量信息
            Label lb_Quantity = (Label)e.Row.FindControl("lb_Quantity");
            if (lb_Quantity != null)
            {
                if (d.BookQuantity / product.ConvertFactor > 0)
                {
                    lb_Quantity.Text = (d.BookQuantity / product.ConvertFactor).ToString() + _T;
                }

                if (d.BookQuantity % product.ConvertFactor > 0)
                {
                    lb_Quantity.Text += " " + (d.BookQuantity % product.ConvertFactor).ToString() + _P;
                }
            }
            #endregion

            #region 显示库存数量
            Label lb_InventoryQuantity = (Label)e.Row.FindControl("lb_InventoryQuantity");
            if (lb_InventoryQuantity != null && ViewState["State"] != null && (int)ViewState["State"] == 1)
            {
                int inv_quantity = INV_InventoryBLL.GetProductQuantityAllWareHouse((int)ViewState["Supplier"], d.Product);
                lb_InventoryQuantity.Text = (inv_quantity / product.ConvertFactor).ToString() + _T;
                if (inv_quantity % product.ConvertFactor > 0)
                {
                    lb_InventoryQuantity.Text += " " + (inv_quantity % product.ConvertFactor).ToString() + _P;
                }

                if ((int)ViewState["Classify"] != 2)
                {
                    if (d.BookQuantity > inv_quantity)
                    {
                        lb_InventoryQuantity.Text = "<font color=red>" + lb_InventoryQuantity.Text + "【库存不足】</font>";
                    }
                }
            }
            #endregion
        }
        else if (e.Row.RowType == DataControlRowType.Footer)
        {
            e.Row.Cells[0].Text = "小计";
            e.Row.Cells[4].Text = Details.GetListItem().Sum(p => Math.Round(p.Price * p.ConvertFactor, 2) * p.BookQuantity / p.ConvertFactor).ToString("<font color=red size='larger'>0.##元</red>");
        }
    }