示例#1
0
        /// <summary>
        /// 添加收货明细,引用POLine信息
        /// </summary>
        /// <param name="session"></param>
        /// <param name="poLine"></param>
        /// <returns></returns>
        public bool AddLine(ISession session, POLine poLine)
        {
            if (poLine.ReceivableQty() <= 0M)
            {
                return(false);
            }
            if (!poLine.UnfinishedReceiveQtyChange(session, poLine.ReceivableQty()))
            {
                return(false);
            }

            RCVLine line = new RCVLine();

            line.OrderNumber    = this.OrderNumber;
            line.LineNumber     = this.NextLineNumber();
            line.TransTypeCode  = " ";
            line.LocationCode   = this.LocationCode;
            line.SKUID          = poLine.SKUID;
            line.UnitID         = poLine.UnitID;
            line.RefQty         = poLine.ReceivableQty();
            line.RCVTotalQty    = poLine.ReceivableQty();
            line.QualifiedQty   = poLine.ReceivableQty();
            line.UnQualifiedQty = 0M;
            line.RefOrderLine   = line.OriginalOrderLine = poLine.LineNumber;
            line.TaxValue       = 0M; // poLine.TaxValue; 系统默认进项税不可以退税抵扣,所以交易税率设置为0,需财务手工确定可以抵扣的进项税率
            line.Price          = poLine.Price;
            return(line.Create(session));
        }
示例#2
0
        /// <summary>
        /// ����ջ���ϸ������POLine��Ϣ
        /// </summary>
        /// <param name="session"></param>
        /// <param name="poLine"></param>
        /// <returns></returns>
        public bool AddLine(ISession session, POLine poLine)
        {
            if (poLine.ReceivableQty() <= 0M) return false;
            if (!poLine.UnfinishedReceiveQtyChange(session, poLine.ReceivableQty())) return false;

            RCVLine line = new RCVLine();
            line.OrderNumber = this.OrderNumber;
            line.LineNumber = this.NextLineNumber();
            line.TransTypeCode = " ";
            line.LocationCode = this.LocationCode;
            line.SKUID = poLine.SKUID;
            line.UnitID = poLine.UnitID;
            line.RefQty = poLine.ReceivableQty();
            line.RCVTotalQty = poLine.ReceivableQty();
            line.QualifiedQty = poLine.ReceivableQty();
            line.UnQualifiedQty = 0M;
            line.RefOrderLine = line.OriginalOrderLine = poLine.LineNumber;
            line.TaxValue = 0M;  // poLine.TaxValue; ϵͳĬ�Ͻ���˰��������˰�ֿۣ����Խ���˰������Ϊ0��������ֹ�ȷ�����Եֿ۵Ľ���˰��
            line.Price = poLine.Price;
            return line.Create(session);
        }
示例#3
0
        public SimpleJson AddLine(ISession session, string poLineNumber, string areaCode, string sectionCode, decimal qty)
        {
            //���
            if (string.IsNullOrEmpty(poLineNumber) || poLineNumber.Trim().Length <= 0)
                return new SimpleJson().HandleError("PO����");
            if (string.IsNullOrEmpty(areaCode) || areaCode.Trim().Length <= 0)
                return new SimpleJson().HandleError("��λΪ��");
            if (!string.IsNullOrEmpty(sectionCode) && sectionCode.Trim().Length > 0)
            {
                WHSection section = WHSection.Retrieve(session, areaCode, sectionCode);
                if (session == null)
                    return new SimpleJson()
                        .HandleError("��λ" + areaCode.Trim().ToUpper() + "�еĻ���" + sectionCode.Trim().ToUpper() + "������");
            }
            if (qty <= 0) return new SimpleJson().HandleError("�ջ�����" + qty.ToString() + "С��0");
            POLine poLine = POLine.Retrieve(session, this.RefOrderNumber, poLineNumber);
            if (poLine == null) return new SimpleJson().HandleError("PO " + this.RefOrderNumber + "�����" + poLineNumber + "����");
            if (poLine.ReceivableQty() <= 0M)
                return new SimpleJson().HandleError("����" + this.RefOrderNumber + "��" + poLineNumber + "���ջ�����Ϊ0");
            if (!poLine.UnfinishedReceiveQtyChange(session, qty))
                return new SimpleJson().HandleError("�޷����¶���" + this.RefOrderNumber + "��" + poLineNumber + "�Ĵ��������");

            RCVLine line = new RCVLine();
            line.OrderNumber = this.OrderNumber;
            line.LineNumber = this.NextLineNumber();
            line.TransTypeCode = " ";
            line.LocationCode = this.LocationCode;
            line.AreaCode = areaCode.Trim().ToUpper();
            line.SectionCode = string.IsNullOrEmpty(sectionCode) ? " " : sectionCode.Trim().ToUpper();
            line.SKUID = poLine.SKUID;
            line.UnitID = poLine.UnitID;
            line.RefQty = poLine.ReceivableQty();
            line.RCVTotalQty = qty;
            line.QualifiedQty = qty;
            line.UnQualifiedQty = 0M;
            line.RefOrderLine = line.OriginalOrderLine = poLine.LineNumber;
            line.TaxValue = 0M; // poLine.TaxValue;  ϵͳĬ�Ͻ���˰��������˰�ֿۣ����Խ���˰������Ϊ0��������ֹ�ȷ�����Եֿ۵Ľ���˰��
            line.Price = poLine.Price;
            line.Create(session);

            this.Update(session, "CurrentLineNumber");

            return new SimpleJson();
        }
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        if (e.CommandName == "Save")
        {
            #region ����
            //�������Ҳ��ʱ�������ã���Ϊ����ɨ����ⷽʽ��������Ҫ���ƻ��ܡ���λ����
            IList<RCVLine> linesToSave = new List<RCVLine>();
            foreach (RepeaterItem item in this.repeatControl.Items)
            {
                HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox;
                TextBox text;
                RCVLine line = new RCVLine();
                line.OrderNumber = this.OrderNumber;
                line.LineNumber = chk.Value.Trim();
                text = item.FindControl("txtQualifiedQty") as TextBox;
                line.QualifiedQty = Cast.Decimal(text.Text.Trim());
                line.RCVTotalQty = line.QualifiedQty;

                linesToSave.Add(line);
            }

            using (ISession session = new Session())
            {
                try
                {
                    //���
                    RCVHead head = RCVHead.Retrieve(session, this.OrderNumber);
                    if (head == null) return;
                    head.UpdateLines(session, linesToSave);
                    WebUtil.ShowMsg(this, "����ɹ�");
                }
                catch (Exception er)
                {
                    WebUtil.ShowError(this, er);
                }
            }
            #endregion
        }
        else if (e.CommandName == "Delete")
        {
            #region ɾ��
            using (ISession session = new Session())
            {
                IList<RCVLine> linesToDelete = new List<RCVLine>();
                foreach (RepeaterItem item in this.repeatControl.Items)
                {
                    HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox;
                    if (chk.Checked)
                    {
                        RCVLine line = RCVLine.Retrieve(session, this.OrderNumber, chk.Value.Trim());
                        if (line != null)
                            linesToDelete.Add(line);
                    }
                }

                try
                {
                    //���
                    RCVHead head = RCVHead.Retrieve(session, this.OrderNumber);
                    if (head == null) return;
                    session.BeginTransaction();
                    head.DeleteLines(session, linesToDelete);
                    session.Commit();
                    this.QueryAndBindData(session, head);
                    WebUtil.ShowMsg(this, "ѡ�����ϸ�Ѿ�ɾ��");
                }
                catch (Exception er)
                {
                    session.Rollback();
                    WebUtil.ShowError(this, er);
                }
            }
            #endregion
        }
        else if (e.CommandName == "Release")
        {
            #region ����
            using (ISession session = new Session())
            {
                try
                {
                    session.BeginTransaction();
                    RCVHead head = RCVHead.Retrieve(session, this.OrderNumber);
                    head.Release(session);
                    session.Commit();
                    WebUtil.ShowMsg(this, "�����ɹ�");
                    this.QueryAndBindData(session, head);
                    this.SetView(head);
                }
                catch (Exception er)
                {
                    session.Rollback();
                    WebUtil.ShowError(this, er);
                }
            }
            #endregion
        }
        else if (e.CommandName == "Close")
        {
            #region �ر�
            using (ISession session = new Session())
            {
                try
                {
                    RCVHead head = RCVHead.Retrieve(session, this.OrderNumber);
                    session.BeginTransaction();
                    head.Close(session, true);
                    session.Commit();
                    WebUtil.ShowMsg(this, "�����ɹ�");
                    this.QueryAndBindData(session, head);
                    this.SetView(head);
                }
                catch (Exception er)
                {
                    session.Rollback();
                    WebUtil.ShowError(this, er);
                }
            }
            #endregion
        }
    }
示例#5
0
        public int UpdateLines(ISession session, IList <RCVLine> linesValue)
        {
            if (linesValue == null || linesValue.Count <= 0)
            {
                return(0);
            }

            #region 检查
            IList <RCVLine>           lines = new List <RCVLine>(linesValue.Count);
            bool                      error = false, errorHead = false;
            System.Text.StringBuilder builder    = new System.Text.StringBuilder();
            bool                      hasSection = false;
            foreach (RCVLine lv in linesValue)
            {
                errorHead = false;
                //收货数量是否有效
                if (lv.RCVTotalQty <= 0M)
                {
                    error = true;
                    if (!errorHead)
                    {
                        builder.Append("行号").Append(lv.LineNumber).Append(": ");
                    }
                    errorHead = true;
                    builder.Append("收货数量小于0; ");
                    continue;
                }
                RCVLine l = RCVLine.Retrieve(session, lv.OrderNumber, lv.LineNumber);
                //可以不填写货架,但如果填写了,则检查货架有效性
                WHSection section = null;
                hasSection = false;
                //库位、货架容量检查
                WHArea area = WHArea.Retrieve(session, l.AreaCode);
                if (!string.IsNullOrEmpty(l.SectionCode) && l.SectionCode.Trim().Length > 0)
                {
                    hasSection = true;
                    section    = WHSection.Retrieve(session, l.AreaCode, l.SectionCode);
                }
                decimal capacityFree = 0M;
                //取库位、货架容量
                if (hasSection)
                {
                    capacityFree = section.SectionCapacity;
                }
                else
                {
                    capacityFree = area.AreaCapacity;
                }
                //库位容量扣减当前已存放量
                if (hasSection)
                {
                    capacityFree = capacityFree - Cast.Decimal(session.CreateObjectQuery(@"
select sum(StockQty) from StockDetail 
where AreaCode=?area and SectionCode=?section")
                                                               .Attach(typeof(StockDetail))
                                                               .SetValue("?area", area.AreaCode, "AreaCode")
                                                               .SetValue("?section", section.SectionCode, "SectionCode")
                                                               .Scalar(), 0M);
                }
                else
                {
                    capacityFree = capacityFree - Cast.Decimal(session.CreateObjectQuery(@"select sum(StockQty) from StockDetail where AreaCode=?area")
                                                               .Attach(typeof(StockDetail))
                                                               .SetValue("?area", area.AreaCode, "AreaCode")
                                                               .Scalar(), 0M);
                }
                //剩余容量和本次入库量比较
                if (capacityFree < lv.QualifiedQty)
                {
                    builder.Append("行号").Append(lv.LineNumber).Append(": ");
                    error = true;
                    builder.Append("入库量").Append(lv.QualifiedQty).Append("大于剩余容量").Append(capacityFree);
                }
                if (!error)
                {
                    lines.Add(l);
                }
            }
            if (error)
            {
                throw new Exception(builder.ToString());
            }
            #endregion

            int       count     = 0;
            DbSession dbsession = session.DbSession as DbSession;
            session.BeginTransaction();
            for (int i = 0; i < lines.Count; i++)
            {
                RCVLine line   = lines[i];
                POLine  poLine = null;
                if (!string.IsNullOrEmpty(this._refOrderNumber) && this._refOrderNumber.Trim().Length > 0 &&
                    !string.IsNullOrEmpty(line.RefOrderLine) && line.RefOrderLine.Trim().Length > 0)
                {
                    poLine = POLine.Retrieve(session, this._refOrderNumber, line.RefOrderLine);
                }
                if (poLine != null)
                {
                    IDbCommand cmd = dbsession.CreateStoredProcCommand("F_PUR_RCV_TOLERANCE_RATIO", new object[] { 0, poLine.OrderNumber });
                    dbsession.ExecuteNonQuery(cmd);
                    IDbDataParameter p      = cmd.Parameters[0] as IDbDataParameter;
                    decimal          ration = Cast.Decimal(p.Value);
                    if (poLine.PurchaseQty * (1 + ration) - poLine.ReceiveQty - poLine.UnfinishedReceiveQty - linesValue[i].QualifiedQty + line.QualifiedQty < 0)
                    {
                        error = true;
                        builder.Append("行号").Append(line.LineNumber).Append("收货数量").Append(linesValue[i].QualifiedQty)
                        .Append("超过PO最大可收货数量").Append(Math.Floor(poLine.PurchaseQty * (1 + ration)) - poLine.ReceiveQty - poLine.UnfinishedReceiveQty + line.QualifiedQty);
                        break;
                    }
                    poLine.UnfinishedReceiveQtyChange(session, linesValue[i].QualifiedQty - line.QualifiedQty);
                }
                line.RCVTotalQty  = linesValue[i].RCVTotalQty;
                line.QualifiedQty = linesValue[i].QualifiedQty;
                line.Update(session, "RCVTotalQty", "QualifiedQty");

                count++;
            }
            if (error)
            {
                session.Rollback();
                throw new Exception(builder.ToString());
            }
            else
            {
                session.Commit();
            }

            return(count);
        }
示例#6
0
        public SimpleJson AddLine(ISession session, string poLineNumber, string areaCode, string sectionCode, decimal qty)
        {
            //检查
            if (string.IsNullOrEmpty(poLineNumber) || poLineNumber.Trim().Length <= 0)
            {
                return(new SimpleJson().HandleError("PO行为空"));
            }
            if (string.IsNullOrEmpty(areaCode) || areaCode.Trim().Length <= 0)
            {
                return(new SimpleJson().HandleError("库位为空"));
            }
            if (!string.IsNullOrEmpty(sectionCode) && sectionCode.Trim().Length > 0)
            {
                WHSection section = WHSection.Retrieve(session, areaCode, sectionCode);
                if (session == null)
                {
                    return(new SimpleJson()
                           .HandleError("库位" + areaCode.Trim().ToUpper() + "中的货架" + sectionCode.Trim().ToUpper() + "不存在"));
                }
            }
            if (qty <= 0)
            {
                return(new SimpleJson().HandleError("收货数量" + qty.ToString() + "小于0"));
            }
            POLine poLine = POLine.Retrieve(session, this.RefOrderNumber, poLineNumber);

            if (poLine == null)
            {
                return(new SimpleJson().HandleError("PO " + this.RefOrderNumber + "中不存在" + poLineNumber + "的行"));
            }
            if (poLine.ReceivableQty() <= 0M)
            {
                return(new SimpleJson().HandleError("订单" + this.RefOrderNumber + "行" + poLineNumber + "可收货数量为0"));
            }
            if (!poLine.UnfinishedReceiveQtyChange(session, qty))
            {
                return(new SimpleJson().HandleError("无法更新订单" + this.RefOrderNumber + "行" + poLineNumber + "的待入库数量"));
            }

            RCVLine line = new RCVLine();

            line.OrderNumber    = this.OrderNumber;
            line.LineNumber     = this.NextLineNumber();
            line.TransTypeCode  = " ";
            line.LocationCode   = this.LocationCode;
            line.AreaCode       = areaCode.Trim().ToUpper();
            line.SectionCode    = string.IsNullOrEmpty(sectionCode) ? " " : sectionCode.Trim().ToUpper();
            line.SKUID          = poLine.SKUID;
            line.UnitID         = poLine.UnitID;
            line.RefQty         = poLine.ReceivableQty();
            line.RCVTotalQty    = qty;
            line.QualifiedQty   = qty;
            line.UnQualifiedQty = 0M;
            line.RefOrderLine   = line.OriginalOrderLine = poLine.LineNumber;
            line.TaxValue       = 0M; // poLine.TaxValue;  系统默认进项税不可以退税抵扣,所以交易税率设置为0,需财务手工确定可以抵扣的进项税率
            line.Price          = poLine.Price;
            line.Create(session);

            this.Update(session, "CurrentLineNumber");

            return(new SimpleJson());
        }