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(); } } }
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"); } } } }
public Inventory(INV_Inventory m) { Product = m.Product; Quantity = m.Quantity; LotNumber = m.LotNumber; CostPrice = m.Price; PDT_Product p = new PDT_ProductBLL(Product).Model; if (p == null) { return; } ProductName = p.ShortName; PDT_Brand b = new PDT_BrandBLL(p.Brand).Model; if (b != null) { BrandName = b.Name; } if (p.Category > 0) { CategoryName = PDT_CategoryBLL.GetFullCategoryName(p.Category); } 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(); } if (PackingName_T == "") { PackingName_T = p.TrafficPackaging.ToString(); } if (p.ConvertFactor == 0) { p.ConvertFactor = 1; } ConvertFactor = p.ConvertFactor; Quantity_T = Quantity / p.ConvertFactor; Quantity_P = Quantity % p.ConvertFactor; }
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(); } }