示例#1
0
        /// <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);
        }
示例#2
0
        object Form_GetEditEntity()
        {
            ORD_PurchaseOrderResult info = new ORD_PurchaseOrderResult();

            info.POGuid = poguid;
            info        = this.ConvertControlToEntity <ORD_PurchaseOrderResult>(this.stcpOrder.Controls, info, null);
            info        = this.ConvertControlToEntity <ORD_PurchaseOrderResult>(this.stcpOther.Controls, info, null);
            info        = this.ConvertControlToEntity <ORD_PurchaseOrderResult>(this.stcpConEntry.Controls, info, null);
            if (!chkIsInvoiced.Checked)
            {
                info.InvoiceType = null;
            }
            this.SetDataIsChanged <ORD_PurchaseOrderResult>(info);

            #region 明细列表
            bsOrderLine.EndEdit();
            tempList.Clear();
            foreach (ORD_PurchaseOrderLineResult rst in addOrModifyList)
            {
                if (rst.HasChanged())
                {
                    tempList.Add(rst);
                }
            }
            tempList.AddRange(delList);
            info.OrderLineList = tempList;
            if (tempList.Count > 0)
            {
                this.DataIsChanged = true;
            }
            #endregion
            return(info);
        }
示例#3
0
        /// <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("请选择需要删除的采购明细!");
            }
        }
示例#4
0
        private void txtPOBillNo_ButtonCustomClick(object sender, EventArgs e)
        {
            frmSelectPurchaseOrder frmSelectPurchaseOrder = new frmSelectPurchaseOrder(false,
                                                                                       new ORD_PurchaseOrderParam()
            {
                StkInOccStatusArr = new string[] { "全部占有", "部分占有" }
            });

            frmSelectPurchaseOrder.SupplierID = txtSupplierID.Text.ToInt32();
            frmSelectPurchaseOrder.BringToFront();
            frmSelectPurchaseOrder.StartPosition = FormStartPosition.CenterScreen;

            DialogResult rst = frmSelectPurchaseOrder.ShowDialog();

            if (rst == DialogResult.OK)
            {
                List <ORD_PurchaseOrderResult> rstList = frmSelectPurchaseOrder.GetSelectList <ORD_PurchaseOrderResult>();
                if (rstList != null && rstList.Count > 0)
                {
                    bsPurchaseReturnLine.Clear();
                    tempList.Clear();
                    delList.Clear();
                    addOrModifyList.Clear();
                    ORD_PurchaseOrderResult orderResult = rstList[0];
                    InitSourceData(orderResult);
                }
            }
        }
示例#5
0
 void InitSourceData(ORD_PurchaseOrderResult orderResult)
 {
     if (orderResult != null)
     {
         txtPOGuid.Text            = orderResult.POGuid.ToStringHasNull();
         txtPOBillNo.Text          = orderResult.BillNo;
         cboCurrency.SelectedValue = orderResult.Currency;
         txtPODate.Text            = orderResult.PODate.ToStringHasNull();
         decimal?totalAmount = 0.0m;
         List <STK_InLineResult> inLineList = inLineLogic.GetList(new STK_InLineParam()
         {
             SourceBillGuid = orderResult.POGuid
         });
         foreach (STK_InLineResult inLineResult in inLineList)
         {
             ORD_PurchaseReturnLineResult returnListResult = new ORD_PurchaseReturnLineResult();
             SetStkLineObjectValue(returnListResult, inLineResult);
             totalAmount += returnListResult.Amount;
             bsPurchaseReturnLine.Add(returnListResult);
         }
         totalAmount    = Math.Round(totalAmount.ToDecimal(), 3, MidpointRounding.AwayFromZero);
         txtAmount.Text = totalAmount.ToStringHasNull();
         CRM_CompanyResult companyResult = companyLogic.GetCustInfo(new CRM_CompanyParam()
         {
             CompanyID = orderResult.SupplierID.ToInt32()
         });
         if (companyResult != null)
         {
             txtSupplierID.Text   = companyResult.CompanyID.ToStringHasNull();
             txtSupplierName.Text = companyResult.CompanyName;
         }
     }
 }
示例#6
0
        private void UpdateCancelFlag(bool isCancel)
        {
            ORD_PurchaseOrderLogic logic = new ORD_PurchaseOrderLogic(this);

            if (poguid == null)
            {
                this.ShowMessage("请先保存新增的数据!");
                return;
            }
            if (isCancel)
            {
                if (MessageBox.Show("是否真的取消当前单据?", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }
            }
            else
            {
                if (MessageBox.Show("是否真的恢复当前单据?", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }
            }
            ORD_PurchaseOrderResult param = new ORD_PurchaseOrderResult();

            param.POGuid   = poguid;
            param.IsCancel = isCancel;
            WCFAddUpdateResult rst = logic.UpdateCancelFlag(param);

            if (rst.Key > 0)
            {
                InitData();
            }
        }
示例#7
0
        private void InitData()
        {
            if (poguid != null)
            {
                ORD_PurchaseOrderResult info = orderLogic.GetInfo(new ORD_PurchaseOrderParam {
                    POGuid = poguid
                });
                this.ConvertEntityToControl <ORD_PurchaseOrderResult>(this.stcpOrder.Controls, info, null);
                this.ConvertEntityToControl <ORD_PurchaseOrderResult>(this.stcpOther.Controls, info, null);
                this.ConvertEntityToControl <ORD_PurchaseOrderResult>(this.stcpConEntry.Controls, info, null);
                if (info != null)
                {
                    txtPurDeptName.Text = info.HR_DepartmentResult == null ? "" : info.HR_DepartmentResult.DeptName;
                    decimal taxAmount   = Math.Round(info.TaxAmount.ToDecimal(), 3, MidpointRounding.AwayFromZero);
                    decimal totalAmount = Math.Round(info.Amount.ToDecimal(), 3, MidpointRounding.AwayFromZero);
                    txtAmount.Text    = totalAmount.ToStringHasNull();
                    txtTaxAmount.Text = taxAmount.ToStringHasNull();
                    if (info.OrderLineList != null)
                    {
                        addOrModifyList = info.OrderLineList;
                    }
                }
                this.CheckIsReadOnly <ORD_PurchaseOrderResult>(info);
                this.CheckAuditStatus <ORD_PurchaseOrderResult>(info, this.stcpOrder, this.panDtlOpr, this.stcpOther, this.stcpAttachFiles, this.stcpConEntry, this.stcpLine);
                this.EditBeforeData = info;
            }
            else
            {
                cboInvType.SelectedValue = "备货库存";
                string date = DateTime.Now.Date.ToStringHasNull();
                txtPODate.Text           = date;
                txtNeedDeliveryDate.Text = date;
                txtNeedPayAmtDate.Text   = date;

                this.txtPurDeptName.Text = MySession.DeptName;
                this.txtPurDeptID.Text   = MySession.DeptID.ToStringHasNull();
                this.txtBuyerName.Text   = MySession.UserName;
                this.txtBuyerID.Text     = MySession.UserID.ToStringHasNull();

                SYS_DictItemLineLogic.SetCombolSelectedIndex(this.cboPurOrgID, MySession.OrgID, true);
            }
            bsOrderLine.DataSource          = addOrModifyList;
            dgvPurchaseOrderLine.DataSource = bsOrderLine;

            CheckAuditButton("ORD_PurchaseOrder", poguid, this.tsbSubmit, null, this.tsbAudit, this.tsbUnDo);
            if (this.txtIsCancel.Text.Trim().ToLower() == "true")
            {
                this.lblSignFlag.SetFlag(ZNLCRM.Controls.UcSignature.SignFlag.CancelBill);
                this.tsbCancelBill.Visible = false;
                this.tsbTakeCancel.Visible = true;
            }
            else
            {
                this.lblSignFlag.SetFlag(ZNLCRM.Controls.UcSignature.SignFlag.None);
                this.tsbCancelBill.Visible = true;
                this.tsbTakeCancel.Visible = false;
            }
            this.DataIsChanged = false;
        }
示例#8
0
        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);
        }
示例#9
0
        public WCFAddUpdateResult UpdateCancelFlag(ORD_PurchaseOrderResult param)
        {
            WCFAddUpdateResult ret = new WCFAddUpdateResult();
            ExeResult          rst = new ExeResult();

            rst = this.Execute("ZNLCRM.BLL.PPM.ORD_PurchaseOrderBLL", "UpdateCancelFlag", param);
            ret = (rst == null ? new WCFAddUpdateResult() : rst.Result as WCFAddUpdateResult);
            return(ret);
        }
示例#10
0
        /// <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);
        }
示例#11
0
        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);
        }
示例#12
0
        private void tsbAudit_Click(object sender, EventArgs e)
        {
            // //tsbSave_Click(sender, e);
            //bool flag=  orderLogic.AuditPurchaseOrderBill(new ORD_PurchaseOrderParam() { POGuid = poguid });
            //if (flag)
            //{
            //    InitData();
            //}
            ORD_PurchaseOrderResult info = Form_GetEditEntity() as ORD_PurchaseOrderResult;

            this.WF_CheckBill("ORD_PurchaseOrder", info.BillNo, info.POGuid, this.DataIsChanged, delegate() { return(SaveData(false)); }, InitData);
        }
示例#13
0
        private bool SaveData(bool isAsyncExecute)
        {
            bool ret = false;
            ORD_PurchaseOrderResult info = Form_GetEditEntity() as ORD_PurchaseOrderResult;

            if (isAsyncExecute && !this.DataIsChanged)
            {
                this.ShowNoChangedMsg();
                return(ret);
            }
            #region 异步执行保存操作
            if (isAsyncExecute)
            {
                WCFAddUpdateResult result = this.AsyncExecute <WCFAddUpdateResult, ORD_PurchaseOrderResult>(info, orderLogic.AddOrUpdate, (a) =>
                {
                    if (a.KeyGuid.ToGuid() != Guid.Empty)
                    {
                        poid         = a.Key;
                        poguid       = a.KeyGuid.ToGuid();
                        sourcebillno = a.BillNo;
                        CRM_CompanyResult companyResult = companyLogic.GetCustInfo(new CRM_CompanyParam()
                        {
                            CompanyID = txtSupplierID.Text.ToInt32()
                        });
                        if (companyResult != null)
                        {
                            companyResult.LastBusinessDate = txtPODate.Text.ToDateTime();
                            companyLogic.AddOrUpdateSup(companyResult);
                        }
                        if (SaveAttach != null)
                        {
                            SaveAttach("ORD_PurchaseOrder", poguid.ToGuid(), sourcebillno);
                        }
                        InitData();
                        delList.Clear();
                    }
                });
            }
            #endregion
            #region  步执行保存操作
            else
            {
                WCFAddUpdateResult result = orderLogic.AddOrUpdate(info);
                if (result.KeyGuid.ToGuid() != Guid.Empty)
                {
                    ret = true;
                }
            }
            #endregion
            return(ret);
        }
示例#14
0
        void biStkIn_Click(object sender, EventArgs e)
        {
            DataGridViewRow row = dgvPurchaseOrder.CurrentRow;

            if (row != null)
            {
                Guid?poguid = row.Cells["colPOGuid"].Value.ToGuid();
                ORD_PurchaseOrderResult orderResult = orderLogic.GetInfo(new ORD_PurchaseOrderParam()
                {
                    POGuid = poguid
                });
                if (orderResult != null && orderResult.Status == "Complete" && orderResult.StkInOccStatus != "全部占有")
                {
                    List <ORD_PurchaseOrderLineResult> lineList = orderResult.OrderLineList;
                    if (lineList != null && lineList.Count > 0)
                    {
                        //有效的可作为入库明细的采购记录
                        List <ORD_PurchaseOrderLineResult> effLineList = lineList.Where(a => a.IsCancel == false && a.Qty > a.StkInOccQty).ToList();
                        if (effLineList != null && effLineList.Count > 0)
                        {
                            STK_InResult inResult = stkInLogic.GetInfo(new STK_InParam()
                            {
                                SourceBillGuid = poguid, Status = "New"
                            });
                            frmStkIn frmStkIn = new frmStkIn();
                            frmStkIn.BringToFront();
                            frmStkIn.StartPosition = FormStartPosition.CenterParent;
                            if (inResult != null)
                            {
                                //存在关联的未提交的入库单
                                frmStkIn.StkInGuid = inResult.StkInGuid;
                            }
                            frmStkIn.ShowDialog();
                        }
                        else
                        {
                            this.ShowMessage("当前采购单没有再需要入库的采购明细!若存在有关联的已提交未审核的入库单,请及时联系相关人员审核!");
                        }
                    }
                }
                else
                {
                    this.ShowMessage("未审核或者全部占有的采购单据不允许入库!");
                }
            }
            else
            {
                this.ShowMessage("未选中数据行!");
            }
        }
示例#15
0
文件: frmStkIn.cs 项目: halfx/ZNL
        public void InitSourceData(string billType, Guid?sourceBillGuid)
        {
            if (cboBillType.SelectedValue.ToStringHasNull() == "")
            {
                SYS_DictItemLineLogic.SetCombolSelectedIndex(cboBillType, billType, true);
            }
            switch (billType)
            {
            case "PO_IN":    //采购入库
                #region 采购入库
                ORD_PurchaseOrderResult rst = purOrderLogic.GetInfo(new ORD_PurchaseOrderParam()
                {
                    POGuid = sourceBillGuid
                });
                if (rst != null)
                {
                    bsStkInLine.Clear();
                    tempList.Clear();
                    delList.Clear();
                    addOrModifyList.Clear();
                    SetStkLineObjectValue(rst);
                    CalcExchangeRate();
                }
                #endregion
                break;

            case "SOR_IN":    //销售退货入库
                #region 销售退货入库
                ORD_SalesReturnResult returnResult = returnLogic.GetInfo(new ORD_SalesReturnParam()
                {
                    SRGuid = sourceBillGuid
                });
                if (returnResult != null)
                {
                    bsStkInLine.Clear();
                    tempList.Clear();
                    delList.Clear();
                    addOrModifyList.Clear();
                    SetStkLineObjectValue(returnResult);
                    CalcExchangeRate();
                }
                #endregion
                break;
            }
        }
示例#16
0
        private void InitData()
        {
            if (PRGuid != null)
            {
                ORD_PurchaseReturnResult info = returnLogic.GetInfo(new ORD_PurchaseReturnParam {
                    PRGuid = PRGuid
                });

                this.ConvertEntityToControl <ORD_PurchaseReturnResult>(this.stcpBase.Controls, info, null);
                if (info != null)
                {
                    txtOperDeptName.Text = info.OperDeptName;
                    decimal totalAmount = Math.Round(info.Amount.ToDecimal(), 3, MidpointRounding.AwayFromZero);
                    txtAmount.Text = totalAmount.ToStringHasNull();
                    if (info.ReturnLineList != null)
                    {
                        addOrModifyList = info.ReturnLineList;
                    }
                }
            }
            else
            {
                txtReturnDate.Text   = DateTime.Now.Date.ToStringHasNull();
                txtOperDeptID.Text   = MySession.DeptID.ToStringHasNull();
                txtOperDeptName.Text = MySession.DeptName;
                txtOperEmpID.Text    = MySession.UserID.ToStringHasNull();
                txtOperEmpName.Text  = MySession.UserName.ToStringHasNull();
                SYS_DictItemLineLogic.SetCombolSelectedIndex(this.cboOperOrgID, MySession.OrgID, true);
            }
            bsPurchaseReturnLine.DataSource  = addOrModifyList;
            dgvPurchaseReturnLine.DataSource = bsPurchaseReturnLine;
            //CheckAuditButton("ORD_SalesOrder", SRGuid, this.tsbSubmit, null, this.tsbAudit, this.tsbUnDo);
            if (PRGuid == null && SourceBillGuid != null)
            {
                ORD_PurchaseOrderResult orderResult = orderLogic.GetInfo(new ORD_PurchaseOrderParam()
                {
                    POGuid = SourceBillGuid
                });
                if (orderResult != null)
                {
                    InitSourceData(orderResult);
                }
            }
        }
示例#17
0
        public List <ORD_PurchaseOrderLineResult> GetSimpleList(ORD_PurchaseOrderLineParam param, List <Field> fields)
        {
            List <ORD_PurchaseOrderLineResult> ret = new List <ORD_PurchaseOrderLineResult>();

            try
            {
                WhereClip whereClip = GetWhereClip(param);
                ret = this.SelectList <ORD_PurchaseOrderLineResult>(fields, whereClip, ORD_PurchaseOrderLine._.CreatedTime.Asc);
                if (ret != null && ret.Count > 0)
                {
                    Guid?[] POGuids = ret.Select(a => a.POGuid).Distinct().ToArray();
                    ORD_PurchaseOrderBLL orderBLL = new ORD_PurchaseOrderBLL();
                    orderBLL.SessionInfo = this.SessionInfo;
                    List <ORD_PurchaseOrderResult> orderResultList = orderBLL.GetList(new ORD_PurchaseOrderParam()
                    {
                        POGuids = POGuids
                    });
                    foreach (ORD_PurchaseOrderLineResult lineResult in ret)
                    {
                        ORD_PurchaseOrderResult orderResult = orderResultList.FirstOrDefault(a => a.POGuid == lineResult.POGuid);
                        if (orderResult != null)
                        {
                            lineResult.POBillNo = orderResult.BillNo;
                            lineResult.Currency = orderResult.Currency;
                            lineResult.TaxRate  = orderResult.TaxRate;
                        }
                    }
                }
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
                throw exp;
            }
            return(ret);
        }
示例#18
0
文件: frmStkIn.cs 项目: halfx/ZNL
        public void SetStkLineObjectValue(ORD_PurchaseOrderResult purchaseOrder)
        {
            decimal?         taxAmount   = 0.0m;
            decimal?         totalAmount = 0.0m;
            decimal?         scAmount    = 0.0m;
            STK_InLineResult inLineRst;

            txtSourceBillGuid.Text    = purchaseOrder.POGuid.ToStringHasNull();
            txtSourceBillNo.Text      = purchaseOrder.BillNo;
            cboCurrency.SelectedValue = purchaseOrder.Currency;
            cboTaxRate.SelectedValue  = purchaseOrder.TaxRate.ToDecimal();
            foreach (ORD_PurchaseOrderLineResult purLineRst in purchaseOrder.OrderLineList)
            {
                inLineRst            = new STK_InLineResult();
                purLineRst.BuyerID   = purchaseOrder.BuyerID;
                purLineRst.BuyerName = purchaseOrder.BuyerName;
                purLineRst.Currency  = purchaseOrder.Currency;
                SetStkLineObjectValue(inLineRst, purLineRst);
                bsStkInLine.Add(inLineRst);
                taxAmount   += inLineRst.TaxRate.ToDecimal();
                totalAmount += inLineRst.Amount.ToDecimal();
                taxAmount   += purLineRst.UnitPrice * purLineRst.Qty.ToInt32() - purLineRst.NTaxPrice * purLineRst.Qty.ToInt32();
                scAmount    += inLineRst.SCAmount.ToDecimal();
            }
            totalAmount       = Math.Round(totalAmount.ToDecimal(), 3, MidpointRounding.AwayFromZero);
            scAmount          = Math.Round(scAmount.ToDecimal(), 3, MidpointRounding.AwayFromZero);
            taxAmount         = Math.Round(taxAmount.ToDecimal(), 3, MidpointRounding.AwayFromZero);
            txtAmount.Text    = totalAmount.ToStringHasNull();
            txtSCAmount.Text  = scAmount.ToStringHasNull();
            txtTaxAmount.Text = taxAmount.ToStringHasNull();
            this.cboOperOrgID.SelectedValue = purchaseOrder.PurOrgID;
            this.txtOperDeptID.Text         = purchaseOrder.PurDeptName;
            this.txtOperDeptID.Text         = purchaseOrder.PurDeptID.ToStringHasNull();
            this.txtOperEmpID.Text          = purchaseOrder.BuyerID.ToStringHasNull();
            this.txtOperEmpName.Text        = purchaseOrder.BuyerName.ToStringHasNull();
        }
示例#19
0
        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);
        }
示例#20
0
        /// <summary>
        /// 添加和新增修改
        /// </summary>
        /// <param name="param">新增或修改的实体</param>
        /// <returns></returns>
        public WCFAddUpdateResult AddOrUpdate(ORD_PurchaseOrderResult param)
        {
            this.CheckSession();
            WCFAddUpdateResult ret = new WCFAddUpdateResult();

            try
            {
                int affect = 0;
                #region 判断

                if (string.IsNullOrEmpty(param.SupplierName.Trim()))
                {
                    throw new WarnException("请指定公司名称!");
                }
                if (string.IsNullOrEmpty(param.BuyerName))
                {
                    throw new WarnException("请选择采购员!");
                }
                if (string.IsNullOrEmpty(param.Currency))
                {
                    throw new WarnException("请选择币种!");
                }
                if (string.IsNullOrEmpty(param.ClearingForm))
                {
                    throw new WarnException("请填写结算方式!");
                }
                if (param.OrderLineList == null)
                {
                    throw new WarnException("请填写采购明细!");
                }
                string msg = string.Empty;

                foreach (ORD_PurchaseOrderLineResult rst in param.OrderLineList)
                {
                    if (string.IsNullOrEmpty(rst.Model))
                    {
                        msg = "请填写采购明细的型号!";
                        break;
                    }
                    if (rst.Qty <= 0)
                    {
                        msg = "请填写采购明细的数量!";
                    }
                }
                #endregion
                List <ORD_PurchaseOrderLineResult> orderLineList = param.OrderLineList;

                #region 系统默认值
                if (param.POGuid != null)
                {
                    WhereClip where      = ORD_PurchaseOrder._.POGuid == param.POGuid;
                    param.UpdatedEmpID   = this.SessionInfo.UserID;
                    param.UpdatedEmpName = this.SessionInfo.UserName;
                    param.UpdatedTime    = DateTime.Now;
                    affect = this.Update <ORD_PurchaseOrderResult>(param, where);
                }
                else
                {
                    param.POGuid = Guid.NewGuid();
                    Sys_CodeRulerBLL codeRulerBll = new Sys_CodeRulerBLL();
                    codeRulerBll.SessionInfo = this.SessionInfo;
                    param.BillNo             = param.BillNo = codeRulerBll.GetBillNo(new Entity.UserModel.Sys.SYS_CredentialCodeRuleParam()
                    {
                        BillDate = DateTime.Today, TableName = "ORD_PurchaseOrder"
                    });
                    param.GCompanyID = this.SessionInfo.CompanyID;

                    param.StkInOccStatus  = "待占有";
                    param.StkInStatus     = "待入库";
                    param.StkOutStatus    = "待出库";
                    param.ReturnOccStatus = "待占有";
                    param.ReturnStatus    = "待退货";
                    param.PaymentStatus   = "待收款";

                    param.Status         = "New";
                    param.ApproveStatus  = "待提交";
                    param.IsDeleted      = false;
                    param.CreatedEmpID   = this.SessionInfo.UserID;
                    param.CreatedEmpName = this.SessionInfo.UserName;
                    param.CreatedTime    = DateTime.Now;
                    affect = this.Insert <ORD_PurchaseOrderResult>(param);
                    param  = this.Select <ORD_PurchaseOrderResult>(new List <Field>()
                    {
                        ORD_PurchaseOrder._.All
                    }, ORD_PurchaseOrder._.POGuid == param.POGuid);
                }


                foreach (ORD_PurchaseOrderLineResult rst in orderLineList)
                {
                    if (rst.POLineGuid == null)
                    {
                        rst.POLineGuid     = Guid.NewGuid();
                        rst.POGuid         = param.POGuid;
                        rst.GCompanyID     = this.SessionInfo.CompanyID;
                        rst.CreatedEmpID   = this.SessionInfo.UserID;
                        rst.CreatedEmpName = this.SessionInfo.UserName;
                        rst.CreatedTime    = DateTime.Now;
                        rst.IsCancel       = false;
                        rst.IsDeleted      = false;
                    }
                    else
                    {
                        rst.UpdatedEmpID   = this.SessionInfo.UserID;
                        rst.UpdatedEmpName = this.SessionInfo.UserName;
                        rst.UpdatedTime    = DateTime.Now;
                    }
                }
                this.BatchInsertOrUpdate <ORD_PurchaseOrderLineResult>(orderLineList);
                this.BatchExecute();


                #region 设置返回值
                ret.Key            = param.POID.ToInt32();
                ret.KeyGuid        = param.POGuid;
                ret.CreatedTime    = param.CreatedTime;
                ret.CreatedEmpID   = param.CreatedEmpID;
                ret.CreatedEmpName = param.CreatedEmpName;
                ret.UpdatedEmpID   = param.UpdatedEmpID;
                ret.UpdatedEmpName = param.UpdatedEmpName;
                ret.UpdatedTime    = param.UpdatedTime;
                #endregion
                #endregion
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
                throw exp;
            }
            return(ret);
        }
示例#21
0
        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);
        }
示例#22
0
        /// <summary>
        /// 取消单据
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public WCFAddUpdateResult UpdateCancelFlag(ORD_PurchaseOrderResult param)
        {
            this.CheckSession();
            WCFAddUpdateResult ret = new WCFAddUpdateResult();

            #region 判断
            if (param.POGuid == null)
            {
                throw new WarnException("请指定采购单GUID!");
            }
            #endregion
            #region 判断是否存在采购主单
            ORD_PurchaseOrderResult info = new ORD_PurchaseOrderResult();
            info = this.Select <ORD_PurchaseOrderResult>(new List <Field>()
            {
                ORD_PurchaseOrder._.Status
            }
                                                         , ORD_PurchaseOrder._.GCompanyID == this.SessionInfo.CompanyID && ORD_PurchaseOrder._.POGuid == param.POGuid && ORD_PurchaseOrder._.IsDeleted == false
                                                         , ORD_PurchaseOrder._.POID.Asc);
            if (info == null)
            {
                throw new WarnException("采购单主单不存在!");
            }
            if (info.IsCancel.ToBooleanHasNull() && param.IsCancel.ToBooleanHasNull())
            {
                throw new WarnException("您已取消当前单据,不允许重复执行当前操作!");
            }
            if (info.IsCancel.ToBooleanHasNull() && !param.IsCancel.ToBooleanHasNull())
            {
                throw new WarnException("当前单据已属于正常状态,不允许重复执当前操作!");
            }
            #endregion
            if (param.IsCancel.ToBooleanHasNull())
            {
                #region 判断是否存在对应的入库单
                if (Exists <STK_In>(STK_In._.GCompanyID == this.SessionInfo.CompanyID && STK_In._.BillType == "PO_IN" && STK_In._.SourceBillGuid == param.POGuid && STK_In._.IsDeleted == false))
                {
                    throw new WarnException("存在对应的入库单,不允许取消当前单据!");
                }
                #endregion
                #region 更新采购单
                this.Update <ORD_PurchaseOrder>(new ORD_PurchaseOrder()
                {
                    IsCancel = true, UpdatedTime = DateTime.Now, UpdatedEmpID = this.SessionInfo.UserID, UpdatedEmpName = this.SessionInfo.UserName
                }
                                                , ORD_PurchaseOrder._.POGuid == param.POGuid && ORD_PurchaseOrder._.GCompanyID == this.SessionInfo.CompanyID);
                #endregion
            }
            else//收回取消
            {
                #region 更新采购单
                this.Update <ORD_PurchaseOrder>(new ORD_PurchaseOrder()
                {
                    IsCancel = false, UpdatedTime = DateTime.Now, UpdatedEmpID = this.SessionInfo.UserID, UpdatedEmpName = this.SessionInfo.UserName
                }
                                                , ORD_PurchaseOrder._.POGuid == param.POGuid && ORD_PurchaseOrder._.GCompanyID == this.SessionInfo.CompanyID);
                #endregion
            }
            ret.Key = 1;
            return(ret);
        }
示例#23
0
        private void tsbUnDo_Click(object sender, EventArgs e)
        {
            ORD_PurchaseOrderResult info = Form_GetEditEntity() as ORD_PurchaseOrderResult;

            this.WF_CancelCheckBill("ORD_PurchaseOrder", info.POGuid, InitData);
        }