/// <summary> /// 删除采购订单 /// </summary> /// <param name="showMsg"></param> private void DeletePurchaseOrder(bool showMsg) { ORD_PurchaseOrderParam param = new ORD_PurchaseOrderParam(); param.POGuid = poguid; ORD_PurchaseOrderResult rst = orderLogic.GetInfo(param); if (rst != null) { if (showMsg) { if (MessageBox.Show("请确认是否要删除采购单:【" + rst.BillNo + "】", "操作提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { WCFAddUpdateResult result = this.AsyncExecute <WCFAddUpdateResult, ORD_PurchaseOrderParam>( param, orderLogic.DelInfo, a => { SearchPO(1); }); } } else { WCFAddUpdateResult result = this.AsyncExecute <WCFAddUpdateResult, ORD_PurchaseOrderParam>( param, orderLogic.DelInfo, a => { SearchPO(1); }); } } else { this.ShowMessage("请选择需要删除的采购明细!"); } }
/// <summary> /// 删除实体 /// </summary> /// <param name="param">删除条件实体</param> /// <returns></returns> public WCFAddUpdateResult DelInfo(ORD_PurchaseOrderParam param) { this.CheckSession(); WCFAddUpdateResult ret = new WCFAddUpdateResult(); int affect = 0; try { #region 判断 if (param.POGuid == null) { throw new WarnException("请指定要删除的采购单ID!"); } #endregion WhereClip whereClip = GetWhereClip(param); ORD_PurchaseOrderResult info = new ORD_PurchaseOrderResult(); info.IsDeleted = true; affect = this.Update <ORD_PurchaseOrderResult>(info, whereClip); #region 设置返回值 ret.Key = affect; #endregion } catch (WarnException exp) { throw exp; } catch (System.Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); throw exp; } return(ret); }
public bool AuditPurchaseOrderBill(ORD_PurchaseOrderParam param) { bool ret = true; ExeResult rst = new ExeResult(); rst = this.Execute("ZNLCRM.BLL.PPM.ORD_PurchaseOrderBLL", "AuditPurchaseOrderBill", param); ret = (rst == null ? false : (bool)rst.Result); return(ret); }
/// <summary> /// 明细查询 /// </summary> /// <param name="pgIndex"></param> public void SearchDtl(int pgIndex) { ORD_PurchaseOrderParam param = new ORD_PurchaseOrderParam(); param = this.ConvertControlToEntity <ORD_PurchaseOrderParam>(this.panDtlWhere.Controls, param, null); param.PageIndex = pgIndex; param.PageSize = 10; BindDataGridView(dgvDtl, pagDtl, param, true); }
public WCFAddUpdateResult DelInfo(ORD_PurchaseOrderParam param) { WCFAddUpdateResult ret = new WCFAddUpdateResult(); ExeResult rst = new ExeResult(); rst = this.Execute("ZNLCRM.BLL.PPM.ORD_PurchaseOrderBLL", "DelInfo", param); ret = (rst == null ? new WCFAddUpdateResult() : rst.Result as WCFAddUpdateResult); return(ret); }
public ORD_PurchaseOrderResult GetInfo(ORD_PurchaseOrderParam param) { ORD_PurchaseOrderResult ret = new ORD_PurchaseOrderResult(); ExeResult rst = new ExeResult(); rst = this.Execute("ZNLCRM.BLL.PPM.ORD_PurchaseOrderBLL", "GetInfo", param); ret = (rst == null ? new ORD_PurchaseOrderResult() : rst.Result as ORD_PurchaseOrderResult); return(ret); }
/// <summary> /// 采集主单查询 /// </summary> public void SearchPO(int pgIndex) { ORD_PurchaseOrderParam param = new ORD_PurchaseOrderParam(); param = this.ConvertControlToEntity <ORD_PurchaseOrderParam>(this.panMastWhere.Controls, param, null); param.PageIndex = pgIndex; param.PageSize = 5; BindDataGridView(dgvPurchaseOrder, pgPurchaseOrder, param, false); }
public List <ORD_PurchaseOrderLineResult> GetLastHisstoryPrice(ORD_PurchaseOrderParam param) { List <ORD_PurchaseOrderLineResult> ret = new List <ORD_PurchaseOrderLineResult>(); ExeResult rst = new ExeResult(); rst = this.Execute("ZNLCRM.BLL.PPM.ORD_PurchaseOrderBLL", "GetLastHisstoryPrice", param); ret = (rst == null ? new List <ORD_PurchaseOrderLineResult>() : rst.Result as List <ORD_PurchaseOrderLineResult>); return(ret); }
/// <summary> /// 获取一条信息记录 /// </summary> /// <param name="param"></param> /// <returns></returns> public ORD_PurchaseOrderResult GetInfo(ORD_PurchaseOrderParam param) { this.CheckSession(); ORD_PurchaseOrderResult rst = new ORD_PurchaseOrderResult(); #region 判断 if (param.POGuid == null) { throw new WarnException("请指定采购单GUID!"); } #endregion #region 获取实体 rst = this.Select <ORD_PurchaseOrderResult>(GetWhereClip(param)); if (rst != null) { string[] statusArr = new string[] { rst.StkInStatus, rst.StkOutStatus, rst.ReturnStatus, rst.PaymentStatus }; rst.AllStatus = string.Join(",", statusArr); ORD_PurchaseOrderLineBLL lineBLL = new ORD_PurchaseOrderLineBLL(); lineBLL.SessionInfo = this.SessionInfo; rst.OrderLineList = lineBLL.GetList(new ORD_PurchaseOrderLineParam() { POGuid = rst.POGuid }); Guid?[] NoticeGuids = rst.OrderLineList.Where(a => a.NoticeGuid != null).Select(a => a.NoticeGuid).Distinct().ToArray(); ORD_PurchaseNoticeBLL noticeBLl = new ORD_PurchaseNoticeBLL(); noticeBLl.SessionInfo = this.SessionInfo; ORD_PurchaseNoticeParam noticeParam = new ORD_PurchaseNoticeParam(); noticeParam.NoticeGuids = NoticeGuids; List <ORD_PurchaseNoticeResult> noticeList = noticeBLl.GetList(noticeParam); foreach (ORD_PurchaseOrderLineResult lineResult in rst.OrderLineList) { ORD_PurchaseNoticeResult noticeResult = noticeList.FirstOrDefault(a => a.NoticeGuid == lineResult.NoticeGuid); if (noticeResult != null) { lineResult.SOLineCode = noticeResult.SOLineCode; lineResult.SOModel = noticeResult.Model; lineResult.SOBrand = noticeResult.Brand; lineResult.SOBatch = noticeResult.Batch; lineResult.SOPackage = noticeResult.Package; lineResult.SOQty = noticeResult.SaleQty; lineResult.SONeedDeliveryDate = noticeResult.NeedDeliveryDate; } } rst.HR_DepartmentResult = this.Select <HR_DepartmentResult>(new List <Field>() { HR_Department._.DeptID, HR_Department._.DeptName }, HR_Department._.DeptID == rst.PurDeptID); } #endregion return(rst); }
void InitForm(bool isMutiSelect, ORD_PurchaseOrderParam param) { InitializeComponent(); InitBaseSelectForm(isMutiSelect, this.dgvPurchaseOrder, this.chkAll, _idColName, _chkColName); orderLogic = new ORD_PurchaseOrderLogic(this); if (param != null) { _StkInOccStatusArr = param.StkInOccStatusArr; } }
/// <summary> /// 获取彩购订单明细分页数据 - 2015/03/10 W:LHQ /// </summary> /// <param name="param"></param> /// <returns></returns> public PageList <ORD_PurchaseOrderResult> GetDtlPageList(ORD_PurchaseOrderParam param) { ExeResult rst = new ExeResult(); rst = this.Execute("ZNLCRM.BLL.PPM.ORD_PurchaseOrderBLL", "GetDtlPageList", param); PageList <ORD_PurchaseOrderResult> pageList = new PageList <ORD_PurchaseOrderResult>(); pageList = (rst == null ? new PageList <ORD_PurchaseOrderResult>() : rst.Result as PageList <ORD_PurchaseOrderResult>); return(pageList); }
/// <summary> /// 分页集合 /// </summary> /// <param name="param"></param> /// <returns></returns> public PageList <ORD_PurchaseOrderResult> GetPageList(ORD_PurchaseOrderParam param) { this.CheckSession(); PageList <ORD_PurchaseOrderResult> ret = new PageList <ORD_PurchaseOrderResult>(); try { List <Field> field = new List <Field>() { Field.All }; ret = this.SelectList <ORD_PurchaseOrderResult>(param.PageIndex.GetValueOrDefault(1), param.PageSize.GetValueOrDefault(50), field, GetWhereClip(param), ORD_PurchaseOrder._.CreatedTime.Desc); if (ret.ResultList != null && ret.ResultList.Count > 0) { HR_OrgBLL orgBLL = new HR_OrgBLL(); orgBLL.SessionInfo = this.SessionInfo; HR_OrgParam orgParam = new HR_OrgParam(); orgParam.OrgIDs = ret.ResultList.Where(a => a.PurOrgID != null).Select(a => a.PurOrgID).Distinct().ToArray(); List <HR_OrgResult> orgList = orgBLL.GetOrgTree(orgParam); HR_DepartmentBLL deptBLL = new HR_DepartmentBLL(); deptBLL.SessionInfo = this.SessionInfo; HR_DepartmentParam deptParam = new HR_DepartmentParam(); deptParam.DeptIDs = ret.ResultList.Where(a => a.PurDeptID != null).Select(a => a.PurDeptID).Distinct().ToArray(); List <HR_DepartmentResult> deptList = deptBLL.GetDeptList(deptParam); HR_Org findOrg = null; HR_DepartmentResult findDept = null; foreach (ORD_PurchaseOrderResult orderResult in ret.ResultList) { findOrg = orgList.Find(a => a.OrgID == orderResult.PurOrgID); if (findOrg != null) { orderResult.PurOrgName = findOrg.OrgName; } findDept = deptList.Find(a => a.DeptID == orderResult.PurDeptID); if (findDept != null) { orderResult.PurDeptName = findDept.DeptName; } orderResult.AllStatus = orderResult.StkInStatus + "->" + orderResult.StkOutStatus; } } } catch (WarnException exp) { throw exp; } catch (System.Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); throw exp; } return(ret); }
public bool SubmitPurchaseOrderBill(ORD_PurchaseOrderParam param) { this.CheckSession(); bool submitFlag = true; try { ORD_PurchaseOrderResult orderResult = this.GetInfo(param); if (orderResult != null) { #region 判断是否可以提交 bool isAllowSubmit = true; if (orderResult.ApproveStatus == "待审核") { isAllowSubmit = false; throw new WarnException("采购单当前状态为:【已提交,待审核】,禁止重复提交!"); } else if (orderResult.ApproveStatus == "审核完成") { isAllowSubmit = false; throw new WarnException("采购单当前状态为:【审核完成】,撤单后才可以再次提交!"); } if (isAllowSubmit) { orderResult.Status = "Approve"; orderResult.ApproveStatus = "待审核"; WCFAddUpdateResult ret = this.AddOrUpdate(orderResult); if (ret.KeyGuid.ToGuid() == Guid.Empty) { submitFlag = false; } } #endregion } else { throw new WarnException("要提交的采购单在系统中不存在!"); } } catch (WarnException exp) { throw exp; } catch (Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); throw exp; } return(submitFlag); }
private void BindDataGridView(int pageIndex) { ORD_PurchaseOrderParam param = new ORD_PurchaseOrderParam(); param.PageIndex = pageIndex; param.PageSize = 100; param.SupplierID = SupplierID.ToInt32(); param.BillNo = txtBillNo.Text.Trim(); param.Status = "Complete"; param.StkInOccStatusArr = _StkInOccStatusArr; PageList <ORD_PurchaseOrderResult> lstRst = orderLogic.GetPageList(param); dgvPurchaseOrder.DataSource = lstRst.ResultList; pgPurchaseOrder.RecordCount = lstRst.TotalCount; this.SetDataSource <ORD_PurchaseOrderResult>(lstRst.ResultList); SetGridCheck(this.dgvPurchaseOrder, _idColName, _chkColName); }
/// <summary> /// 获取集合 /// </summary> /// <param name="param"></param> /// <returns></returns> public List <ORD_PurchaseOrderResult> GetList(ORD_PurchaseOrderParam param) { this.CheckSession(); List <ORD_PurchaseOrderResult> ret = new List <ORD_PurchaseOrderResult>(); try { WhereClip whereClip = GetWhereClip(param); ret = this.SelectList <ORD_PurchaseOrderResult>(whereClip, ORD_PurchaseOrder._.CreatedTime.Desc); } catch (WarnException exp) { throw exp; } catch (System.Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); throw exp; } return(ret); }
public bool AuditPurchaseOrderBill(ORD_PurchaseOrderParam param) { bool auditFlag = true; try { ORD_PurchaseOrderResult orderResult = this.GetInfo(param); if (orderResult != null) { bool isAllowAudit = true; if (orderResult.ApproveStatus == "待提交") { isAllowAudit = false; throw new WarnException("采购单当前状态为:【待提交】,请先提交!"); } else if (orderResult.ApproveStatus == "审核完成") { isAllowAudit = false; throw new WarnException("采购单当前状态为:【审核完成】,禁止重复审核!"); } if (isAllowAudit) { orderResult.Status = "Complete"; orderResult.ApproveStatus = "审核完成"; WCFAddUpdateResult ret = this.AddOrUpdate(orderResult); if (ret.KeyGuid.ToGuid() == Guid.Empty) { auditFlag = false; } else { #region 更新关联单据的相关数据(回写)和状态 //采购单关联的采购明细 List <ORD_PurchaseOrderLineResult> purLineList = orderResult.OrderLineList; if (purLineList != null && purLineList.Count > 0) { #region 定义相关变量(可重复使用) ORD_SalesOrderBLL saleOrderBLL = new ORD_SalesOrderBLL(); saleOrderBLL.SessionInfo = this.SessionInfo; ORD_SalesOrderLineBLL saleLineBLL = new ORD_SalesOrderLineBLL(); saleLineBLL.SessionInfo = this.SessionInfo; ORD_PurchaseNoticeBLL noticeBLL = new ORD_PurchaseNoticeBLL(); noticeBLL.SessionInfo = this.SessionInfo; ORD_PurchaseOrderLineBLL purLineBLL = new ORD_PurchaseOrderLineBLL(); purLineBLL.SessionInfo = this.SessionInfo; Guid?[] SOGuids = null; Guid?[] SOLineGuids = null; Guid?[] NoticeGuids = null; Guid?[] POGuids = null; Guid?[] effPOGuids = null; List <ORD_SalesOrderLineResult> saleLineList = null; List <ORD_PurchaseNoticeResult> noticeResultList = null; List <ORD_PurchaseOrderResult> purOrderList = null; List <ORD_PurchaseOrderLineResult> linkPurLineList = null; List <ORD_PurchaseOrderLineResult> effPurLineList = null; #endregion #region 更新采购通知的采购数量 //获取关联的所有的采购通知guid NoticeGuids = purLineList.Where(a => a.NoticeGuid != Guid.Empty && a.IsCancel != true).Select(a => a.NoticeGuid).Distinct().ToArray(); //获取关联的所有的采购通知信息 noticeResultList = noticeBLL.GetList(new ORD_PurchaseNoticeParam() { NoticeGuids = NoticeGuids }); if (noticeResultList != null && noticeResultList.Count > 0) { //采购单明细关联的采购通知所有关联的采购明细 linkPurLineList = purLineBLL.GetList(new ORD_PurchaseOrderLineParam() { NoticeGuids = NoticeGuids, IsCancel = false }); //获取采购单明细关联的POGuid POGuids = linkPurLineList.Select(a => a.POGuid).Distinct().ToArray(); //获取所有关联的采购主单 purOrderList = this.GetList(new ORD_PurchaseOrderParam() { POGuids = POGuids, Status = "Complete" }); if (purOrderList != null && purOrderList.Count > 0) { effPOGuids = purOrderList.Select(a => a.POGuid).Distinct().ToArray(); effPurLineList = linkPurLineList.Where(a => effPOGuids.Contains(a.POGuid)).ToList(); foreach (ORD_PurchaseNoticeResult noticeResult in noticeResultList) { int?qty = effPurLineList.Where(a => a.NoticeGuid == noticeResult.NoticeGuid).Sum(a => a.Qty.ToInt32()); noticeResult.PurchaseQty = qty; } } noticeBLL.UpdateOrInsertList(noticeResultList); } #endregion #region 更新销售明细的采购数量 // 有关联销售同时未取消的采购明细 SOLineGuids = purLineList.Where(a => a.SOLineGuid != null && a.IsCancel != true).Select(a => a.SOLineGuid).Distinct().ToArray(); if (SOLineGuids != null && SOLineGuids.Length > 0) { //采购明细关联的所有的销售明细(未取消) saleLineList = saleLineBLL.GetList(new ORD_SalesOrderLineParam() { SOLineGuids = SOLineGuids, IsCancel = false }); if (saleLineList != null && saleLineList.Count > 0) { //销售明细所关联的采购明细(未取消) linkPurLineList = purLineBLL.GetList(new ORD_PurchaseOrderLineParam() { SOLineGuids = SOLineGuids, IsCancel = false }); POGuids = linkPurLineList.Select(a => a.POGuid).Distinct().ToArray(); if (POGuids != null && POGuids.Length > 0) { //销售明细所关联的采购明细对应的采购主单 purOrderList = this.GetList(new ORD_PurchaseOrderParam() { POGuids = POGuids, Status = "Complete" }); if (purOrderList != null && purOrderList.Count > 0) { effPOGuids = purOrderList.Select(a => a.POGuid).Distinct().ToArray(); effPurLineList = linkPurLineList.Where(a => effPOGuids.Contains(a.POGuid)).ToList(); foreach (ORD_SalesOrderLineResult saleLineResult in saleLineList) { int?qty = effPurLineList.Where(a => a.SOLineGuid == saleLineResult.SOLineGuid).Sum(a => a.Qty.ToInt32()); saleLineResult.PurchaseQty = qty; } } } saleLineBLL.UpdateOrInsertList(saleLineList); SOGuids = saleLineList.Select(a => a.SOGuid).Distinct().ToArray(); foreach (Guid soguid in SOGuids) { saleOrderBLL.UpdateStatus(new ORD_SalesOrderParam() { SOGuid = soguid }); } } } #endregion } #endregion } } } else { throw new WarnException("要审核的采购单在系统中不存在!"); } } catch (WarnException exp) { throw exp; } catch (Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); throw exp; } return(auditFlag); }
/// <summary> ///获取彩购订单明细分页数据 - 2015/03/10 W:LHQ /// </summary> /// <param name="param"></param> /// <returns></returns> public PageList <ORD_PurchaseOrderResult> GetDtlPageList(ORD_PurchaseOrderParam param) { this.CheckSession(); PageList <ORD_PurchaseOrderResult> ret = new PageList <ORD_PurchaseOrderResult>(); try { #region 表字段 List <Field> field = new List <Field>() { ORD_PurchaseOrderLine._.Model.At("b").As("Model"), ORD_PurchaseOrderLine._.Brand.At("b").As("Brand") , ORD_PurchaseOrderLine._.Package.At("b").As("Package"), ORD_PurchaseOrderLine._.Batch.At("b").As("Batch") , ORD_PurchaseOrderLine._.MarkCode.At("b").As("MarkCode"), ORD_PurchaseOrderLine._.UnitPrice.At("b").As("UnitPrice") , ORD_PurchaseOrderLine._.NTaxPrice.At("b").As("NTaxPrice"), ORD_PurchaseOrderLine._.Qty.At("b").As("Qty") , ORD_PurchaseOrderLine._.NeedDeliveryDate.At("b").As("NeedDeliveryDate"), ORD_PurchaseOrderLine._.NeedPayAmtDate.At("b").As("NeedPayAmtDate") , ORD_PurchaseOrderLine._.CreatedEmpName.At("b").As("CreatedEmpName"), ORD_PurchaseOrderLine._.CreatedTime.At("b").As("CreatedTime") , ORD_PurchaseOrderLine._.StkInQty.At("b").As("StkInQty"), ORD_PurchaseOrderLine._.StkOutQty.At("b").As("StkOutQty") , ORD_PurchaseOrderLine._.ReturnQty.At("b").As("ReturnQty") , ORD_PurchaseOrderLine._.POLineGuid.At("b").As("POLineGuid"), ORD_PurchaseOrder._.Status, ORD_PurchaseOrder._.ApproveStatus, ORD_PurchaseOrder._.IsCancel, ORD_PurchaseOrder._.Amount , ORD_PurchaseOrder._.BillNo, ORD_PurchaseOrder._.PODate, ORD_PurchaseOrder._.BuyerName, ORD_PurchaseOrder._.Currency, ORD_PurchaseOrder._.TaxRate, ORD_PurchaseOrder._.POID, ORD_PurchaseOrder._.POGuid }; #endregion WhereClip onWhere = ORD_PurchaseOrder._.POGuid == ORD_PurchaseOrderLine._.POGuid.At("b") && ORD_PurchaseOrderLine._.IsDeleted.At("b") == 0;//明细删除状态 ret = this.SelectList <ORD_PurchaseOrderResult, ORD_PurchaseOrderLineResult>(JoinType.InnerJoin, onWhere, param.PageIndex.GetValueOrDefault(1), param.PageSize.GetValueOrDefault(50), field, GetWhereClip(param), ORD_PurchaseOrder._.CreatedTime.Desc, null, null); if (ret.ResultJoinList.Rows.Count > 0) { ret.ResultJoinList.Columns.Add("IsCancelName"); ret.ResultJoinList.Columns.Add("All_Status"); string s = ""; int StkInQty = 0; int StkOutQty = 0; int Qty = 0; int ReturnQty = 0; for (int i = 0; i < ret.ResultJoinList.Rows.Count; i++) { if (ret.ResultJoinList.Rows[i]["IsCancel"].ToString() == "True") { ret.ResultJoinList.Rows[i]["IsCancelName"] = "是"; } #region 状态判断 s = ""; StkInQty = ret.ResultJoinList.Rows[i]["StkInQty"].ToInt32(); StkOutQty = ret.ResultJoinList.Rows[i]["StkOutQty"].ToInt32(); Qty = ret.ResultJoinList.Rows[i]["Qty"].ToInt32(); ReturnQty = ret.ResultJoinList.Rows[i]["ReturnQty"].ToInt32(); if (StkInQty >= Qty) { s += "全部入库,"; } if (StkInQty > 0 && StkInQty < Qty) { s += "部分入库,"; } if (StkOutQty == Qty) { s += "全部出库,"; } if (StkOutQty > 0 && StkOutQty < Qty) { s += "部分出库,"; } if (StkInQty == 0 && Qty > 0) { s += "未入库,"; } if (StkOutQty == 0 && Qty > 0) { s += "待出库,"; } if (ReturnQty == 0 && StkInQty > 0) { s += "未退货"; } if (ReturnQty > 0 && ReturnQty < Qty) { s += "部分退货"; } if (ReturnQty >= Qty) { s += "全部退货"; } ret.ResultJoinList.Rows[i]["All_Status"] = s; #endregion } } } catch (WarnException exp) { throw exp; } catch (System.Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); throw exp; } return(ret); }
public frmSelectPurchaseOrder(bool isMutiSelect, ORD_PurchaseOrderParam param) { InitForm(isMutiSelect, param); }
/// <summary> /// 绑定表格,分页控件 /// </summary> /// <param name="dgv">表格控件</param> /// <param name="pg">分页控件</param> /// <param name="param">查询参数对象</param> /// <param name="isTable">是否返回DataTable</param> private void BindDataGridView(Controls.UcDataGridView dgv, Controls.UcPager pg, ORD_PurchaseOrderParam param, bool isTable) { PageList <ORD_PurchaseOrderResult> pageList = null; if (isTable) { pageList = this.AsyncExecute <PageList <ORD_PurchaseOrderResult>, ORD_PurchaseOrderParam>(param, orderLogic.GetDtlPageList, a => { dgv.DataSource = a.ResultJoinList; pg.PageSize = param.PageSize.ToInt32(); pg.RecordCount = a.TotalCount; }); } else { pageList = this.AsyncExecute <PageList <ORD_PurchaseOrderResult>, ORD_PurchaseOrderParam>(param, orderLogic.GetPageList, a => { dgv.DataSource = a.ResultList; pg.PageSize = param.PageSize.ToInt32(); pg.RecordCount = a.TotalCount; }); } }
/// <summary> /// 查询条件 /// </summary> /// <param name="param"></param> /// <returns></returns> WhereClip GetWhereClip(ORD_PurchaseOrderParam param) { this.CheckSession(); WhereClip where = ORD_PurchaseOrder._.IsDeleted == 0; if (param.POID > 0) { where = where && ORD_PurchaseOrder._.POID == param.POID; } if (param.POGuid != null) { where = where && ORD_PurchaseOrder._.POGuid == param.POGuid; } if (!string.IsNullOrEmpty(param.BillNo)) { where = where && ORD_PurchaseOrder._.BillNo.Like("%" + param.BillNo + "%"); } if (!string.IsNullOrEmpty(param.BillType)) { where = where && ORD_PurchaseOrder._.BillType == param.BillType; } if (!string.IsNullOrEmpty(param.SupplierName)) { where = where && ORD_PurchaseOrder._.SupplierName.Like("%" + param.SupplierName + "%"); } if (!string.IsNullOrEmpty(param.Contact)) { where = where && ORD_PurchaseOrder._.Contact.Like("%" + param.Contact + "%"); } if (!string.IsNullOrEmpty(param.ClearingForm)) { where = where && ORD_PurchaseOrder._.ClearingForm.Like("%" + param.ClearingForm + "%"); } if (!string.IsNullOrEmpty(param.BuyerName)) { where = where && ORD_PurchaseOrder._.BuyerName.Like("%" + param.BuyerName + "%"); } if (!string.IsNullOrEmpty(param.Status)) { if (param.Status.ToLower() == "new") { string[] tmpStatus = new String[2] { "", param.Status }; where = where && ORD_PurchaseOrder._.Status.IsNull("").In(tmpStatus); } else { where = where && ORD_PurchaseOrder._.Status == param.Status; } } if (!string.IsNullOrEmpty(param.Model)) { where = where && ORD_PurchaseOrderLine._.Model.At("b").As("Model").Like("%" + param.Model + "%"); //Model } if (!string.IsNullOrEmpty(param.Brand)) { where = where && ORD_PurchaseOrderLine._.Brand.At("b").As("Brand").Like("%" + param.Brand + "%"); //Brand } if (!string.IsNullOrEmpty(param.StkInStatus)) { where = where && ORD_PurchaseOrder._.StkInStatus.Like("%" + param.StkInStatus + "%"); //InStatus } if (!string.IsNullOrEmpty(param.HasTaxRate)) { if (param.HasTaxRate.ToLower() == "true") { where = where && ORD_PurchaseOrder._.TaxRate > 0; } else { where = where && ORD_PurchaseOrder._.TaxRate.IsNull(0) <= 0; } } if (param.StartPODate != null && param.EndPODate != null) { where = where && ORD_PurchaseOrder._.PODate.Between(param.StartPODate.GetValueOrDefault(), param.EndPODate.GetValueOrDefault());//采购日期 } if (param.StartNeedPayAmtDate != null && param.EndNeedPayAmtDate != null) { where = where && ORD_PurchaseOrder._.PODate.Between(param.StartNeedPayAmtDate.GetValueOrDefault(), param.EndNeedPayAmtDate.GetValueOrDefault());//付款日期 } if (param.StartNeedDeliveryDate != null && param.EndNeedDeliveryDate != null) { where = where && ORD_PurchaseOrder._.PODate.Between(param.StartNeedDeliveryDate.GetValueOrDefault(), param.EndNeedDeliveryDate.GetValueOrDefault());//到货日期 } if (param.StkInOccStatusArr != null && param.StkInOccStatusArr.Length > 0) { where = where && ORD_PurchaseOrder._.StkInOccStatus.In(param.StkInOccStatusArr); } return(where); }
public bool UpdateStatus(ORD_PurchaseOrderParam param) { bool flag = true; try { ORD_PurchaseOrderResult orderResult = this.GetInfo(param); if (orderResult != null) { if (orderResult.OrderLineList != null && orderResult.OrderLineList.Count > 0) { //取消的明细需要排除 List <ORD_PurchaseOrderLineResult> lineList = orderResult.OrderLineList; if (lineList != null && lineList.Count > 0) { int?qty = lineList.Where(a => a.Qty != null).Select(a => a.Qty).Sum(); int?stkInOccQty = lineList.Where(a => a.StkInOccQty != null).Select(a => a.StkInOccQty).Sum(); int?stkInQty = lineList.Where(a => a.StkInQty != null).Select(a => a.StkInQty).Sum(); int?stkOutQty = lineList.Where(a => a.StkOutQty != null).Select(a => a.StkOutQty).Sum(); int?returnOccQty = lineList.Where(a => a.ReturnOccQty != null).Select(a => a.ReturnOccQty).Sum(); int?returnQty = lineList.Where(a => a.ReturnQty != null).Select(a => a.ReturnQty).Sum(); if (stkInOccQty == 0) { orderResult.StkInOccStatus = "待占有"; } else if (stkInOccQty >= qty) { orderResult.StkInOccStatus = "全部占有"; } else { orderResult.StkInOccStatus = "部分占有"; } if (stkInQty == 0) { orderResult.StkInStatus = "待入库"; } else if (stkInQty >= qty) { orderResult.StkInStatus = "全部入库"; } else { orderResult.StkInStatus = "部分采购"; } if (stkOutQty == 0) { orderResult.StkOutStatus = "待出库"; } else if (stkOutQty >= qty) { orderResult.StkOutStatus = "全部出库"; } else { orderResult.StkOutStatus = "部分出库"; } if (returnOccQty == 0) { orderResult.ReturnOccStatus = "待占有"; } else if (returnOccQty >= qty) { orderResult.ReturnOccStatus = "全部占有"; } else { orderResult.ReturnOccStatus = "部分占有"; } if (returnQty == 0) { orderResult.ReturnStatus = "待退货"; } else if (returnQty >= qty) { orderResult.ReturnStatus = "全部退货"; } else { orderResult.ReturnStatus = "部分退货"; } this.AddOrUpdate(orderResult); } } } } catch (WarnException exp) { flag = false; throw exp; } catch (System.Exception exp) { flag = false; LogInfoBLL.WriteLog(this.SessionInfo, exp); throw exp; } return(flag); }
private void GetLastHistoryPrice(string oprType) { string supplierName = ""; int supplierID = 0; List <string> modelList = new List <string>(); List <string> brandList = new List <string>(); #region 供应商名称 supplierID = this.txtSupplierID.Text.ToInt32(); supplierName = this.txtSupplierName.Text; if (supplierName.Trim() == "" || supplierID <= 0) { return; } #endregion #region 更改了供应商 if (oprType == "supplier") { foreach (DataGridViewRow row in this.dgvPurchaseOrderLine.Rows) { if (row.Cells["colModel"].Value.ToStringHasNull().Trim() == "") { continue; } if (row.Cells["colNTaxPrice"].Tag.ToDecimal() != row.Cells["colNTaxPrice"].Value.ToDecimal() && row.Cells["colUnitPrice"].Tag.ToDecimal() != row.Cells["colUnitPrice"].Value.ToDecimal()) { continue; } modelList.Add(row.Cells["colModel"].Value.ToStringHasNull()); if (row.Cells["colBrand"].Value.ToStringHasNull().Trim() != "" && !brandList.Contains(row.Cells["colBrand"].Value.ToStringHasNull().Trim())) { brandList.Add(row.Cells["colBrand"].Value.ToStringHasNull()); } } } #endregion #region 更改了型号和品牌 else if ((oprType == "model" || oprType == "brand") && this.dgvPurchaseOrderLine.CurrentCell != null) { DataGridViewRow row = this.dgvPurchaseOrderLine.Rows[this.dgvPurchaseOrderLine.CurrentCell.RowIndex]; if (row.Cells["colModel"].Value.ToStringHasNull().Trim() != "" && (row.Cells["colNTaxPrice"].Tag.ToDecimal() == row.Cells["colNTaxPrice"].Value.ToDecimal() || row.Cells["colUnitPrice"].Tag.ToDecimal() == row.Cells["colUnitPrice"].Value.ToDecimal())) { modelList.Add(row.Cells["colModel"].Value.ToStringHasNull()); if (row.Cells["colBrand"].Value.ToStringHasNull().Trim() != "" && !brandList.Contains(row.Cells["colBrand"].Value.ToStringHasNull().Trim())) { brandList.Add(row.Cells["colBrand"].Value.ToStringHasNull()); } } } #endregion #region 获取历史单价 if (modelList.Count <= 0) { return; } ORD_PurchaseOrderLogic logic = new ORD_PurchaseOrderLogic(this); ORD_PurchaseOrderParam param = new ORD_PurchaseOrderParam(); param.SupplierID = supplierID; param.ModelList = modelList.ToArray(); param.BrandList = brandList.ToArray(); List <ORD_PurchaseOrderLineResult> rst = logic.GetLastHisstoryPrice(param); #endregion string model = "", brand = ""; ORD_PurchaseOrderLineResult findInfo = new ORD_PurchaseOrderLineResult(); #region 更改了供应商 if (oprType == "supplier") { foreach (DataGridViewRow row in this.dgvPurchaseOrderLine.Rows) { if (row.Cells["colModel"].Value.ToStringHasNull().Trim() == "") { continue; } if (row.Cells["colNTaxPrice"].Tag.ToDecimal() != row.Cells["colNTaxPrice"].Value.ToDecimal() && row.Cells["colUnitPrice"].Tag.ToDecimal() != row.Cells["colUnitPrice"].Value.ToDecimal()) { continue; } model = row.Cells["colModel"].Value.ToStringHasNull().ToLower(); brand = row.Cells["colBrand"].Value.ToStringHasNull().ToLower(); if (brand.ToStringHasNull().Trim() == "") { findInfo = rst.Find(a => a.Model.ToLower() == model); } else { findInfo = rst.Find(a => a.Model.ToLower() == model && a.Brand.ToStringHasNull().ToLower() == brand); } if (findInfo != null) { row.Cells["colUnitPrice"].Value = findInfo.UnitPrice; row.Cells["colNTaxPrice"].Value = findInfo.NTaxPrice; row.Cells["colUnitPrice"].Tag = findInfo.UnitPrice; row.Cells["colNTaxPrice"].Tag = findInfo.NTaxPrice; } else { row.Cells["colUnitPrice"].Value = ""; row.Cells["colNTaxPrice"].Value = ""; row.Cells["colUnitPrice"].Tag = null; row.Cells["colNTaxPrice"].Tag = null; } } } #endregion #region 更改了型号和品牌 else if ((oprType == "model" || oprType == "brand") && this.dgvPurchaseOrderLine.CurrentCell != null) { DataGridViewRow row = this.dgvPurchaseOrderLine.Rows[this.dgvPurchaseOrderLine.CurrentCell.RowIndex]; if (row.Cells["colModel"].Value.ToStringHasNull().Trim() == "") { return; } if (row.Cells["colNTaxPrice"].Tag.ToDecimal() != row.Cells["colNTaxPrice"].Value.ToDecimal() && row.Cells["colUnitPrice"].Tag.ToDecimal() != row.Cells["colUnitPrice"].Value.ToDecimal()) { return; } model = row.Cells["colModel"].Value.ToStringHasNull().ToLower(); brand = row.Cells["colBrand"].Value.ToStringHasNull().ToLower(); if (brand.ToStringHasNull().Trim() == "") { findInfo = rst.Find(a => a.Model.ToLower() == model); } else { findInfo = rst.Find(a => a.Model.ToLower() == model && a.Brand.ToStringHasNull().ToLower() == brand); } if (findInfo != null) { row.Cells["colUnitPrice"].Value = findInfo.UnitPrice; row.Cells["colNTaxPrice"].Value = findInfo.NTaxPrice; row.Cells["colUnitPrice"].Tag = findInfo.UnitPrice; row.Cells["colNTaxPrice"].Tag = findInfo.NTaxPrice; } else { row.Cells["colUnitPrice"].Value = ""; row.Cells["colNTaxPrice"].Value = ""; row.Cells["colUnitPrice"].Tag = null; row.Cells["colNTaxPrice"].Tag = null; } } #endregion }
/// <summary> /// 获取某供应商的最近料的历史单价 /// </summary> /// <returns></returns> public List <ORD_PurchaseOrderLineResult> GetLastHisstoryPrice(ORD_PurchaseOrderParam param) { List <ORD_PurchaseOrderLineResult> ret = new List <ORD_PurchaseOrderLineResult>(); #region 判断提供条件 if (param.SupplierID.ToInt32() <= 0) { throw new WarnException("请指定供应商条件!"); } if (param.ModelList == null || param.ModelList.Length <= 0) { throw new WarnException("请指定查找型号!"); } #endregion #region 获取最近最大日期和明细ID WhereClip filterWhere = ORD_PurchaseOrder._.SupplierID == param.SupplierID && ORD_PurchaseOrder._.GCompanyID == this.SessionInfo.CompanyID && ORD_PurchaseOrder._.IsDeleted == false; filterWhere = filterWhere && ORD_PurchaseOrderLine._.Model.At("b").In(param.ModelList); if (param.BrandList != null && param.BrandList.Length > 0) { filterWhere = filterWhere && ORD_PurchaseOrderLine._.Brand.At("b").In(param.BrandList); } PageList <ORD_PurchaseOrderResult> lstPOTemp = new PageList <ORD_PurchaseOrderResult>(); WhereClip onWhere = ORD_PurchaseOrder._.POGuid == ORD_PurchaseOrderLine._.POGuid.At("b"); lstPOTemp = this.SelectList <ORD_PurchaseOrderResult, ORD_PurchaseOrderLine>(JoinType.InnerJoin, onWhere, 1, 5000 , new List <Field>() { ORD_PurchaseOrder._.BillNo.Max().As("BillNo") } , filterWhere, null, null, null); #region 生成条件数组 List <string> billNoList = new List <string>(); DataTable tbl = lstPOTemp.ResultJoinList; if (tbl != null) { foreach (DataRow row in tbl.Rows) { billNoList.Add(row["BillNo"].ToStringHasNull()); } } if (billNoList.Count > 0) { filterWhere = filterWhere && ORD_PurchaseOrder._.BillNo.In(billNoList.ToArray()); } #endregion #endregion #region 获取返回记录 lstPOTemp = new PageList <ORD_PurchaseOrderResult>(); lstPOTemp = this.SelectList <ORD_PurchaseOrderResult, ORD_PurchaseOrderLine>(JoinType.InnerJoin, onWhere, 1, 5000 , new List <Field>() { ORD_PurchaseOrderLine._.Model.At("b").As("Model"), ORD_PurchaseOrderLine._.Brand.At("b").As("Brand") , ORD_PurchaseOrderLine._.Package.At("b").As("Package"), ORD_PurchaseOrderLine._.Batch.At("b").As("Batch") , ORD_PurchaseOrderLine._.MarkCode.At("b").As("MarkCode"), ORD_PurchaseOrderLine._.UnitPrice.At("b").As("UnitPrice") , ORD_PurchaseOrderLine._.NTaxPrice.At("b").As("NTaxPrice") } , filterWhere, null, null, null); #endregion #region 返回值 foreach (DataRow row in lstPOTemp.ResultJoinList.Rows) { ret.Add(new ORD_PurchaseOrderLineResult() { Model = row["Model"].ToStringHasNull(), Brand = row["Brand"].ToStringHasNull(), Package = row["Package"].ToStringHasNull(), MarkCode = row["Package"].ToStringHasNull(), Batch = row["Batch"].ToStringHasNull(), NTaxPrice = row["NTaxPrice"].ToDecimal(), UnitPrice = row["NTaxPrice"].ToDecimal() }); } #endregion return(ret); }