protected void bt_Approve_Click(object sender, EventArgs e) { int ID = ViewState["ID"] != null && int.TryParse(ViewState["ID"].ToString(), out ID) ? ID : 0; CM_VehicleBLL _VehicleBLL = new CM_VehicleBLL(ID); if (ID == 0 || _VehicleBLL.Model == null | _VehicleBLL.Model.ApproveFlag == 1) { MessageBox.Show(Page, "审核失败"); return; } CM_WareHouseBLL _WareHouseBLL = new CM_WareHouseBLL(); _WareHouseBLL.Model.Client = (int)Session["OwnerClient"]; _WareHouseBLL.Model.Code = _VehicleBLL.Model.VehicleNo; _WareHouseBLL.Model.Name = _VehicleBLL.Model.VehicleNo + "-仓库"; _WareHouseBLL.Model.OfficialCity = new CM_ClientBLL((int)Session["OwnerClient"]).Model.OfficialCity; _WareHouseBLL.Model.Classify = 3; //车仓库 _WareHouseBLL.Model.RelateVehicle = ID; _WareHouseBLL.Model.ActiveState = 1; _WareHouseBLL.Model.InsertStaff = (int)Session["UserID"]; int warehouse = _WareHouseBLL.Add(); if (warehouse > 0) { _VehicleBLL.Model.RelateWareHouse = warehouse; _VehicleBLL.Model.ApproveFlag = 1; _VehicleBLL.Model.UpdateStaff = (int)Session["UserID"]; _VehicleBLL.Update(); MessageBox.ShowAndRedirect(this, "审核成功!", "VehicleList.aspx"); } }
private void BindData() { CM_Vehicle m = new CM_VehicleBLL((int)ViewState["ID"]).Model; if (m != null) { if (m.Client != (int)Session["OwnerClient"]) { Response.Redirect("~/SubModule/Desktop.aspx"); } pl_detail.BindData(m); if (m.ApproveFlag == 1) { bt_Approve.Visible = false; } foreach (Org_Staff staff in CM_VehicleInStaffBLL.GetStaffByVehicle(m.ID)) { ListItem item = cbx_Staff.Items.FindByValue(staff.ID.ToString()); if (item != null) { item.Selected = true; } } } }
protected void ddl_DeliveryVehicle_SelectedIndexChanged(object sender, EventArgs e) { int vehicle = 0; int.TryParse(ddl_DeliveryVehicle.SelectedValue, out vehicle); if (vehicle != 0) { CM_VehicleBLL v = new CM_VehicleBLL(vehicle); CM_WareHouse w = v.GetRelateWareHouse(); ddl_SupplierWareHouse.Items.Clear(); if (w != null) { ddl_SupplierWareHouse.Items.Add(new ListItem(w.Name, w.ID.ToString())); } } else { ddl_SupplierWareHouse.DataSource = CM_WareHouseBLL.GetByClient((int)Session["OwnerClient"]).Where(p => p.Classify == 1); ddl_SupplierWareHouse.DataBind(); } }
/// <summary> /// 汇总预售待送货列表 /// </summary> /// <param name="User"></param> /// <param name="TDP"></param> /// <param name="Vehicle"></param> /// <param name="BeginDate"></param> /// <param name="EndDate"></param> /// <returns></returns> public static List<DicDataItem> GetNeedDeliverySummary(UserInfo User, int TDP, int Vehicle, DateTime BeginDate, DateTime EndDate) { LogWriter.WriteLog("PBMIFService.GetNeedDeliverySummary:UserName="******",Vehicle=" + Vehicle.ToString() + ",TDP=" + TDP.ToString() + ",BeginDate=" + BeginDate.ToString("yyyy-MM-dd") + ",EndDate=" + EndDate.ToString("yyyy-MM-dd")); if (User.OwnerType == 3) TDP = User.ClientID; int warehouse = 0; if (Vehicle > 0) { warehouse = new CM_VehicleBLL(Vehicle).Model.RelateWareHouse; } DataTable dt = PBM_DeliveryBLL.GetNeedDeliverySummary(BeginDate, EndDate, TDP, warehouse, 0, User.StaffID); List<DicDataItem> list = new List<DicDataItem>(dt.Rows.Count); for (int i = 0; i < dt.Rows.Count; i++) { DataRow dr = dt.Rows[i]; string remark = ""; if ((int)dr["Quantity_T"] != 0) { remark += dr["Quantity_T"].ToString() + dr["Packagint_T"].ToString(); } if ((int)dr["Quantity_P"] != 0) { remark += dr["Quantity_P"].ToString() + dr["Packagint_P"].ToString(); } remark += " 重量:" + dr["Weight"].ToString() + "Kg"; list.Add(new DicDataItem((int)dr["Product"], dr["ProductName"].ToString(), dr["Quantity"].ToString(), remark)); } return list; }
/// <summary> /// 获取指定车辆的仓库库存 /// </summary> /// <param name="UserInfo"></param> /// <param name="VehicleID"></param> /// <param name="DisplayMode">1:按产品查询库存 2:按批号查询库存</param> /// <returns></returns> public static List<Inventory> GetInventoryByVehicle(UserInfo User, int VehicleID, int DisplayMode) { LogWriter.WriteLog("PBMIFService.GetInventoryByVehicle:UserName="******",VehicleID=" + VehicleID.ToString() + ",IsMergeByProduct=" + DisplayMode.ToString()); CM_Vehicle v = new CM_VehicleBLL(VehicleID).Model; if (v == null) return null; //车辆ID无效 if (v.RelateWareHouse == 0) return null; //车辆关联仓库无效 return GetInventoryByWareHouse(User, v.RelateWareHouse, DisplayMode); }
/// <summary> /// 移库调拨申请 /// </summary> /// <param name="User"></param> /// <param name="DeliveryInfo">移库单信息</param> /// <param name="ErrorInfo">出错消息</param> /// <returns></returns> public static int TransWithVehicle(UserInfo User, Delivery DeliveryInfo, out string ErrorInfo) { ErrorInfo = ""; LogWriter.WriteLog("PBMIFService.TransWithVehicle:UserName="******",DeliveryInfo=" + JsonConvert.SerializeObject(DeliveryInfo)); //经销商级人员,供货商只能是自己所属的经销商 if (User.OwnerType == 3) { DeliveryInfo.Supplier = User.ClientID; DeliveryInfo.Client = User.ClientID; } if (DeliveryInfo.Classify != 5 && DeliveryInfo.Classify != 6) { ErrorInfo = "单据类别无效"; return -1; } #region 根据车辆设置调入或调出车仓库 //如果有送货车辆,默认出货仓库为该车辆所关联仓库 if (DeliveryInfo.DeliveryVehicle != 0) { CM_Vehicle v = new CM_VehicleBLL(DeliveryInfo.DeliveryVehicle).Model; if (v == null) { ErrorInfo = "送货车辆无效!"; return -1; } if (DeliveryInfo.Classify == 5) { //车销移库 DeliveryInfo.ClientWareHouse = v.RelateWareHouse; } else if (DeliveryInfo.Classify == 6) { //车销退库 DeliveryInfo.SupplierWareHouse = v.RelateWareHouse; } } #endregion //默认业务人员为当前员工 if (DeliveryInfo.SalesMan == 0) DeliveryInfo.SalesMan = User.StaffID; #region 必填字段校验 if (DeliveryInfo.Supplier == 0 && DeliveryInfo.SupplierWareHouse != 0) { DeliveryInfo.Supplier = new CM_WareHouseBLL(DeliveryInfo.SupplierWareHouse).Model.Client; } if (DeliveryInfo.Supplier == 0) { ErrorInfo = "无效的客户!"; return -2; } if (DeliveryInfo.SupplierWareHouse == 0) { ErrorInfo = "无效的调出仓库!"; return -2; } if (DeliveryInfo.Client == 0) { DeliveryInfo.Client = DeliveryInfo.Supplier; } if (DeliveryInfo.ClientWareHouse == 0) { ErrorInfo = "无效的调入仓库!"; return -2; } if (DeliveryInfo.Items == null || DeliveryInfo.Items.Count == 0) { ErrorInfo = "无调拨产品明细!"; return -10; } #endregion PBM_DeliveryBLL bll = new PBM_DeliveryBLL(); #region 保存发货单头信息 bll.Model.SheetCode = ""; bll.Model.Supplier = DeliveryInfo.Supplier; bll.Model.SupplierWareHouse = DeliveryInfo.SupplierWareHouse; bll.Model.Client = DeliveryInfo.Client; bll.Model.ClientWareHouse = DeliveryInfo.ClientWareHouse; bll.Model.Classify = DeliveryInfo.Classify; //5:车销移库 6:车销退库 bll.Model.SalesMan = User.StaffID; bll.Model.PrepareMode = 1; //1:快捷模式 bll.Model.State = 1; //默认制单状态 bll.Model.DeliveryVehicle = DeliveryInfo.DeliveryVehicle; bll.Model.Remark = DeliveryInfo.Remark; bll.Model.ApproveFlag = 2; bll.Model.InsertStaff = User.StaffID; #endregion #region 循环处理每个发货单明细 foreach (Delivery.DeliveryDetail item in DeliveryInfo.Items) { if (item.Product == 0) continue; if (item.DeliveryQuantity <= 0 && item.SignInQuantity <= 0) continue; string lotnumber = item.LotNumber.Trim(); int quantity = item.DeliveryQuantity <= 0 ? item.SignInQuantity : item.DeliveryQuantity; PDT_ProductBLL productbll = new PDT_ProductBLL(item.Product); if (productbll.Model == null) { ErrorInfo = "无效产品项,产品ID:" + item.Product; return -11; } PDT_ProductExtInfo extinfo = productbll.GetProductExtInfo(bll.Model.Supplier); if (productbll.Model == null) { ErrorInfo = "产品不在销售商的经营目录中," + productbll.Model.FullName; return -11; } //判断库存是否够销售 int inv_quantity = INV_InventoryBLL.GetProductQuantity(bll.Model.SupplierWareHouse, item.Product, lotnumber); if (quantity > inv_quantity) { ErrorInfo = "产品[" + productbll.Model.FullName + "]库存不足,当前库存:" + inv_quantity.ToString(); return -11; } #region 新增库存明细 PBM_DeliveryDetail d = new PBM_DeliveryDetail(); d.Product = item.Product; d.LotNumber = lotnumber; d.SalesMode = item.SalesMode == 0 ? 1 : item.SalesMode; //默认为“销售” d.Price = extinfo.SalesPrice; //默认销售价 d.DiscountRate = 1; d.ConvertFactor = productbll.Model.ConvertFactor == 0 ? 1 : productbll.Model.ConvertFactor; d.DeliveryQuantity = quantity; d.SignInQuantity = d.DeliveryQuantity; d.Remark = item.Remark; bll.Items.Add(d); #endregion } #endregion //计算折扣金额 bll.Model.DiscountAmount = 0; bll.Model.WipeAmount = 0; //计算实际销售金额 bll.Model.ActAmount = Math.Round(bll.Items.Sum(p => Math.Round(p.Price * p.ConvertFactor, 2) * p.SignInQuantity / p.ConvertFactor), 2); int ret = bll.Add(); if (ret <= 0) { ErrorInfo = "销售单保存失败!"; return ret; } return ret; }
/// <summary> /// 验证销售单,当在执行预售送货时,或在收款单变更了销售单明细时,需要调用此接口更新销售单 /// </summary> /// <param name="User"></param> /// <param name="DeliveryInfo"></param> /// <param name="ErrorInfo"></param> /// <returns></returns> public static int SaleOut_Update(UserInfo User, Delivery DeliveryInfo, out string ErrorInfo) { ErrorInfo = ""; LogWriter.WriteLog("PBMIFService.SaleOut_Update:UserName="******",DeliveryInfo=" + JsonConvert.SerializeObject(DeliveryInfo)); if (DeliveryInfo.ID == 0) { ErrorInfo = "销售单不存在,请先新增销售单!"; return -1; } PBM_DeliveryBLL bll = new PBM_DeliveryBLL(DeliveryInfo.ID); if (bll.Model == null) { ErrorInfo = "销售单不存在,请先新增销售单!"; return -1; } if (bll.Model.State > 3 || bll.Model.ApproveFlag == 1) { ErrorInfo = "销售单状态不允许执行此操作!"; return -1; } if (bll.Model.Supplier == 0) bll.Model.Supplier = DeliveryInfo.Supplier; if (bll.Model.Client == 0) bll.Model.Client = DeliveryInfo.Client; //如果有送货车辆,默认出货仓库为该车辆所关联仓库 if (DeliveryInfo.DeliveryVehicle != 0 && DeliveryInfo.SupplierWareHouse == 0) { CM_Vehicle v = new CM_VehicleBLL(DeliveryInfo.DeliveryVehicle).Model; if (v == null) { ErrorInfo = "送货车辆无效!"; return -1; } DeliveryInfo.SupplierWareHouse = v.RelateWareHouse; } //默认业务人员为当前员工 if (DeliveryInfo.SalesMan == 0) DeliveryInfo.SalesMan = User.StaffID; #region 必填字段校验 if (bll.Model.Supplier == 0) { ErrorInfo = "无效的供货客户!"; return -2; } if (User.OwnerType == 3 && bll.Model.Supplier != User.ClientID) { ErrorInfo = "无效的供货客户!"; return -2; } if (bll.Model.Client == 0) { ErrorInfo = "无效的购买客户!"; return -2; } if (DeliveryInfo.SupplierWareHouse == 0) { ErrorInfo = "无效的供货仓库!"; return -2; } if (DeliveryInfo.Items == null || DeliveryInfo.Items.Count == 0) { ErrorInfo = "无销售产品明细!"; return -10; } #endregion #region 保存销售单头信息 bll.Model.SalesMan = DeliveryInfo.SalesMan; bll.Model.DeliveryVehicle = DeliveryInfo.DeliveryVehicle; bll.Model.SupplierWareHouse = DeliveryInfo.SupplierWareHouse; bll.Model.WipeAmount = DeliveryInfo.WipeAmount; bll.Model.WorkList = DeliveryInfo.WorkList; bll.Model.Remark = DeliveryInfo.Remark; #endregion #region 循环处理每个订单明细 foreach (Delivery.DeliveryDetail item in DeliveryInfo.Items) { if (item.Product == 0) continue; if (item.DeliveryQuantity <= 0 && item.SignInQuantity <= 0) { if (item.DetailID == 0) continue; else bll.DeleteDetail(item.DetailID); } string lotnumber = item.LotNumber.Trim(); int quantity = 0; if (bll.Model.State == 1) quantity = item.DeliveryQuantity == 0 ? item.SignInQuantity : item.DeliveryQuantity; else quantity = item.SignInQuantity; string remark = item.Remark; PDT_ProductBLL productbll = new PDT_ProductBLL(item.Product); if (productbll.Model == null) { ErrorInfo = "无效产品项,产品ID:" + item.Product; return -11; } PDT_ProductExtInfo extinfo = productbll.GetProductExtInfo(bll.Model.Supplier); if (productbll.Model == null) { ErrorInfo = "产品不在销售商的经营目录中," + productbll.Model.FullName; return -11; } if (bll.Model.Classify != 2) { //不为退货单时,判断车库存是否够销售 int inv_quantity = INV_InventoryBLL.GetProductQuantity(bll.Model.SupplierWareHouse, item.Product, lotnumber); if (quantity > inv_quantity) { ErrorInfo = "产品[" + productbll.Model.FullName + "]库存不足,当前库存:" + inv_quantity.ToString(); return -11; } } if (item.DetailID > 0) { PBM_DeliveryDetail d = bll.GetDetailModel(item.DetailID); if (bll.Model.State == 1) d.DeliveryQuantity = quantity; d.SignInQuantity = item.SignInQuantity; d.LotNumber = lotnumber; d.Remark = item.Remark; bll.UpdateDetail(d); } else { #region 新增商品明细品项 PBM_DeliveryDetail d = new PBM_DeliveryDetail(); d.Product = item.Product; d.LotNumber = lotnumber; d.SalesMode = item.SalesMode == 0 ? 1 : item.SalesMode; //默认为“销售” d.Price = PDT_StandardPriceBLL.GetSalePrice(bll.Model.Client, bll.Model.Supplier, d.Product); if (d.SalesMode == 1) d.DiscountRate = (item.DiscountRate <= 0 || item.DiscountRate > 1) ? 1 : item.DiscountRate; else d.DiscountRate = 0; d.ConvertFactor = productbll.Model.ConvertFactor == 0 ? 1 : productbll.Model.ConvertFactor; d.DeliveryQuantity = item.DeliveryQuantity; d.SignInQuantity = d.DeliveryQuantity; d.Remark = item.Remark; bll.AddDetail(d); #endregion } } #endregion //计算折扣金额 bll.Model.DiscountAmount = bll.Items.Sum(p => (1 - p.DiscountRate) * Math.Round(p.Price * p.ConvertFactor, 2) * p.SignInQuantity / p.ConvertFactor); //计算实际销售金额 bll.Model.ActAmount = Math.Round((bll.Model.Classify == 2 ? -1 : 1) * bll.Items.Sum(p => p.DiscountRate * Math.Round(p.Price * p.ConvertFactor, 2) * p.SignInQuantity / p.ConvertFactor) - bll.Model.WipeAmount, 2); int ret = bll.Update(); if (ret < 0) { ErrorInfo = "销售单保存失败!"; return ret; } return 0; }
/// <summary> /// 新增销售发货单 /// </summary> /// <param name="User"></param> /// <param name="DeliveryInfo">发货单信息</param> /// <param name="ErrorInfo">出错消息</param> /// <returns></returns> public static int SaleOut_Add(UserInfo User, Delivery DeliveryInfo, out string ErrorInfo) { ErrorInfo = ""; LogWriter.WriteLog("PBMIFService.SaleOut_Add:UserName="******",DeliveryInfo=" + JsonConvert.SerializeObject(DeliveryInfo)); //经销商级人员,供货商只能是自己所属的经销商 if (User.OwnerType == 3) DeliveryInfo.Supplier = User.ClientID; //如果有送货车辆,默认出货仓库为该车辆所关联仓库 if (DeliveryInfo.DeliveryVehicle != 0 && DeliveryInfo.SupplierWareHouse == 0) { CM_Vehicle v = new CM_VehicleBLL(DeliveryInfo.DeliveryVehicle).Model; if (v == null) { ErrorInfo = "送货车辆无效!"; return -1; } DeliveryInfo.SupplierWareHouse = v.RelateWareHouse; } //默认业务人员为当前员工 if (DeliveryInfo.SalesMan == 0) DeliveryInfo.SalesMan = User.StaffID; #region 必填字段校验 if (DeliveryInfo.Supplier == 0) { ErrorInfo = "无效的供货客户!"; return -2; } if (DeliveryInfo.Client == 0) { ErrorInfo = "无效的购买客户!"; return -2; } if (DeliveryInfo.SupplierWareHouse == 0) { ErrorInfo = "无效的供货仓库!"; return -2; } if (DeliveryInfo.Items == null || DeliveryInfo.Items.Count == 0) { ErrorInfo = "无销售产品明细!"; return -10; } #endregion PBM_DeliveryBLL bll = new PBM_DeliveryBLL(); #region 保存销售单头信息 bll.Model.SheetCode = ""; bll.Model.Supplier = DeliveryInfo.Supplier; bll.Model.SupplierWareHouse = DeliveryInfo.SupplierWareHouse; bll.Model.Client = DeliveryInfo.Client; bll.Model.SalesMan = DeliveryInfo.SalesMan; bll.Model.Classify = (DeliveryInfo.Classify == 0 ? 1 : DeliveryInfo.Classify); //默认销售单 bll.Model.PrepareMode = (DeliveryInfo.PrepareMode == 0 ? 2 : DeliveryInfo.PrepareMode); //默认车销模式 bll.Model.State = 1; //默认制单状态 bll.Model.StandardPrice = DeliveryInfo.StandardPrice; bll.Model.OrderId = DeliveryInfo.OrderID; bll.Model.WipeAmount = DeliveryInfo.WipeAmount; bll.Model.DeliveryVehicle = DeliveryInfo.DeliveryVehicle; bll.Model.WorkList = DeliveryInfo.WorkList; bll.Model.Remark = DeliveryInfo.Remark; bll.Model.ApproveFlag = 2; bll.Model.InsertStaff = User.StaffID; #endregion #region 循环处理每个订单明细 foreach (Delivery.DeliveryDetail item in DeliveryInfo.Items) { if (item.Product == 0) continue; if (item.DeliveryQuantity <= 0 && item.SignInQuantity <= 0) continue; string lotnumber = item.LotNumber.Trim(); int deliveryquantity = item.DeliveryQuantity <= 0 ? item.SignInQuantity : item.DeliveryQuantity; PDT_ProductBLL productbll = new PDT_ProductBLL(item.Product); if (productbll.Model == null) { ErrorInfo = "无效产品项,产品ID:" + item.Product; return -11; } PDT_ProductExtInfo extinfo = productbll.GetProductExtInfo(bll.Model.Supplier); if (productbll.Model == null) { ErrorInfo = "产品不在销售商的经营目录中," + productbll.Model.FullName; return -11; } if (bll.Model.Classify != 2) { //不为退货单时,判断车库存是否够销售 int inv_quantity = INV_InventoryBLL.GetProductQuantity(bll.Model.SupplierWareHouse, item.Product, lotnumber); if (deliveryquantity > inv_quantity) { ErrorInfo = "产品[" + productbll.Model.FullName + "]库存不足,当前库存:" + inv_quantity.ToString(); return -11; } } #region 新增销售明细 PBM_DeliveryDetail d = new PBM_DeliveryDetail(); d.Product = item.Product; d.LotNumber = lotnumber; d.SalesMode = item.SalesMode == 0 ? 1 : item.SalesMode; //默认为“销售” if (item.Price > 0) d.Price = item.Price; else d.Price = PDT_StandardPriceBLL.GetSalePrice(bll.Model.Client, bll.Model.Supplier, d.Product); //默认销售价 if (d.SalesMode == 1) d.DiscountRate = (item.DiscountRate <= 0 || item.DiscountRate > 1) ? 1 : item.DiscountRate; else d.DiscountRate = 0; //非销售时,0折销售 d.ConvertFactor = productbll.Model.ConvertFactor == 0 ? 1 : productbll.Model.ConvertFactor; d.DeliveryQuantity = deliveryquantity; d.SignInQuantity = d.DeliveryQuantity; d.Remark = item.Remark; bll.Items.Add(d); #endregion } #endregion //计算折扣金额 bll.Model.DiscountAmount = bll.Items.Sum(p => (1 - p.DiscountRate) * Math.Round(p.Price * p.ConvertFactor, 2) * p.DeliveryQuantity / p.ConvertFactor); //计算实际销售金额 bll.Model.ActAmount = Math.Round((bll.Model.Classify == 2 ? -1 : 1) * bll.Items.Sum(p => p.DiscountRate * Math.Round(p.Price * p.ConvertFactor, 2) * p.SignInQuantity / p.ConvertFactor) - bll.Model.WipeAmount, 2); int deliveryid = bll.Add(); if (deliveryid <= 0) { ErrorInfo = "销售单保存失败!"; return deliveryid; } #region 销售单直接完成 if (DeliveryInfo.State == 4 && DeliveryInfo.PayInfos != null && DeliveryInfo.PayInfos.Count > 0) { LogWriter.WriteLog("PBMIFService.SaleOut_Add:UserName="******",DeliveryID=" + deliveryid.ToString() + ",Auto submit order!"); int ret = SaleOut_Confirm(User, deliveryid, DeliveryInfo.WipeAmount, DeliveryInfo.PayInfos, out ErrorInfo); if (ret < 0) { LogWriter.WriteLog("PBMIFService.SaleOut_Add:UserName="******",DeliveryID=" + deliveryid.ToString() + ",Auto confirm failed!ErrorInfo=" + ErrorInfo); return ret; } } #endregion return deliveryid; }
private void FillModel(int DeliveryID) { PBM_DeliveryBLL bll = new PBM_DeliveryBLL(DeliveryID); if (bll.Model == null) { ID = -1; return; } PBM_Delivery m = bll.Model; ID = m.ID; SheetCode = m.SheetCode; Supplier = m.Supplier; SupplierWareHouse = m.SupplierWareHouse; ClientWareHouse = m.ClientWareHouse; Client = m.Client; SalesMan = m.SalesMan; DeliveryMan = m.DeliveryMan; Classify = m.Classify; PrepareMode = m.PrepareMode; State = m.State; StandardPrice = m.StandardPrice; OrderID = m.OrderId; DiscountAmount = m.DiscountAmount; WipeAmount = m.WipeAmount; ActAmount = m.ActAmount; DeliveryVehicle = m.DeliveryVehicle; PreArrivalDate = m.PreArrivalDate; LoadingTime = m.LoadingTime; DepartTime = m.DepartTime; ActArriveTime = m.ActArriveTime; InsertTime = m.InsertTime; WorkList = m.WorkList; ApproveFlag = m.ApproveFlag; Remark = m.Remark; //发货单明细 Items = new List<DeliveryDetail>(); foreach (PBM_DeliveryDetail item in bll.Items) { Items.Add(new DeliveryDetail(item)); } //付款信息列表 PayInfos = new List<DeliveryPayInfo>(); foreach (PBM_DeliveryPayInfo item in bll.GetPayInfoList()) { PayInfos.Add(new DeliveryPayInfo(item)); } #region 获取各字段ID对应的名称 if (Supplier > 0) { CM_Client c = new CM_ClientBLL(Supplier).Model; if (c != null) SupplierName = c.FullName; } if (Client > 0) { CM_Client c = new CM_ClientBLL(Client).Model; if (c != null) { ClientName = c.FullName; ClientAddress = c.DeliveryAddress == "" ? c.Address : c.DeliveryAddress; ClientLinkMan = c.LinkManName; ClientTeleNum = c.Mobile == "" ? c.TeleNum : c.Mobile; } } if (SupplierWareHouse > 0) { CM_WareHouse w = new CM_WareHouseBLL(SupplierWareHouse).Model; if (w != null) SupplierWareHouseName = w.Name; } if (ClientWareHouse > 0) { CM_WareHouse w = new CM_WareHouseBLL(ClientWareHouse).Model; if (w != null) ClientWareHouseName = w.Name; } if (SalesMan > 0) { Org_Staff s = new Org_StaffBLL(SalesMan).Model; if (s != null) SalesManName = s.RealName; } if (DeliveryMan > 0) { Org_Staff s = new Org_StaffBLL(DeliveryMan).Model; if (s != null) DeliveryManName = s.RealName; } if (StandardPrice > 0) { PDT_StandardPrice s = new PDT_StandardPriceBLL(StandardPrice).Model; if (s != null) StandardPriceName = s.Name; } if (DeliveryVehicle > 0) { CM_Vehicle v = new CM_VehicleBLL(DeliveryVehicle).Model; if (v != null) DeliveryVehicleName = v.VehicleNo; } #endregion #region 获取字典表名称 try { if (m.Classify > 0) { Dictionary_Data dic = DictionaryBLL.GetDicCollections("PBM_DeliveryClassify")[m.Classify.ToString()]; if (dic != null) ClassifyName = dic.Name; } if (m.PrepareMode > 0) { Dictionary_Data dic = DictionaryBLL.GetDicCollections("PBM_DeliveryPrepareMode")[m.PrepareMode.ToString()]; if (dic != null) PrepareModeName = dic.Name; } if (m.State > 0) { Dictionary_Data dic = DictionaryBLL.GetDicCollections("PBM_DeliveryState")[m.State.ToString()]; if (dic != null) StateName = dic.Name; } } catch (System.Exception err) { LogWriter.WriteLog("MCSFramework.WSI.Delivery", err); } #endregion }
protected void bt_OK_Click(object sender, EventArgs e) { CM_VehicleBLL _bll; if ((int)ViewState["ID"] != 0) { //修改 _bll = new CM_VehicleBLL((int)ViewState["ID"]); } else { //新增 _bll = new CM_VehicleBLL(); } pl_detail.GetData(_bll.Model); #region 判断必填项 if (_bll.Model.VehicleClassify == 0) { MessageBox.Show(Page, "车辆类别必选"); return; } if (_bll.Model.State == 0) { MessageBox.Show(Page, "车牌状态必选"); return; } #endregion if ((int)ViewState["ID"] != 0) { //修改 _bll.Model.UpdateStaff = (int)Session["UserID"]; if (_bll.Update() == 0) { } } else { //新增 _bll.Model.InsertStaff = (int)Session["UserID"]; _bll.Model.Client = (int)Session["OwnerClient"]; _bll.Model.ApproveFlag = 2; ViewState["ID"] = _bll.Add(); if ((int)ViewState["ID"] > 0) { } } if (_bll.Model.RelateStaff > 0) { ListItem item = cbx_Staff.Items.FindByValue(_bll.Model.RelateStaff.ToString()); if (item != null && !item.Selected) { item.Selected = true; } } foreach (ListItem item in cbx_Staff.Items) { IList <CM_VehicleInStaff> lists = CM_VehicleInStaffBLL.GetModelList("Vehicle=" + ViewState["ID"].ToString() + " AND Staff=" + item.Value); if (item.Selected) { if (lists.Count == 0) { CM_VehicleInStaffBLL b = new CM_VehicleInStaffBLL(); b.Model.Vehicle = (int)ViewState["ID"]; b.Model.Staff = int.Parse(item.Value); b.Model.InsertStaff = (int)Session["UserID"]; b.Add(); } } else { if (lists.Count > 0) { CM_VehicleInStaffBLL b = new CM_VehicleInStaffBLL(lists[0].ID); b.Delete(); } } } if (_bll.Model.ApproveFlag == 2) { Response.Redirect("VehicleDetail.aspx?ID=" + ViewState["ID"].ToString()); } else { Response.Redirect("VehicleList.aspx"); } }
protected void bt_OK_Click(object sender, EventArgs e) { CM_VehicleBLL _bll; if ((int)ViewState["ID"] != 0) { //修改 _bll = new CM_VehicleBLL((int)ViewState["ID"]); } else { //新增 _bll = new CM_VehicleBLL(); } pl_detail.GetData(_bll.Model); #region 判断必填项 if (_bll.Model.VehicleClassify == 0) { MessageBox.Show(Page, "车辆类别必选"); return; } if (_bll.Model.State == 0) { MessageBox.Show(Page, "车牌状态必选"); return; } #endregion if ((int)ViewState["ID"] != 0) { //修改 _bll.Model.UpdateStaff = (int)Session["UserID"]; if (_bll.Update() == 0) { } } else { //新增 _bll.Model.InsertStaff = (int)Session["UserID"]; _bll.Model.Client = (int)Session["OwnerClient"]; _bll.Model.ApproveFlag = 2; ViewState["ID"] = _bll.Add(); if ((int)ViewState["ID"] > 0) { } } if (_bll.Model.RelateStaff > 0) { ListItem item = cbx_Staff.Items.FindByValue(_bll.Model.RelateStaff.ToString()); if (item != null && !item.Selected) item.Selected = true; } foreach (ListItem item in cbx_Staff.Items) { IList<CM_VehicleInStaff> lists = CM_VehicleInStaffBLL.GetModelList("Vehicle=" + ViewState["ID"].ToString() + " AND Staff=" + item.Value); if (item.Selected) { if (lists.Count == 0) { CM_VehicleInStaffBLL b = new CM_VehicleInStaffBLL(); b.Model.Vehicle = (int)ViewState["ID"]; b.Model.Staff = int.Parse(item.Value); b.Model.InsertStaff = (int)Session["UserID"]; b.Add(); } } else { if (lists.Count > 0) { CM_VehicleInStaffBLL b = new CM_VehicleInStaffBLL(lists[0].ID); b.Delete(); } } } if (_bll.Model.ApproveFlag == 2) Response.Redirect("VehicleDetail.aspx?ID=" + ViewState["ID"].ToString()); else Response.Redirect("VehicleList.aspx"); }
private void BindData() { CM_Vehicle m = new CM_VehicleBLL((int)ViewState["ID"]).Model; if (m != null) { if (m.Client != (int)Session["OwnerClient"]) { Response.Redirect("~/SubModule/Desktop.aspx"); } pl_detail.BindData(m); if (m.ApproveFlag == 1) bt_Approve.Visible = false; foreach (Org_Staff staff in CM_VehicleInStaffBLL.GetStaffByVehicle(m.ID)) { ListItem item = cbx_Staff.Items.FindByValue(staff.ID.ToString()); if (item != null) item.Selected = true; } } }
/// <summary> /// 导入员工资料 /// </summary> /// <param name="TemplateID"></param> /// <param name="Staff"></param> /// <param name="StaffSheet"></param> /// <param name="State">3:成功 4:失败 5:部分成功</param> /// <returns></returns> //public string DoImportStaff(int TemplateID, int Client, ISheet StaffSheet, out int State) public string DoImportStaff(int TemplateID, int Client, ISheet Sheet, out int State) { string ImportInfo = "【员工资料】Excel表:"; State = 0; IPT_UploadTemplateBLL _template = new IPT_UploadTemplateBLL(TemplateID); List<string> listPDT = new List<string>() { "序号", "姓名", "职务", "手机号码", "关联车号", "身份证号" }; DataTable dt = null; bool flag = VertifySheet(Sheet, listPDT, out dt, ref ImportInfo); if (!flag) { State = 4; return ImportInfo; } foreach (DataRow dr in dt.Rows)//循环导入数据 { try { string _staffName = dr["姓名"].ToString(); IList<Org_Staff> _listStaff = Org_StaffBLL.GetStaffList(" Dimission=1 AND OwnerClient=" + _template.Model.ClientID.ToString() + " AND RealName='" + _staffName + "'"); if (_listStaff != null && _listStaff.Count > 0) { ImportInfo += string.Format("导入序列号为{0},名字为{1}的数据行时与现有员工名字重复,跳过此行\r\n", dr["序号"].ToString(), _staffName); continue; } int _staffPosition = 0; string _strStaffPosition = dr["职务"].ToString(); string _staffPhone = dr["手机号码"].ToString(); string _staffIDCode = dr["身份证号"].ToString(); if (!string.IsNullOrEmpty(_strStaffPosition))//无职位默认为业代 { IList<Org_Position> _listPosition = Org_PositionBLL.GetModelList(" Name='" + _strStaffPosition + "'"); if (_listPosition != null && _listPosition.Count > 0) _staffPosition = _listPosition[0].ID; } else { _staffPosition = 1030; } Org_StaffBLL _bllStaff = new Org_StaffBLL(); CM_ClientBLL c = new CM_ClientBLL(_template.Model.ClientID); CM_ClientManufactInfo manufactinfo = c.GetManufactInfo(); if (c != null && manufactinfo != null) { _bllStaff.Model.OrganizeCity = manufactinfo.OrganizeCity; _bllStaff.Model.OfficialCity = c.Model.OfficialCity; } _bllStaff.Model.RealName = _staffName; _bllStaff.Model.Position = _staffPosition; _bllStaff.Model.Mobile = _staffPhone; _bllStaff.Model.TeleNum = _staffPhone; _bllStaff.Model.IDCode = _staffIDCode; _bllStaff.Model.InsertStaff = _template.Model.InsertStaff; _bllStaff.Model.OwnerClient = _template.Model.ClientID; _bllStaff.Model.OwnerType = 3; _bllStaff.Model.Dimission = 1; _bllStaff.Model.ApproveFlag = 1; int _ClientID = _bllStaff.Add();//当前员工ID //创建默认员工线路 if (_ClientID > 0) { if (_bllStaff.Model.Position == 1030)//业待创建默认路线 { VST_RouteBLL routebll = new VST_RouteBLL(); routebll.Model.Code = "R" + _ClientID.ToString(); routebll.Model.Name = "线路-" + _bllStaff.Model.RealName; routebll.Model.RelateStaff = _ClientID; routebll.Model.OrganizeCity = _bllStaff.Model.OrganizeCity; routebll.Model.OwnerClient = _template.Model.ClientID; routebll.Model.OwnerType = 3; routebll.Model.ApproveFlag = 1; routebll.Model.EnableFlag = "Y"; routebll.Model.InsertStaff = _template.Model.InsertStaff; routebll.Add(); } if (_bllStaff.Model.Position == 1030 || _bllStaff.Model.Position == 1050)//只有业待和司机能关联车号 { #region 获取车号ID int _staffCar = 0; string _strStaffCar = dr["关联车号"].ToString(); if (!string.IsNullOrEmpty(_strStaffCar)) { IList<CM_Vehicle> _listVehicles = CM_VehicleBLL.GetModelList("Client=" + _template.Model.ClientID + " AND VehicleNo='" + _strStaffPosition + "' "); if (_listVehicles != null && _listVehicles.Count > 0) _staffCar = _listVehicles[0].ID; else { CM_VehicleBLL vehicle = new CM_VehicleBLL(); vehicle.Model.Client = _template.Model.ClientID; vehicle.Model.VehicleNo = _strStaffCar; vehicle.Model.State = 1; vehicle.Model.Remark = "新导入未确认"; vehicle.Model.VehicleClassify = 2; _staffCar = vehicle.Add(); } } #endregion if (_staffCar > 0)//关联车号 { IList<CM_VehicleInStaff> _listVehicleInStaff = CM_VehicleInStaffBLL.GetModelList("Vehicle=" + _staffCar.ToString() + " AND Staff=" + _ClientID.ToString()); if (_listVehicleInStaff == null || _listVehicleInStaff.Count == 0) { CM_VehicleInStaffBLL vehicle_staff = new CM_VehicleInStaffBLL(); vehicle_staff.Model.Staff = _ClientID; vehicle_staff.Model.Vehicle = _staffCar; vehicle_staff.Model.InsertStaff = _template.Model.InsertStaff; vehicle_staff.Add(); } } } } } 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; }
/** *返回状态 3:成功 4:失败 5:部分成功 */ #region 1.导入员工资料,废弃不用 /// <summary> /// 导入员工资料 /// </summary> /// <param name="TemplateID"></param> /// <param name="Staff"></param> /// <param name="StaffSheet"></param> /// <param name="State">3:成功 4:失败 5:部分成功</param> /// <returns></returns> //public string DoImportStaff(int TemplateID, int Client, ISheet StaffSheet, out int State) public string DoImportStaff(int TemplateID, int Client, ISheet Sheet, out int State) { string ImportInfo = "【员工资料】Excel表:"; State = 0; IPT_UploadTemplateBLL _template = new IPT_UploadTemplateBLL(TemplateID); List <string> listPDT = new List <string>() { "序号", "姓名", "职务", "手机号码", "关联车号", "身份证号" }; DataTable dt = null; bool flag = VertifySheet(Sheet, listPDT, out dt, ref ImportInfo); if (!flag) { State = 4; return(ImportInfo); } foreach (DataRow dr in dt.Rows)//循环导入数据 { try { string _staffName = dr["姓名"].ToString(); IList <Org_Staff> _listStaff = Org_StaffBLL.GetStaffList(" Dimission=1 AND OwnerClient=" + _template.Model.ClientID.ToString() + " AND RealName='" + _staffName + "'"); if (_listStaff != null && _listStaff.Count > 0) { ImportInfo += string.Format("导入序列号为{0},名字为{1}的数据行时与现有员工名字重复,跳过此行\r\n", dr["序号"].ToString(), _staffName); continue; } int _staffPosition = 0; string _strStaffPosition = dr["职务"].ToString(); string _staffPhone = dr["手机号码"].ToString(); string _staffIDCode = dr["身份证号"].ToString(); if (!string.IsNullOrEmpty(_strStaffPosition))//无职位默认为业代 { IList <Org_Position> _listPosition = Org_PositionBLL.GetModelList(" Name='" + _strStaffPosition + "'"); if (_listPosition != null && _listPosition.Count > 0) { _staffPosition = _listPosition[0].ID; } } else { _staffPosition = 1030; } Org_StaffBLL _bllStaff = new Org_StaffBLL(); CM_ClientBLL c = new CM_ClientBLL(_template.Model.ClientID); CM_ClientManufactInfo manufactinfo = c.GetManufactInfo(); if (c != null && manufactinfo != null) { _bllStaff.Model.OrganizeCity = manufactinfo.OrganizeCity; _bllStaff.Model.OfficialCity = c.Model.OfficialCity; } _bllStaff.Model.RealName = _staffName; _bllStaff.Model.Position = _staffPosition; _bllStaff.Model.Mobile = _staffPhone; _bllStaff.Model.TeleNum = _staffPhone; _bllStaff.Model.IDCode = _staffIDCode; _bllStaff.Model.InsertStaff = _template.Model.InsertStaff; _bllStaff.Model.OwnerClient = _template.Model.ClientID; _bllStaff.Model.OwnerType = 3; _bllStaff.Model.Dimission = 1; _bllStaff.Model.ApproveFlag = 1; int _ClientID = _bllStaff.Add();//当前员工ID //创建默认员工线路 if (_ClientID > 0) { if (_bllStaff.Model.Position == 1030)//业待创建默认路线 { VST_RouteBLL routebll = new VST_RouteBLL(); routebll.Model.Code = "R" + _ClientID.ToString(); routebll.Model.Name = "线路-" + _bllStaff.Model.RealName; routebll.Model.RelateStaff = _ClientID; routebll.Model.OrganizeCity = _bllStaff.Model.OrganizeCity; routebll.Model.OwnerClient = _template.Model.ClientID; routebll.Model.OwnerType = 3; routebll.Model.ApproveFlag = 1; routebll.Model.EnableFlag = "Y"; routebll.Model.InsertStaff = _template.Model.InsertStaff; routebll.Add(); } if (_bllStaff.Model.Position == 1030 || _bllStaff.Model.Position == 1050)//只有业待和司机能关联车号 { #region 获取车号ID int _staffCar = 0; string _strStaffCar = dr["关联车号"].ToString(); if (!string.IsNullOrEmpty(_strStaffCar)) { IList <CM_Vehicle> _listVehicles = CM_VehicleBLL.GetModelList("Client=" + _template.Model.ClientID + " AND VehicleNo='" + _strStaffPosition + "' "); if (_listVehicles != null && _listVehicles.Count > 0) { _staffCar = _listVehicles[0].ID; } else { CM_VehicleBLL vehicle = new CM_VehicleBLL(); vehicle.Model.Client = _template.Model.ClientID; vehicle.Model.VehicleNo = _strStaffCar; vehicle.Model.State = 1; vehicle.Model.Remark = "新导入未确认"; vehicle.Model.VehicleClassify = 2; _staffCar = vehicle.Add(); } } #endregion if (_staffCar > 0)//关联车号 { IList <CM_VehicleInStaff> _listVehicleInStaff = CM_VehicleInStaffBLL.GetModelList("Vehicle=" + _staffCar.ToString() + " AND Staff=" + _ClientID.ToString()); if (_listVehicleInStaff == null || _listVehicleInStaff.Count == 0) { CM_VehicleInStaffBLL vehicle_staff = new CM_VehicleInStaffBLL(); vehicle_staff.Model.Staff = _ClientID; vehicle_staff.Model.Vehicle = _staffCar; vehicle_staff.Model.InsertStaff = _template.Model.InsertStaff; vehicle_staff.Add(); } } } } } 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); }