Пример #1
0
        public void AddLine(ISession session, string po, string poLine, string area, string section, decimal qty)
        {
            if (this.Status != POReturnStatus.New)
                throw new Exception("�ɹ��˻��������½�״̬���޷������ϸ");
            POLine line = POLine.Retrieve(session, po, poLine);
            if (line == null)
                throw new Exception(po + "��" + poLine + "������");
            if (line.ReceiveQty < qty)
                throw new Exception(po + "��" + poLine + "�˻�����" + qty.ToString() + "�����ջ�����" + line.ReceiveQty.ToString());
            StockDetail sto = StockDetail.Retrieve(session, line.SKUID, this.LocationCode, area, section);
            if (sto == null)
                throw new Exception(po + "��" + poLine + "�����ϸ(" + area + "," + section + ")������");
            if (sto.StockQty < qty)
                throw new Exception(po + "��" + poLine + "�˻�����" + qty.ToString() + "���ڿ����" + sto.StockQty.ToString());

            DbSession dbsession = session.DbSession as DbSession;
            IDbCommand cmd = dbsession.CreateSqlStringCommand("Select Sum(a.rtn_qty) From ord_pur_rtn_line a Where a.po_num=:po And a.po_line=:poline");
            dbsession.AddParameter(cmd, ":po", DbTypeInfo.AnsiString(16), po);
            dbsession.AddParameter(cmd, ":poline", DbTypeInfo.AnsiString(4), poLine);
            decimal returnedQty = Cast.Decimal(dbsession.ExecuteScalar(cmd));
            if (returnedQty + qty > line.ReceiveQty)
                throw new Exception(po + "��" + poLine + "�����˻�����" + returnedQty.ToString() + "�����˻�����" + qty.ToString() + "�����ջ�����" + line.ReceiveQty.ToString());

            POReturnLine rtnLine = new POReturnLine();
            rtnLine.OrderNumber = this.OrderNumber;
            rtnLine.LineNumber = this.NextLineNumber();
            rtnLine.PONumber = po;
            rtnLine.POLine = poLine;
            rtnLine.SKUID = line.SKUID;
            rtnLine.Price = line.Price;
            rtnLine.Quantity = qty;
            rtnLine.TaxValue = line.TaxValue;
            rtnLine.StockDetailID = sto.StockDetailID;
            rtnLine.Create(session);
        }
Пример #2
0
        public void AddLine(ISession session, string po, string poLine, string area, string section, decimal qty)
        {
            if (this.Status != POReturnStatus.New)
            {
                throw new Exception("采购退货单不是新建状态,无法添加明细");
            }
            POLine line = POLine.Retrieve(session, po, poLine);

            if (line == null)
            {
                throw new Exception(po + "行" + poLine + "不存在");
            }
            if (line.ReceiveQty < qty)
            {
                throw new Exception(po + "行" + poLine + "退货数量" + qty.ToString() + "大于收货数量" + line.ReceiveQty.ToString());
            }
            StockDetail sto = StockDetail.Retrieve(session, line.SKUID, this.LocationCode, area, section);

            if (sto == null)
            {
                throw new Exception(po + "行" + poLine + "库存明细(" + area + "," + section + ")不存在");
            }
            if (sto.StockQty < qty)
            {
                throw new Exception(po + "行" + poLine + "退货数量" + qty.ToString() + "大于库存量" + sto.StockQty.ToString());
            }

            DbSession  dbsession = session.DbSession as DbSession;
            IDbCommand cmd       = dbsession.CreateSqlStringCommand("Select Sum(a.rtn_qty) From ord_pur_rtn_line a Where a.po_num=:po And a.po_line=:poline");

            dbsession.AddParameter(cmd, ":po", DbTypeInfo.AnsiString(16), po);
            dbsession.AddParameter(cmd, ":poline", DbTypeInfo.AnsiString(4), poLine);
            decimal returnedQty = Cast.Decimal(dbsession.ExecuteScalar(cmd));

            if (returnedQty + qty > line.ReceiveQty)
            {
                throw new Exception(po + "行" + poLine + ",已退货数量" + returnedQty.ToString() + "本次退货数量" + qty.ToString() + "大于收货数量" + line.ReceiveQty.ToString());
            }

            POReturnLine rtnLine = new POReturnLine();

            rtnLine.OrderNumber   = this.OrderNumber;
            rtnLine.LineNumber    = this.NextLineNumber();
            rtnLine.PONumber      = po;
            rtnLine.POLine        = poLine;
            rtnLine.SKUID         = line.SKUID;
            rtnLine.Price         = line.Price;
            rtnLine.Quantity      = qty;
            rtnLine.TaxValue      = line.TaxValue;
            rtnLine.StockDetailID = sto.StockDetailID;
            rtnLine.Create(session);
        }