Example #1
0
        /// <summary>
        /// 删除实体
        /// </summary>
        /// <param name="param">删除条件实体</param>
        /// <returns></returns>
        public WCFAddUpdateResult DelInfo(STK_OutLineParam param)
        {
            this.CheckSession();
            WCFAddUpdateResult ret = new WCFAddUpdateResult();
            int affect             = 0;

            try
            {
                #region 判断
                if (param.StkOutLineGuid == null)
                {
                    throw new WarnException("请指定明细GUID!");
                }
                #endregion
                WhereClip         whereClip = GetWhereClip(param);
                STK_OutLineResult info      = new STK_OutLineResult();
                info.IsDeleted = true;
                affect         = this.Update <STK_OutLineResult>(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);
        }
Example #2
0
        public STK_OutLineResult GetInfo(STK_OutLineParam param)
        {
            STK_OutLineResult ret = new STK_OutLineResult();
            ExeResult         rst = new ExeResult();

            rst = this.Execute("ZNLCRM.BLL.STK.STK_OutLineBLL", "GetInfo", param);
            ret = rst == null ? new STK_OutLineResult() : rst.Result as STK_OutLineResult;
            return(ret);
        }
Example #3
0
        private void btnAddRow_Click(object sender, EventArgs e)
        {
            bsStkOutLine.AddNew();
            STK_OutLineResult rst = bsStkOutLine.Current as STK_OutLineResult;

            rst.Currency     = cboCurrency.SelectedValue.ToStringHasNull();
            rst.ExchangeRate = txtExchangeRate.Text.ToDecimal();
            rst.Unit         = "PCS";
            rst.TaxRate      = cboTaxRate.SelectedValue.ToDecimal();
        }
Example #4
0
 private void btnDelRow_Click(object sender, EventArgs e)
 {
     if (this.bsStkOutLine.Current != null)
     {
         Guid?stkOutLineGuid         = null;
         STK_OutLineResult delResult = this.bsStkOutLine.Current as STK_OutLineResult;
         stkOutLineGuid = delResult.StkOutLineGuid;
         if (stkOutLineGuid != null)
         {
             delResult.IsDeleted = true;
             delList.Add(delResult);
         }
         bsStkOutLine.RemoveCurrent();
     }
 }
Example #5
0
        /// <summary>
        /// 获取一条信息记录
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public STK_OutLineResult GetInfo(STK_OutLineParam param)
        {
            this.CheckSession();
            STK_OutLineResult rst = new STK_OutLineResult();

            #region 判断
            if (param.StkOutLineGuid == null)
            {
                throw new WarnException("请指定明细GUID!");
            }
            #endregion
            #region 获取实体

            rst = this.Select <STK_OutLineResult>(GetWhereClip(param));

            #endregion
            return(rst);
        }
Example #6
0
 public void SetStkLineObjectValue(STK_OutLineResult outLineRst, STK_StockReserveResult reserveResult)
 {
     outLineRst.SRGuid             = reserveResult.SRGuid;
     outLineRst.StkInLineGuid      = reserveResult.StkInLineGuid;
     outLineRst.ItemCode           = reserveResult.ItemCode;
     outLineRst.SourceBillGuid     = reserveResult.SourceBillGuid;
     outLineRst.SourceBillLineGuid = reserveResult.SourceBillLineGuid;
     outLineRst.Model        = reserveResult.Model;
     outLineRst.Brand        = reserveResult.Brand;
     outLineRst.Package      = reserveResult.Package;
     outLineRst.Batch        = reserveResult.Batch;
     outLineRst.TaxRate      = cboTaxRate.SelectedValue.ToDecimal();
     outLineRst.InvType      = reserveResult.InvType;
     outLineRst.Currency     = cboCurrency.SelectedValue.ToStringHasNull();
     outLineRst.Unit         = reserveResult.Unit;
     outLineRst.Qty          = reserveResult.ReserveQty.ToInt32() - reserveResult.UsedQty.ToInt32();
     outLineRst.Amount       = outLineRst.Qty * outLineRst.UnitPrice;
     outLineRst.Warehouse    = reserveResult.Warehouse;
     outLineRst.Location     = reserveResult.Location;
     outLineRst.IsCut        = true;
     outLineRst.IsPCut       = true;
     outLineRst.IsRaiseTaxes = false;
     outLineRst.IsDeleted    = false;
 }
Example #7
0
        public bool SubmitStkOutBill(STK_OutParam param)
        {
            this.CheckSession();
            bool submitFlag = true;

            try
            {
                STK_OutResult outResult = this.GetInfo(param);

                if (outResult != null)
                {
                    #region 判断是否可以提交
                    bool isAllowSubmit = true;
                    if (outResult.ApproveStatus == "待审核")
                    {
                        isAllowSubmit = false;
                        throw new WarnException("入库单当前状态为:【已提交,待审核】,禁止重复提交!");
                    }
                    else if (outResult.ApproveStatus == "审核完成")
                    {
                        isAllowSubmit = false;
                        throw new WarnException("入库单当前状态为:【审核完成】,撤单后才可以再次提交!");
                    }

                    #region 提交时判断预留信息使用数量是否大于预留数量,如果大于预留数量是不允许提交的
                    List <STK_OutLineResult> outLineList = outResult.StkOutLineList;
                    Guid?[]             SRGuids          = outLineList.Select(a => a.SRGuid).Distinct().ToArray();
                    STK_StockReserveBLL reserveBLL       = new STK_StockReserveBLL();
                    reserveBLL.SessionInfo = this.SessionInfo;

                    List <STK_StockReserveResult> reserveList = reserveBLL.GetList(new STK_StockReserveParam()
                    {
                        SRGuids = SRGuids
                    });
                    foreach (STK_StockReserveResult reserveResult in reserveList)
                    {
                        reserveResult.UsedQty    = reserveResult.UsedQty.ToInt32();
                        reserveResult.ReserveQty = reserveResult.ReserveQty.ToInt32();
                        int?usedQty = 0;
                        STK_OutLineResult outLineResult = outLineList.FirstOrDefault(a => a.SRGuid == reserveResult.SRGuid);
                        if (outLineResult != null)
                        {
                            usedQty = outLineResult.Qty;
                        }
                        if ((reserveResult.UsedQty + usedQty) > reserveResult.ReserveQty)
                        {
                            isAllowSubmit = false;
                            break;
                        }
                        reserveResult.UsedQty += usedQty;
                    }

                    if (isAllowSubmit)
                    {
                        #region 回写库存预留的出库数量
                        WCFAddUpdateResult ret = reserveBLL.UpdateOrInsertList(reserveList);
                        if (ret.Key <= 0)
                        {
                            submitFlag = false;
                            throw new WarnException("回写出库单明细关联的库存预留明细的出库数量失败,禁止提交出库单!");
                        }
                        #endregion

                        #region 更新出库单的状态
                        outResult.Status        = "Approve";
                        outResult.ApproveStatus = "待审核";
                        this.AddOrUpdate(outResult);
                        #endregion
                    }
                    else
                    {
                        submitFlag = false;
                        throw new WarnException("出库单明细所关联库存预留明细的出库数量+此次出库数量>库存预留数量,禁止提交出库单!");
                    }
                    #endregion
                    #endregion
                }
                else
                {
                    throw  new WarnException("要提交的出库单在系统中不存在!");
                }
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
                throw exp;
            }
            return(submitFlag);
        }
Example #8
0
        private void ImportStockReserve(bool isMutiSelect)
        {
            if (!string.IsNullOrEmpty(txtSourceBillGuid.Text))
            {
                frmSelectStockReserve frm = new frmSelectStockReserve(isMutiSelect);
                frm.SourceBillGuid = txtSourceBillGuid.Text.ToGuid();

                Guid?  SourceBillLineGuid = Guid.Empty;
                Guid?  SRGuid             = Guid.Empty;
                string model = string.Empty;

                if (!isMutiSelect)
                {
                    SourceBillLineGuid = dgvStkOutLine.CurrentRow.Cells["colSourceBillLineGuid"].Value.ToGuid();
                    model  = dgvStkOutLine.CurrentRow.Cells["colModel"].Value.ToStringHasNull();
                    SRGuid = dgvStkOutLine.CurrentRow.Cells["colSRGuid"].Value.ToGuid();
                }

                if (!string.IsNullOrEmpty(model))
                {
                    frm.Model = model;
                }
                if (SourceBillLineGuid != Guid.Empty)//如果已经存在关联的源单据明细ID,则只筛选此条明细
                {
                    frm.SourceBillLineGuid = SourceBillLineGuid;
                }
                if (SRGuid != Guid.Empty)//如果已经存在关联的预留ID,则只能筛选此条明细
                {
                    frm.SRGuid = SRGuid;
                }
                else//如果是新行,则排除掉已经存在列表里面的所有的源单据明细
                {
                    Guid?[] NoSRGuids = addOrModifyList.Where(a => a.SRGuid.ToGuid() != Guid.Empty).Select(a => a.SRGuid).Distinct().ToArray();
                    frm.NoSRGuids = NoSRGuids;
                }
                frm.BringToFront();
                frm.StartPosition = FormStartPosition.CenterScreen;
                DialogResult rst = frm.ShowDialog();
                if (rst == DialogResult.OK)
                {
                    List <STK_StockReserveResult> rstList = frm.GetSelectList <STK_StockReserveResult>();
                    if (rstList != null && rstList.Count > 0)
                    {
                        foreach (STK_StockReserveResult reserveResult in rstList)
                        {
                            bool isAddNew = true;
                            foreach (DataGridViewRow row in dgvStkOutLine.Rows)
                            {
                                //如果是已经存在的行,则利用现成的行进行编辑

                                if (row.Cells["colSRGuid"].Value.ToGuid() == reserveResult.SRGuid)
                                {
                                    isAddNew = false;
                                    STK_OutLineResult stkOutLineResult = bsStkOutLine[row.Index] as STK_OutLineResult;
                                    SetStkLineObjectValue(stkOutLineResult, reserveResult);
                                    break;
                                }
                            }
                            if (isAddNew)
                            {
                                if (!isMutiSelect)//单选
                                {
                                    STK_OutLineResult stkOutLineResult = bsStkOutLine.Current as STK_OutLineResult;
                                    SetStkLineObjectValue(stkOutLineResult, reserveResult);
                                }
                                else//多选
                                {
                                    STK_OutLineResult stkOutLineResult = new STK_OutLineResult();
                                    SetStkLineObjectValue(stkOutLineResult, reserveResult);
                                    bsStkOutLine.Add(stkOutLineResult);
                                }
                            }
                        }
                    }
                }
                dgvStkOutLine.EndEdit();
                CalcExchangeRate();
            }
            else
            {
                MessageBox.Show("请先选择源单据!");
            }
        }
Example #9
0
        public void InitSourceData(string billType, object obj)
        {
            if (obj != null)
            {
                if (cboBillType.SelectedValue.ToStringHasNull() == "")
                {
                    SYS_DictItemLineLogic.SetCombolSelectedIndex(cboBillType, billType, true);
                }
                if (obj is ORD_SalesOrderResult)
                {
                    ORD_SalesOrderResult salesOrderResult = obj as ORD_SalesOrderResult;
                    if (salesOrderResult != null)
                    {
                        txtSourceBillGuid.Text    = salesOrderResult.SOGuid.ToStringHasNull();
                        txtSourceBillNo.Text      = salesOrderResult.BillNo;
                        cboTaxRate.SelectedValue  = salesOrderResult.TaxRate == null ? 0 : salesOrderResult.TaxRate;
                        cboCurrency.SelectedValue = salesOrderResult.Currency;
                        List <STK_StockReserveResult> reserveList = reserveLogic.GetList(new STK_StockReserveParam()
                        {
                            SourceBillGuid = salesOrderResult.SOGuid, IsUsedOver = false
                        });
                        List <ORD_SalesOrderLineResult> lineList = null;
                        if (salesOrderResult.OrderLineList != null)//从其他窗体点击出库进入,只传递guid,通过guid获取的对象中含有明细
                        {
                            lineList = salesOrderResult.OrderLineList.Where(a => a.StkOutOccQty.ToInt32() < a.Qty).ToList();
                        }
                        else//在出库窗体打开选择窗体得到的对象是没有包含明细的,需要去单独获取明细
                        {
                            lineList = orderLineLogic.GetList(new ORD_SalesOrderLineParam()
                            {
                                SOGuid = salesOrderResult.SOGuid
                            }).Where(a => a.StkOutOccQty.ToInt32() < a.Qty).ToList();
                        }

                        foreach (STK_StockReserveResult reserveResult in reserveList)
                        {
                            STK_OutLineResult        stkOutLineResult = new STK_OutLineResult();
                            ORD_SalesOrderLineResult lineResult       = lineList.FirstOrDefault(a => a.SOLineGuid == reserveResult.SourceBillLineGuid);
                            if (lineResult != null)
                            {
                                stkOutLineResult.UnitPrice = lineResult.UnitPrice;
                            }
                            SetStkLineObjectValue(stkOutLineResult, reserveResult);
                            bsStkOutLine.Add(stkOutLineResult);
                        }
                    }
                }
                else if (obj is ORD_PurchaseReturnResult)
                {
                    ORD_PurchaseReturnResult purReturnResult = obj as ORD_PurchaseReturnResult;
                    if (purReturnResult != null)
                    {
                        txtSourceBillGuid.Text = purReturnResult.POGuid.ToStringHasNull();
                        txtSourceBillNo.Text   = purReturnResult.BillNo;
                        decimal?taxRate = 0;
                        cboTaxRate.SelectedValue  = taxRate;
                        cboCurrency.SelectedValue = purReturnResult.Currency;
                        List <STK_StockReserveResult> reserveList = reserveLogic.GetList(new STK_StockReserveParam()
                        {
                            SourceBillGuid = purReturnResult.PRGuid, IsUsedOver = false
                        });
                        List <ORD_PurchaseReturnLineResult> lineList = null;
                        if (purReturnResult.ReturnLineList != null)
                        {
                            lineList = purReturnResult.ReturnLineList.Where(a => a.StkOutOccQty.ToInt32() < a.Qty).ToList();
                        }
                        else
                        {
                            lineList = returnLineLogic.GetList(new ORD_PurchaseReturnLineParam()
                            {
                                PRGuid = purReturnResult.PRGuid
                            }).Where(a => a.StkOutOccQty.ToInt32() < a.Qty).ToList();
                        }

                        foreach (STK_StockReserveResult reserveResult in reserveList)
                        {
                            STK_OutLineResult            stkOutLineResult = new STK_OutLineResult();
                            ORD_PurchaseReturnLineResult lineResult       = lineList.FirstOrDefault(a => a.PRLineGuid == reserveResult.SourceBillLineGuid);
                            if (lineResult != null)
                            {
                                stkOutLineResult.UnitPrice = lineResult.UnitPrice;
                            }
                            SetStkLineObjectValue(stkOutLineResult, reserveResult);
                            bsStkOutLine.Add(stkOutLineResult);
                        }
                    }
                }
                CalcExchangeRate();
            }
        }
Example #10
0
        public void SetStkLineObjectValue(ORD_SalesReturnLineResult returnLineResult, STK_OutLineResult outLineRst)
        {
            returnLineResult.SOGuid     = outLineRst.SourceBillGuid;
            returnLineResult.SOBillNo   = outLineRst.SourceBillNo;//销售单号
            returnLineResult.SOLineGuid = outLineRst.SourceBillLineGuid;

            returnLineResult.StkOutGuid     = outLineRst.StkOutGuid;
            returnLineResult.StkOutBillNo   = outLineRst.StkOutBillNo;//出库单号
            returnLineResult.StkOutLineGuid = outLineRst.StkOutLineGuid;


            returnLineResult.BuyerID       = outLineRst.BuyerID;
            returnLineResult.BuyerName     = outLineRst.BuyerName;
            returnLineResult.StkInLineGuid = outLineRst.StkInLineGuid;
            returnLineResult.ItemCode      = outLineRst.ItemCode;
            returnLineResult.Model         = outLineRst.Model;
            returnLineResult.Brand         = outLineRst.Brand;
            returnLineResult.Package       = outLineRst.Package;
            returnLineResult.Batch         = outLineRst.Batch;
            returnLineResult.MPQ           = outLineRst.MPQ;
            returnLineResult.Quality       = outLineRst.Quality;
            returnLineResult.MarkCode      = outLineRst.MarkCode;
            returnLineResult.InvType       = outLineRst.InvType;
            returnLineResult.Currency      = outLineRst.Currency;
            returnLineResult.Unit          = outLineRst.Unit;
            returnLineResult.UnitPrice     = outLineRst.UnitPrice;
            returnLineResult.Qty           = outLineRst.Qty.ToInt32() - outLineRst.ReturnOccQty.ToInt32();
            returnLineResult.Amount        = returnLineResult.UnitPrice * returnLineResult.Qty;
            returnLineResult.Warehouse     = outLineRst.Warehouse;
            returnLineResult.Location      = outLineRst.Location;
            returnLineResult.IsDeleted     = false;
        }