コード例 #1
0
    protected void ddl_LotNumber_SelectedIndexChanged(object sender, EventArgs e)
    {
        int product = 0;

        int.TryParse(select_Product.SelectValue, out product);
        //int.TryParse(RadComboBox1.SelectedValue, out product);
        if (product != 0 && ddl_LotNumber.SelectedValue != "")
        {
            PDT_ProductBLL productbll = new PDT_ProductBLL(product, true);
            if (productbll.Model == null)
            {
                return;
            }
            PDT_Product p = productbll.Model;

            INV_Inventory inv = INV_InventoryBLL.GetInventoryByProductAndLotNumber((int)ViewState["WareHouse"], product, ddl_LotNumber.SelectedValue);
            if (inv == null)
            {
                inv = INV_InventoryBLL.GetInventoryByClientAndProduct((int)ViewState["Supplier"], product, ddl_LotNumber.SelectedValue);
            }
            if (inv != null)
            {
                //获取现有库存中的批号信息
                tbx_ProductDate.Text = inv.ProductDate.ToString("yyyy-MM-dd");
                tbx_Quantity.Focus();
            }
        }
    }
コード例 #2
0
    protected void tbx_LotNumber_TextChanged(object sender, EventArgs e)
    {
        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;
            }
            PDT_Product p = productbll.Model;

            INV_Inventory inv = INV_InventoryBLL.GetInventoryByProductAndLotNumber((int)ViewState["WareHouse"], product, tbx_LotNumber.Text);
            if (inv != null)
            {
                //获取现有库存中的批号信息
                tbx_ProductDate.Text = inv.ProductDate.ToString("yyyy-MM-dd");
                if (ddl_Unit.SelectedValue == "T")
                {
                    tbx_Price.Text = (inv.Price * p.ConvertFactor).ToString("0.##");
                }
                else
                {
                    tbx_Price.Text = inv.Price.ToString("0.##");
                }
                tbx_Quantity.Focus();
            }
            else
            {
                //根据批号尝试转换为生产日期
                DateTime d = DateTime.Today;
                DateTime.TryParse(tbx_LotNumber.Text, out d);
                if (d.Year < DateTime.Today.Year - 1)
                {
                    if (tbx_LotNumber.Text.Length >= 8)
                    {
                        DateTime.TryParse(tbx_LotNumber.Text.Substring(0, 4) + "-" + tbx_LotNumber.Text.Substring(4, 2) + "-" + tbx_LotNumber.Text.Substring(6, 2), out d);
                    }
                }
                if (d.Year >= DateTime.Today.Year - 1)
                {
                    tbx_ProductDate.Text = d.ToString("yyyy-MM-dd");
                    tbx_Price.Focus();
                }
                else
                {
                    tbx_ProductDate.Text = DateTime.Today.ToString("yyyy-MM-01");
                }
            }
        }
    }
コード例 #3
0
    protected void gv_List_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            long          id  = (long)gv_List.DataKeys[e.Row.RowIndex]["ID"];
            INV_Inventory inv = new INV_InventoryBLL(id).Model;
            if (inv == null)
            {
                return;
            }

            PDT_Product product = new PDT_ProductBLL(inv.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_T = (Label)e.Row.FindControl("lb_Price_T");
            if (lb_Price_T != null)
            {
                lb_Price_T.Text = (inv.Price * product.ConvertFactor).ToString("0.##") + "元 /" + _T + "(" + product.ConvertFactor.ToString() + _P + ")";
            }

            Label lb_Price_P = (Label)e.Row.FindControl("lb_Price_P");
            if (lb_Price_P != null)
            {
                lb_Price_P.Text = inv.Price.ToString("0.##") + "元 /" + _P;
            }
            #endregion

            #region 显示产品数量信息
            Label lb_Quantity = (Label)e.Row.FindControl("lb_Quantity");
            if (lb_Quantity != null)
            {
                lb_Quantity.Text = (inv.Quantity / product.ConvertFactor).ToString() + _T;
                if (inv.Quantity % product.ConvertFactor > 0)
                {
                    lb_Quantity.Text += " " + (inv.Quantity % product.ConvertFactor).ToString() + _P;
                }
            }
            #endregion
        }
        else if (e.Row.RowType == DataControlRowType.Footer && ViewState["TotalInventory"] != null)
        {
            e.Row.Cells[1].Text = "小计库存额";
            e.Row.Cells[5].Text = ((decimal)ViewState["TotalInventory"]).ToString("<font color=red>0.##元</font>");
        }
    }
コード例 #4
0
    private void BindGrid()
    {
        string ConditionStr = "INV_Inventory.Quantity <> 0 ";

        if (ddl_WareHouse.SelectedValue != "0")
        {
            ConditionStr += " AND Inv_Inventory.WareHouse = " + ddl_WareHouse.SelectedValue;
        }
        else
        {
            ConditionStr += " AND INV_Inventory.WareHouse IN (SELECT ID FROM MCS_CM.dbo.CM_WareHouse WHERE Client=" + Session["OwnerClient"].ToString() + ")";
        }

        if (tr_List.SelectedValue != "" && tr_List.SelectedValue != "1")
        {
            string    _categoryids = "";
            DataTable dt           = TreeTableBLL.GetAllChildByNodes("MCS_Pub.dbo.PDT_Category", "ID", "SuperID", tr_List.SelectedValue);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                _categoryids += dt.Rows[i]["ID"].ToString() + ",";
            }
            _categoryids += tr_List.SelectedValue;

            ConditionStr += " AND INV_Inventory.Product IN (SELECT ID FROM MCS_PUB.dbo.PDT_Product WHERE Category IN (" + _categoryids + "))";
        }

        if (tbx_SearchKey.Text != "")
        {
            ConditionStr += " AND (INV_Inventory.Product IN (SELECT ID FROM MCS_PUB.dbo.PDT_Product WHERE ";
            ConditionStr += " FullName LIKE '%" + tbx_SearchKey.Text + "%' ";
            ConditionStr += "OR ShortName LIKE '%" + tbx_SearchKey.Text + "%' ";
            ConditionStr += "OR BarCode LIKE '%" + tbx_SearchKey.Text + "%' ";
            ConditionStr += "OR FactoryName LIKE '%" + tbx_SearchKey.Text + "%' ";
            ConditionStr += "OR FactoryCode LIKE '%" + tbx_SearchKey.Text + "%' ";
            ConditionStr += ") )";
        }

        IList <INV_Inventory> lists = INV_InventoryBLL.GetModelList(ConditionStr);

        ViewState["TotalInventory"] = lists.Sum(p => p.Price * p.Quantity);
        gv_List.BindGrid(lists);

        gv_List.Columns[gv_List.Columns.Count - 1].Visible = ddl_WareHouse.SelectedValue != "0";
        bt_Adjust.Enabled = ddl_WareHouse.SelectedValue != "0";
    }
コード例 #5
0
    protected void gv_List_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            long id = (long)gv_List.DataKeys[e.Row.RowIndex]["ID"];
            INV_Inventory inv = new INV_InventoryBLL(id).Model;
            if (inv == null) return;

            PDT_Product product = new PDT_ProductBLL(inv.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_T = (Label)e.Row.FindControl("lb_Price_T");
            if (lb_Price_T != null)
            {
                lb_Price_T.Text = (inv.Price * product.ConvertFactor).ToString("0.##") + "元 /" + _T + "(" + product.ConvertFactor.ToString() + _P + ")";
            }

            Label lb_Price_P = (Label)e.Row.FindControl("lb_Price_P");
            if (lb_Price_P != null)
            {
                lb_Price_P.Text = inv.Price.ToString("0.##") + "元 /" + _P;
            }
            #endregion

            #region 显示产品数量信息
            Label lb_Quantity = (Label)e.Row.FindControl("lb_Quantity");
            if (lb_Quantity != null)
            {
                lb_Quantity.Text = (inv.Quantity / product.ConvertFactor).ToString() + _T;
                if (inv.Quantity % product.ConvertFactor > 0)
                    lb_Quantity.Text += " " + (inv.Quantity % product.ConvertFactor).ToString() + _P;
            }
            #endregion
        }
        else if (e.Row.RowType == DataControlRowType.Footer && ViewState["TotalInventory"] != null)
        {
            e.Row.Cells[1].Text = "小计库存额";
            e.Row.Cells[5].Text = ((decimal)ViewState["TotalInventory"]).ToString("<font color=red>0.##元</font>");
        }
    }
コード例 #6
0
    protected void bt_AddDetail_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["ID"] == 0)
        {
            return;
        }
        PBM_DeliveryBLL _bll = new PBM_DeliveryBLL((int)ViewState["ID"]);

        if (ViewState["Details"] == null)
        {
            return;
        }
        ListTable <PBM_DeliveryDetail> Details = (ListTable <PBM_DeliveryDetail>)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;
            }

            if ((int)ViewState["Classify"] != 2)
            {
                #region 销售时判断库存数量是否够退货
                int inv_quantity = INV_InventoryBLL.GetProductQuantity((int)ViewState["WareHouse"], product, ddl_LotNumber.SelectedValue);
                if (quantity > inv_quantity)
                {
                    MessageBox.Show(this, "库存不足,不可销售出库!");
                    return;
                }
                #endregion
            }

            INV_Inventory inv = INV_InventoryBLL.GetInventoryByProductAndLotNumber((int)ViewState["WareHouse"],
                                                                                   product, ddl_LotNumber.SelectedValue);
            if (inv == null)
            {
                MessageBox.Show(this, "请正确选择销售批号!");
                return;
            }

            PBM_DeliveryDetail d = null;

            if (ViewState["SelectedDetail"] != null)
            {
                d = (PBM_DeliveryDetail)ViewState["SelectedDetail"];
            }
            else
            {
                d            = new PBM_DeliveryDetail();
                d.DeliveryID = (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.LotNumber        = ddl_LotNumber.SelectedValue;
            d.CostPrice        = inv.Price;     //成本价取当前库存表的价格
            d.Price            = price;         //实际销售价
            d.ConvertFactor    = productbll.Model.ConvertFactor;
            d.DiscountRate     = 1;             //默认全价
            d.DeliveryQuantity = quantity;
            d.SignInQuantity   = d.DeliveryQuantity;
            d.LostQuantity     = 0;
            d.BadQuantity      = 0;
            d.SalesMode        = 1;
            if (d.SalesMode == 2)
            {
                d.Price = 0;
            }

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

            tbx_Quantity.Text = "0";

            BindGrid();
        }
    }
コード例 #7
0
    protected void select_Product_SelectChange(object sender, MCSControls.MCSWebControls.SelectChangeEventArgs e)
    {
        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);
            if (productbll.Model == null)
            {
                return;
            }
            PDT_Product p = productbll.Model;

            Dictionary <string, Dictionary_Data> dic = DictionaryBLL.GetDicCollections("PDT_Packaging");
            string _T = dic[p.TrafficPackaging.ToString()].Name;
            string _P = dic[p.Packaging.ToString()].Name;

            #region 显示批号及库存信息
            ddl_LotNumber.Items.Clear();
            //调拨,仅获取指定仓库可销售的批号
            foreach (INV_Inventory item in INV_InventoryBLL.GetInventoryListByProduct((int)ViewState["WareHouse"], product).OrderBy(t => t.LotNumber))
            {
                string invstr = (item.Quantity / p.ConvertFactor).ToString() + _T;
                if (item.Quantity % p.ConvertFactor > 0)
                {
                    invstr += " " + (item.Quantity % p.ConvertFactor).ToString() + _P;
                }

                ddl_LotNumber.Items.Add(new ListItem((item.LotNumber == "" ? "无批号" : item.LotNumber) +
                                                     " -【库存量:" + invstr + "】", item.LotNumber));
            }

            if (ddl_LotNumber.Items.Count == 0)
            {
                ddl_LotNumber.Items.Add(new ListItem("无批号", ""));
            }
            ddl_LotNumber_SelectedIndexChanged(null, null);
            #endregion

            #region 显示产品包装信息
            lb_TrafficPackagingName.Text = "元/" + _T + "(" + p.ConvertFactor.ToString() + _P + ")";
            #endregion

            #region 调拨价格为商品默认销售价
            decimal saleprice = 0;
            try
            {
                saleprice = productbll.GetProductExtInfo((int)Session["OwnerClient"]).SalesPrice;
            }
            catch { }

            if (saleprice > 0)
            {
                if (ddl_Unit.SelectedValue == "T")
                {
                    tbx_Price.Text = (saleprice * p.ConvertFactor).ToString("0.###");
                }
                else
                {
                    tbx_Price.Text = saleprice.ToString("0.###");
                }
                tbx_Price.Enabled = false;
            }
            else
            {
                tbx_Price.Text    = "0";
                tbx_Price.Enabled = true;
            }
            #endregion
        }
    }
コード例 #8
0
    protected void bt_AddDetail_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["ID"] == 0)
        {
            return;
        }
        PBM_DeliveryBLL _bll = new PBM_DeliveryBLL((int)ViewState["ID"]);

        if (ViewState["Details"] == null)
        {
            return;
        }
        ListTable <PBM_DeliveryDetail> Details = (ListTable <PBM_DeliveryDetail>)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();
            }

            string   lotnumber   = "";
            int      quantity    = 0;
            decimal  price       = 0;
            DateTime producedate = new DateTime(1900, 1, 1);


            int.TryParse(tbx_Quantity.Text, out quantity);
            decimal.TryParse(tbx_Price.Text, out price);
            DateTime.TryParse(tbx_ProductDate.Text, out producedate);
            if (producedate.Year < 1900)
            {
                producedate = new DateTime(1900, 1, 1);
            }

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

            if (quantity == 0)
            {
                //MessageBox.Show(this, "请选择采购数量!");
                return;
            }

            lotnumber = rbl_ln.SelectedValue == "N" ? tbx_LotNumber.Text : ddl_LotNumber.SelectedValue;

            if (lotnumber == "" && producedate.Year > 1900)
            {
                lotnumber = producedate.ToString("yyyyMMdd");
            }

            if ((int)ViewState["Classify"] == 12)
            {
                #region 判断库存数量是否够退货
                int inv_quantity = INV_InventoryBLL.GetProductQuantity((int)ViewState["WareHouse"], product, lotnumber);
                if (quantity > inv_quantity)
                {
                    MessageBox.Show(this, "库存不足,不可采购退货!");
                    return;
                }
                #endregion
            }
            PBM_DeliveryDetail d = null;

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

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

            decimal discountrate = 100;
            decimal.TryParse(tbx_DiscountRate.Text, out discountrate);

            d.Product          = product;
            d.LotNumber        = lotnumber;
            d.ProductDate      = producedate.Year < 1900 ? new DateTime(1900, 1, 1) : producedate;
            d.CostPrice        = price;
            d.Price            = d.CostPrice;
            d.DiscountRate     = discountrate / 100; //默认100为全价
            d.ConvertFactor    = productbll.Model.ConvertFactor;
            d.DeliveryQuantity = quantity;
            d.SignInQuantity   = d.DeliveryQuantity;
            d.LostQuantity     = 0;
            d.BadQuantity      = 0;
            d.SalesMode        = int.Parse(ddl_SalesMode.SelectedValue);
            if (d.SalesMode == 2)
            {
                d.Price = 0;
            }                                           //赠送模式采购价自动设为0

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

            BindGrid();
        }
    }
コード例 #9
0
    protected void rbl_ln_SelectedIndexChanged(object sender, EventArgs e)
    {
        ddl_LotNumber.Visible   = rbl_ln.SelectedValue != "N";
        tbx_LotNumber.Visible   = rbl_ln.SelectedValue == "N";
        tbx_ProductDate.Enabled = rbl_ln.SelectedValue == "N";

        if (rbl_ln.SelectedValue == "Y")
        {
            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;
                }
                PDT_Product p = productbll.Model;

                Dictionary <string, Dictionary_Data> dic = DictionaryBLL.GetDicCollections("PDT_Packaging");
                string _T = dic[p.TrafficPackaging.ToString()].Name;
                string _P = dic[p.Packaging.ToString()].Name;

                #region 显示批号及库存信息
                ddl_LotNumber.Items.Clear();
                foreach (INV_Inventory item in INV_InventoryBLL.GetInventoryListByProduct((int)ViewState["WareHouse"], product))
                {
                    //ddl_LotNumber.Items.Add(new ListItem((item.LotNumber == "" ? "无批号" : item.LotNumber), item.LotNumber));
                    string invstr = (item.Quantity / p.ConvertFactor).ToString() + _T;
                    if (item.Quantity % p.ConvertFactor > 0)
                    {
                        invstr += " " + (item.Quantity % p.ConvertFactor).ToString() + _P;
                    }
                    ddl_LotNumber.Items.Add(new ListItem((item.LotNumber == "" ? "无批号" : item.LotNumber) + "-【库存量:" + invstr + "】", item.LotNumber));
                }
                #endregion

                ddl_LotNumber_SelectedIndexChanged(null, null);
            }
        }
        else
        {
            tbx_LotNumber.Text   = "";
            tbx_ProductDate.Text = "";

            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;
                }

                PDT_ProductExtInfo extinfo = productbll.GetProductExtInfo((int)Session["OwnerClient"]);
                if (extinfo == null)
                {
                    return;
                }

                if (ddl_Unit.SelectedValue == "T")
                {
                    tbx_Price.Text = (extinfo.BuyPrice * productbll.Model.ConvertFactor).ToString("0.##");
                }
                else
                {
                    tbx_Price.Text = extinfo.BuyPrice.ToString("0.##");
                }
            }
        }
    }
コード例 #10
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>");
        }
    }
コード例 #11
0
    protected void select_Product_SelectChange(object sender, MCSControls.MCSWebControls.SelectChangeEventArgs e)
    {
        int product = 0;

        int.TryParse(select_Product.SelectValue, out product);
        if (product != 0)
        {
            PDT_ProductBLL productbll = new PDT_ProductBLL(product);
            if (productbll.Model == null)
            {
                return;
            }
            PDT_Product p = productbll.Model;

            Dictionary <string, Dictionary_Data> dic = DictionaryBLL.GetDicCollections("PDT_Packaging");
            string _T = dic[p.TrafficPackaging.ToString()].Name;
            string _P = dic[p.Packaging.ToString()].Name;

            #region 显示批号及库存信息
            ddl_LotNumber.Items.Clear();
            if ((int)ViewState["Classify"] == 2)
            {
                //退货,从供货商全部仓库中获取可退货的批号
                IList <INV_Inventory> list = INV_InventoryBLL.GetListByClientAndProduct((int)ViewState["Supplier"], product);
                foreach (INV_Inventory item in list)
                {
                    ddl_LotNumber.Items.Add(new ListItem((item.LotNumber == "" ? "无批号" : item.LotNumber), item.LotNumber));
                }
            }
            else
            {
                //销售,仅获取指定仓库可销售的批号
                foreach (INV_Inventory item in INV_InventoryBLL.GetInventoryListByProduct((int)ViewState["WareHouse"], product).OrderBy(t => t.LotNumber))
                {
                    string invstr = (item.Quantity / p.ConvertFactor).ToString() + _T;
                    if (item.Quantity % p.ConvertFactor > 0)
                    {
                        invstr += " " + (item.Quantity % p.ConvertFactor).ToString() + _P;
                    }

                    ddl_LotNumber.Items.Add(new ListItem((item.LotNumber == "" ? "无批号" : item.LotNumber) +
                                                         " -【库存量:" + invstr + "】", item.LotNumber));
                }
            }
            if (ddl_LotNumber.Items.Count == 0)
            {
                ddl_LotNumber.Items.Add(new ListItem("无批号", ""));
            }
            ddl_LotNumber_SelectedIndexChanged(null, null);
            #endregion

            #region 显示产品包装信息
            lb_TrafficPackagingName.Text = "元/" + _T + "(" + p.ConvertFactor.ToString() + _P + ")";
            #endregion

            #region 获取销售该门店的价格
            decimal saleprice = PDT_StandardPriceBLL.GetSalePrice((int)ViewState["Client"], (int)Session["OwnerClient"], product);
            if (saleprice > 0)
            {
                if (ddl_Unit.SelectedValue == "T")
                {
                    tbx_Price.Text = (saleprice * p.ConvertFactor).ToString("0.###");
                }
                else
                {
                    tbx_Price.Text = saleprice.ToString("0.###");
                }
                //tbx_Price.Enabled = false;
            }
            else
            {
                tbx_Price.Text = "0";
                //tbx_Price.Enabled = true;
            }
            #endregion
        }
    }
コード例 #12
0
        public string DoImportInventory(int TemplateID, int Client, ISheet Sheet, out int State)
        {
            string ImportInfo = "【期初库存】Excel表:";

            State = 0;
            IPT_UploadTemplateBLL _template = new IPT_UploadTemplateBLL(TemplateID);

            List <string> listSupplier = new List <string>()
            {
                "序号", "商品编码", "商品名称", "批号", "生产日期", "库存成本价", "整件数量", "零散数量"
            };

            DataTable dt   = null;
            bool      flag = VertifySheet(Sheet, listSupplier, out dt, ref ImportInfo);

            if (!flag)
            {
                State = 4; return(ImportInfo);
            }

            foreach (DataRow dr in dt.Rows)//循环导入数据
            {
                try
                {
                    int _pdtTrafficPackaging = (!string.IsNullOrEmpty(dr["整件数量"].ToString())) ? Convert.ToInt32(dr["整件数量"].ToString()) : 0;
                    int _pdtPackaging        = (!string.IsNullOrEmpty(dr["零散数量"].ToString())) ? Convert.ToInt32(dr["零散数量"].ToString()) : 0;
                    if (_pdtPackaging == 0 && _pdtTrafficPackaging == 0)
                    {
                        ImportInfo += string.Format("序号为{0}的行导入库存数量为0,跳过此行信息\r\n", dr["序号"]);
                        continue;
                    }
                    string _pdtCode = dr["商品编码"].ToString();
                    IList <PDT_ProductExtInfo> _listPdtExtInfo = PDT_ProductExtInfoBLL.GetProductExtInfoList_BySupplier(_template.Model.ClientID);
                    PDT_ProductExtInfo         _ProductExtInfo = _listPdtExtInfo.FirstOrDefault(m => m.Code == _pdtCode);
                    if (_ProductExtInfo == null || _ProductExtInfo.ID == 0)
                    {
                        ImportInfo += string.Format("序号为{0}的行找不到对应编码的产品,跳过此行信息\r\n", dr["序号"]);
                        continue;
                    }
                    int _pdtID = _ProductExtInfo.Product;

                    //string _pdtName = dr["商品名称"].ToString();
                    string   _pdtLotNumber = dr["批号"].ToString();
                    DateTime _pdtProductDate; DateTime.TryParse(dr["生产日期"].ToString(), out _pdtProductDate);
                    decimal  _pdtPrice    = (!string.IsNullOrEmpty(dr["库存成本价"].ToString())) ? Convert.ToDecimal(dr["库存成本价"].ToString()) : 0;
                    int      _pdtQuantity = new PDT_ProductBLL(_pdtID).Model.ConvertFactor *_pdtTrafficPackaging + _pdtPackaging;


                    #region 获取经销商主仓库
                    int _WareHouse = 0;
                    IList <CM_WareHouse> _listWareHouse = CM_WareHouseBLL.GetModelList("  Classify=1 AND ApproveFlag=1 AND Client=" + _template.Model.ClientID.ToString());
                    if (_listWareHouse != null || _listWareHouse.Count > 0)
                    {
                        _WareHouse = _listWareHouse[0].ID;
                    }
                    else
                    {
                        CM_WareHouseBLL _bllWareHouse = new CM_WareHouseBLL();
                        _bllWareHouse.Model.Name        = "默认主仓库";
                        _bllWareHouse.Model.Client      = _template.Model.ClientID;
                        _bllWareHouse.Model.InsertStaff = _template.Model.InsertStaff;
                        _bllWareHouse.Model.ApproveFlag = 1;
                        _WareHouse = _bllWareHouse.Add();
                    }
                    #endregion

                    int _result = INV_InventoryBLL.IncreaseQuantity(_WareHouse, _pdtID, _pdtLotNumber, _pdtPrice, _pdtQuantity);
                    if (_result != 0)
                    {
                        ImportInfo += "导入序列号为" + dr["序号"].ToString() + "的销量时出现错误";
                        State       = 5;
                        continue;
                    }
                }
                catch (Exception ex)
                {
                    ImportInfo += "导入序列号为" + dr["序号"].ToString() + "的数据行时出现错误,错误说明:" + ex.Message + "\r\n";
                    State       = 5;
                    continue;
                }
            }
            if (State == 0)
            {
                State = 3;
            }
            ImportInfo += (State == 3 ? "导入完成!\r\n" : "");
            IPT_UploadTemplateMessageBLL _bllUploadTemplateMessage = new IPT_UploadTemplateMessageBLL();
            _bllUploadTemplateMessage.Model.TemplateID  = TemplateID;
            _bllUploadTemplateMessage.Model.MessageType = State;
            _bllUploadTemplateMessage.Model.Content     = ImportInfo;
            _bllUploadTemplateMessage.Add();
            return(ImportInfo);
        }