Esempio n. 1
0
        public int InsertMaster(RMARefundInfo oParam)
        {
            string sql = @"INSERT INTO rma_refund
                            (
                            SysNo, RefundID, SOSysNo, CustomerSysNo,
                            CreateTime, CreateUserSysNo, AuditTime, AuditUserSysNo,
                            RefundTime, RefundUserSysNo, CompensateShipPrice, SOCashPointRate,
                            OrgCashAmt, OrgPointAmt, DeductPointFromAccount, DeductPointFromCurrentCash,
                            CashAmt, PointAmt, RefundPayType, Note,
                            Status
                            )
                            VALUES (
                            @SysNo, @RefundID, @SOSysNo, @CustomerSysNo,
                            @CreateTime, @CreateUserSysNo, @AuditTime, @AuditUserSysNo,
                            @RefundTime, @RefundUserSysNo, @CompensateShipPrice, @SOCashPointRate,
                            @OrgCashAmt, @OrgPointAmt, @DeductPointFromAccount, @DeductPointFromCurrentCash,
                            @CashAmt, @PointAmt, @RefundPayType, @Note,
                            @Status
                            )";

            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int,4);
            SqlParameter paramRefundID = new SqlParameter("@RefundID", SqlDbType.NVarChar,10);
            SqlParameter paramSOSysNo = new SqlParameter("@SOSysNo", SqlDbType.Int,4);
            SqlParameter paramCustomerSysNo = new SqlParameter("@CustomerSysNo", SqlDbType.Int,4);
            SqlParameter paramCreateTime = new SqlParameter("@CreateTime", SqlDbType.DateTime);
            SqlParameter paramCreateUserSysNo = new SqlParameter("@CreateUserSysNo", SqlDbType.Int,4);
            SqlParameter paramAuditTime = new SqlParameter("@AuditTime", SqlDbType.DateTime);
            SqlParameter paramAuditUserSysNo = new SqlParameter("@AuditUserSysNo", SqlDbType.Int,4);
            SqlParameter paramRefundTime = new SqlParameter("@RefundTime", SqlDbType.DateTime);
            SqlParameter paramRefundUserSysNo = new SqlParameter("@RefundUserSysNo", SqlDbType.Int,4);
            SqlParameter paramCompensateShipPrice = new SqlParameter("@CompensateShipPrice", SqlDbType.Decimal,9);
            SqlParameter paramSOCashPointRate = new SqlParameter("@SOCashPointRate", SqlDbType.Decimal,9);
            SqlParameter paramOrgCashAmt = new SqlParameter("@OrgCashAmt", SqlDbType.Decimal,9);
            SqlParameter paramOrgPointAmt = new SqlParameter("@OrgPointAmt", SqlDbType.Int,4);
            SqlParameter paramDeductPointFromAccount = new SqlParameter("@DeductPointFromAccount", SqlDbType.Int,4);
            SqlParameter paramDeductPointFromCurrentCash = new SqlParameter("@DeductPointFromCurrentCash", SqlDbType.Decimal,9);
            SqlParameter paramCashAmt = new SqlParameter("@CashAmt", SqlDbType.Decimal,9);
            SqlParameter paramPointAmt = new SqlParameter("@PointAmt", SqlDbType.Int,4);
            SqlParameter paramRefundPayType = new SqlParameter("@RefundPayType", SqlDbType.Int, 4);
            SqlParameter paramNote = new SqlParameter("@Note", SqlDbType.NVarChar,500);
            SqlParameter paramStatus = new SqlParameter("@Status", SqlDbType.Int,4);

            if ( oParam.SysNo != AppConst.IntNull)
                paramSysNo.Value = oParam.SysNo;
            else
                paramSysNo.Value = System.DBNull.Value;
            if ( oParam.RefundID != AppConst.StringNull)
                paramRefundID.Value = oParam.RefundID;
            else
                paramRefundID.Value = System.DBNull.Value;
            if ( oParam.SOSysNo != AppConst.IntNull)
                paramSOSysNo.Value = oParam.SOSysNo;
            else
                paramSOSysNo.Value = System.DBNull.Value;
            if ( oParam.CustomerSysNo != AppConst.IntNull)
                paramCustomerSysNo.Value = oParam.CustomerSysNo;
            else
                paramCustomerSysNo.Value = System.DBNull.Value;
            if ( oParam.CreateTime != AppConst.DateTimeNull)
                paramCreateTime.Value = oParam.CreateTime;
            else
                paramCreateTime.Value = System.DBNull.Value;
            if ( oParam.CreateUserSysNo != AppConst.IntNull)
                paramCreateUserSysNo.Value = oParam.CreateUserSysNo;
            else
                paramCreateUserSysNo.Value = System.DBNull.Value;
            if ( oParam.AuditTime != AppConst.DateTimeNull)
                paramAuditTime.Value = oParam.AuditTime;
            else
                paramAuditTime.Value = System.DBNull.Value;
            if ( oParam.AuditUserSysNo != AppConst.IntNull)
                paramAuditUserSysNo.Value = oParam.AuditUserSysNo;
            else
                paramAuditUserSysNo.Value = System.DBNull.Value;
            if ( oParam.RefundTime != AppConst.DateTimeNull)
                paramRefundTime.Value = oParam.RefundTime;
            else
                paramRefundTime.Value = System.DBNull.Value;
            if ( oParam.RefundUserSysNo != AppConst.IntNull)
                paramRefundUserSysNo.Value = oParam.RefundUserSysNo;
            else
                paramRefundUserSysNo.Value = System.DBNull.Value;
            if ( oParam.CompensateShipPrice != AppConst.DecimalNull)
                paramCompensateShipPrice.Value = oParam.CompensateShipPrice;
            else
                paramCompensateShipPrice.Value = System.DBNull.Value;
            if ( oParam.SOCashPointRate != AppConst.DecimalNull)
                paramSOCashPointRate.Value = oParam.SOCashPointRate;
            else
                paramSOCashPointRate.Value = System.DBNull.Value;
            if ( oParam.OrgCashAmt != AppConst.DecimalNull)
                paramOrgCashAmt.Value = oParam.OrgCashAmt;
            else
                paramOrgCashAmt.Value = System.DBNull.Value;
            if ( oParam.OrgPointAmt != AppConst.IntNull)
                paramOrgPointAmt.Value = oParam.OrgPointAmt;
            else
                paramOrgPointAmt.Value = System.DBNull.Value;
            if ( oParam.DeductPointFromAccount != AppConst.IntNull)
                paramDeductPointFromAccount.Value = oParam.DeductPointFromAccount;
            else
                paramDeductPointFromAccount.Value = System.DBNull.Value;
            if ( oParam.DeductPointFromCurrentCash != AppConst.DecimalNull)
                paramDeductPointFromCurrentCash.Value = oParam.DeductPointFromCurrentCash;
            else
                paramDeductPointFromCurrentCash.Value = System.DBNull.Value;
            if ( oParam.CashAmt != AppConst.DecimalNull)
                paramCashAmt.Value = oParam.CashAmt;
            else
                paramCashAmt.Value = System.DBNull.Value;
            if ( oParam.PointAmt != AppConst.IntNull)
                paramPointAmt.Value = oParam.PointAmt;
            else
                paramPointAmt.Value = System.DBNull.Value;
            if (oParam.RefundPayType != AppConst.IntNull)
                paramRefundPayType.Value = oParam.RefundPayType;
            else
                paramRefundPayType.Value = System.DBNull.Value;
            if ( oParam.Note != AppConst.StringNull)
                paramNote.Value = oParam.Note;
            else
                paramNote.Value = System.DBNull.Value;
            if ( oParam.Status != AppConst.IntNull)
                paramStatus.Value = oParam.Status;
            else
                paramStatus.Value = System.DBNull.Value;

            cmd.Parameters.Add(paramSysNo);
            cmd.Parameters.Add(paramRefundID);
            cmd.Parameters.Add(paramSOSysNo);
            cmd.Parameters.Add(paramCustomerSysNo);
            cmd.Parameters.Add(paramCreateTime);
            cmd.Parameters.Add(paramCreateUserSysNo);
            cmd.Parameters.Add(paramAuditTime);
            cmd.Parameters.Add(paramAuditUserSysNo);
            cmd.Parameters.Add(paramRefundTime);
            cmd.Parameters.Add(paramRefundUserSysNo);
            cmd.Parameters.Add(paramCompensateShipPrice);
            cmd.Parameters.Add(paramSOCashPointRate);
            cmd.Parameters.Add(paramOrgCashAmt);
            cmd.Parameters.Add(paramOrgPointAmt);
            cmd.Parameters.Add(paramDeductPointFromAccount);
            cmd.Parameters.Add(paramDeductPointFromCurrentCash);
            cmd.Parameters.Add(paramCashAmt);
            cmd.Parameters.Add(paramPointAmt);
            cmd.Parameters.Add(paramRefundPayType);
            cmd.Parameters.Add(paramNote);
            cmd.Parameters.Add(paramStatus);

            return SqlHelper.ExecuteNonQuery(cmd);
        }
Esempio n. 2
0
        public void ReCalc(RMARefundInfo oRefund)
        {
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {

                //�����dz�ʼ״̬
                if (getCurrentStatus(oRefund.SysNo) != (int)AppEnum.RMARefundStatus.WaitingRefund)
                    throw new BizException("status is not origin now,  re calc failed");

                Calc(oRefund);
                //update master;

                Hashtable htMaster = new Hashtable(5);
                htMaster.Add("SysNo", oRefund.SysNo);
                htMaster.Add("CompensateShipPrice", oRefund.CompensateShipPrice);
                htMaster.Add("OrgCashAmt", oRefund.OrgCashAmt);
                htMaster.Add("OrgPointAmt", oRefund.OrgPointAmt);
                htMaster.Add("DeductPointFromAccount", oRefund.DeductPointFromAccount);
                htMaster.Add("DeductPointFromCurrentCash", oRefund.DeductPointFromCurrentCash);
                htMaster.Add("CashAmt", oRefund.CashAmt);
                htMaster.Add("PointAmt", oRefund.PointAmt);

                new RMARefundDac().UpdateMaster(htMaster);

                foreach (RMARefundItemInfo oItem in oRefund.ItemHash.Values)
                {
                    Hashtable htItem = new Hashtable(5);

                    htItem.Add("SysNo", oItem.SysNo);

                    htItem.Add("OrgPrice", oItem.OrgPrice);
                    htItem.Add("UnitDiscount", oItem.UnitDiscount);
                    htItem.Add("ProductValue", oItem.ProductValue);
                    htItem.Add("RefundPrice", oItem.RefundPrice);
                    htItem.Add("PointType", oItem.PointType);
                    htItem.Add("RefundCash ", oItem.RefundCash);
                    htItem.Add("RefundPoint", oItem.RefundPoint);
                    htItem.Add("RefundPriceType", oItem.RefundPriceType);

                    new RMARefundDac().UpdateItem(htItem);
                }

                scope.Complete();
            }
        }
Esempio n. 3
0
        private void Calc(RMARefundInfo oRefund)
        {
            //���
            oRefund.OrgPointAmt = 0;
            oRefund.OrgCashAmt = 0;

            SOInfo oSO = SaleManager.GetInstance().LoadSO(oRefund.SOSysNo);

            #region calc money/point radio

            decimal pointOnly = 0; //������֧�����ֶ�Ӧ�ļ�ֵ
            decimal cashOnly = 0; //���ֽ�֧�����ֶ�Ӧ�ļ�ֵ

            foreach (SOItemInfo soItem in oSO.ItemHash.Values)
            {
                if (soItem.PointType == (int)AppEnum.ProductPayType.PointPayOnly)
                {
                    pointOnly += soItem.Price * soItem.Quantity + soItem.DiscountAmt;
                }
                else if (soItem.PointType == (int)AppEnum.ProductPayType.MoneyPayOnly)
                {
                    cashOnly += soItem.Price * soItem.Quantity + soItem.DiscountAmt;
                }
            }
            //����ɻ��֧�������У��û�֧���ı�����
            //������SOAmt = CashPay + PointPay(��λΪ���֣�int), ���ֱ��+����������Ҫת���ġ�
            //CashPay��ȥ��cashOnly == ��ϲ����û�֧�����ֽ�
            // ----------------------------
            // | cashOnly     | pointOnly |
            // |              |__________ |
            // |--------------|           |
            // |              |    B      |
            // |              |___________|
            // |       A      |
            // |              |
            // |              |
            // |              |
            // |______________|

            // ������Ϊ���һ����CashPay, �ұ�һ����PointPay
            // ����Ҫ��ı����� a/(a+b) = (cashPay-cashOnly)/(soAmt-pointOnly-cashOnly);

            //���oSO.SOAmt-pointOnly-cashOnly=0 ��������MoneyPayOnly����PointPayOnly���������������ļ�����
            //����Ҫ�õ�SOCashPointRate��ֵ�������趨ֵΪ0��
            if ((oSO.SOAmt - pointOnly - cashOnly) == 0)
                oRefund.SOCashPointRate = 0;
            else
                oRefund.SOCashPointRate = Decimal.Round((oSO.CashPay - cashOnly) / (oSO.SOAmt - pointOnly - cashOnly), 4);
                //oRefund.SOCashPointRate = Decimal.Round((oSO.CashPay - cashOnly) / (oSO.SOAmt - oSO.promotionValue - pointOnly - cashOnly), 4);  //�����ڷ�ĸ�ĵط�������-oSO.promotionValue
            #endregion

            foreach (RMARefundItemInfo oItem in oRefund.ItemHash.Values)
            {
                //���� point type ���� Ӧ���˵��ֽ�ͽ��

                if ((oItem.ProductValue + 20) < oItem.RefundPrice)
                    throw new BizException("�˿���ܴ�����Ʒ�۸�+20Ԫ�˷�");

                if (oItem.PointType == (int)AppEnum.ProductPayType.BothSupported)
                {
                    oItem.RefundCash = oItem.RefundPrice * oRefund.SOCashPointRate;
                    oItem.RefundPoint = Convert.ToInt32(Decimal.Round(oItem.RefundPrice * (1 - oRefund.SOCashPointRate) * AppConst.ExchangeRate, 0))
                                    - oItem.OrgPoint;
                }
                else if (oItem.PointType == (int)AppEnum.ProductPayType.MoneyPayOnly)
                {
                    oItem.RefundCash = oItem.RefundPrice;
                    oItem.RefundPoint = -1 * oItem.OrgPoint;
                }
                else
                {
                    oItem.RefundCash = 0m;
                    oItem.RefundPoint = Convert.ToInt32(Decimal.Round(oItem.RefundPrice * AppConst.ExchangeRate, 0)) - oItem.OrgPoint;
                }

                oRefund.OrgCashAmt += oItem.RefundCash;
                oRefund.OrgPointAmt += oItem.RefundPoint;
            }

            oRefund.DeductPointFromAccount = 0;
            oRefund.DeductPointFromCurrentCash = 0;
            if (oRefund.OrgPointAmt < 0)
            {
                CustomerInfo oCustomer = CustomerManager.GetInstance().Load(oRefund.CustomerSysNo);
                if (oRefund.OrgPointAmt * -1 < oCustomer.ValidScore)
                {
                    oRefund.DeductPointFromAccount = oRefund.OrgPointAmt * -1;
                }
                else
                {
                    oRefund.DeductPointFromAccount = oCustomer.ValidScore;
                    oRefund.DeductPointFromCurrentCash = Decimal.Round((oRefund.OrgPointAmt * -1 - oCustomer.ValidScore) / AppConst.ExchangeRate, 2);
                }
            }
            else
            {
            }

            oRefund.CashAmt = oRefund.OrgCashAmt - oRefund.DeductPointFromCurrentCash + oRefund.CompensateShipPrice;
            oRefund.PointAmt = oRefund.OrgPointAmt + oRefund.DeductPointFromAccount + Convert.ToInt32(oRefund.DeductPointFromCurrentCash * AppConst.ExchangeRate);
        }
Esempio n. 4
0
        /// <summary>
        /// SoIncomeʹ��,�ɰ��ͻ������ÿͻ���ȫ��RO��
        /// </summary>
        /// <param name="sysno"></param>
        /// <returns></returns>
        public RMARefundInfo LoadRMARefund(int sysno)
        {
            string sql = "select * from rma_refund (nolock) where sysno = " + sysno;
            DataSet ds = SqlHelper.ExecuteDataSet(sql);
            RMARefundInfo oMaster = new RMARefundInfo();
            if (Util.HasMoreRow(ds))
            {
                map(oMaster, ds.Tables[0].Rows[0]);

                string sql_item = "select * from rma_refund_item (nolock) where refundsysno =" + oMaster.SysNo;
                DataSet ds_item = SqlHelper.ExecuteDataSet(sql_item);
                if (Util.HasMoreRow(ds_item))
                {
                    foreach (DataRow dr in ds_item.Tables[0].Rows)
                    {
                        RMARefundItemInfo oItem = new RMARefundItemInfo();
                        map(oItem, dr);
                        oMaster.ItemHash.Add(oItem.RegisterSysNo, oItem);
                    }
                }
            }
            else
            {
                oMaster = null;
            }
            return oMaster;
        }
Esempio n. 5
0
        public RMARefundInfo Load(int sysno)
        {
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {

                string sql = "select * from rma_refund (NOLOCK) where sysno = " + sysno;
                DataSet ds = SqlHelper.ExecuteDataSet(sql);
                if (!Util.HasMoreRow(ds))
                    throw new BizException("does not exist such sysno");

                RMARefundInfo oMaster = new RMARefundInfo();

                map(oMaster, ds.Tables[0].Rows[0]);

                string sql_item = "select * from rma_refund_item (NOLOCK) where refundsysno =" + oMaster.SysNo;
                DataSet ds_item = SqlHelper.ExecuteDataSet(sql_item);
                if (Util.HasMoreRow(ds_item))
                {
                    foreach (DataRow dr in ds_item.Tables[0].Rows)
                    {
                        RMARefundItemInfo oItem = new RMARefundItemInfo();
                        map(oItem, dr);
                        oMaster.ItemHash.Add(oItem.RegisterSysNo, oItem);
                    }
                }

                scope.Complete();

                return oMaster;

            }
        }
Esempio n. 6
0
        public void Create(RMARefundInfo oParam)
        {
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {

                //1 get register item with the same so sysno
                //2 load sosysno,
                //3 foreach registersysno calc so, set some default value
                //4 calc master

                string sql_register = @"select rma_register.sysno, productsysno
                                        from
                                            rma_request (NOLOCK), rma_request_item (NOLOCK), rma_register (NOLOCK)
                                        where
                                            rma_request.sysno = rma_request_item.requestsysno
                                        and rma_request.sosysno = @sosysno
                                        and rma_register.refundstatus = @0
                                        and rma_register.sysno = rma_request_item.registersysno
                                        and rma_register.sysno not in
                                        (
                                            select rma_refund_item.registersysno
                                            from
                                                rma_refund (NOLOCK), rma_refund_item (NOLOCK)
                                            where
                                                rma_refund.sysno = rma_refund_item.refundsysno
                                            and rma_refund.status <> @1
                                        )";
                sql_register = sql_register.Replace("@sosysno", oParam.SOSysNo.ToString());
                sql_register = sql_register.Replace("@0", ((int)AppEnum.RMARefundStatus.WaitingRefund).ToString());
                sql_register = sql_register.Replace("@1", ((int)AppEnum.RMARefundStatus.Abandon).ToString());

                DataSet ds_register = SqlHelper.ExecuteDataSet(sql_register);
                if (!Util.HasMoreRow(ds_register))
                    throw new BizException("no valid register item can be inserted into refund sheet");

                SOInfo oSO = SaleManager.GetInstance().LoadSO(oParam.SOSysNo);

                //get something from so
                oParam.CustomerSysNo = oSO.CustomerSysNo;

                //set ship price default ����ȱʡ �⳥�˷�
                oParam.CompensateShipPrice = 0;

                foreach (DataRow dr in ds_register.Tables[0].Rows)
                {
                    RMARefundItemInfo refundItem = new RMARefundItemInfo();
                    //refundItem.RefundSysNo �Ȳ����ʱ��ֵ
                    refundItem.RegisterSysNo = Util.TrimIntNull(dr["sysno"]);

                    int productSysNo = Util.TrimIntNull(dr["productSysNo"]);
                    SOItemInfo soItem = oSO.ItemHash[productSysNo] as SOItemInfo;

                    refundItem.OrgPrice = soItem.Price;
                    refundItem.UnitDiscount = Decimal.Round(soItem.DiscountAmt / soItem.Quantity, 2);
                    refundItem.ProductValue = refundItem.OrgPrice + refundItem.UnitDiscount;

                    refundItem.OrgPoint = soItem.Point;
                    refundItem.RefundPrice = refundItem.ProductValue; //ȱʡ����Ϊȫ��
                    refundItem.PointType = soItem.PointType;
                    refundItem.RefundPriceType = (int)AppEnum.ReturnPriceType.TenPercentsOff;  //ȱʡ����Ϊ10%�ۼ��˿�
                    //refundItem.RefundCash = 0;
                    //refundItem.RefundPoint = 0;
                    oParam.ItemHash.Add(refundItem.RegisterSysNo, refundItem);
                }

                Calc(oParam);

                //inster master
                oParam.SysNo = SequenceDac.GetInstance().Create("RMA_Refund_Sequence");
                oParam.RefundID = getRefundID(oParam.SysNo);
                oParam.RefundPayType = (int)AppEnum.RMARefundPayType.CashRefund;  //Ĭ��Ϊ�ֽ��˿�
                new RMARefundDac().InsertMaster(oParam);

                //insert item;
                foreach (RMARefundItemInfo oItem in oParam.ItemHash.Values)
                {
                    oItem.RefundSysNo = oParam.SysNo;
                    new RMARefundDac().InsertItem(oItem);
                }

                scope.Complete();
            }
        }
Esempio n. 7
0
 private void map(RMARefundInfo oParam, DataRow tempdr)
 {
     oParam.SysNo = Util.TrimIntNull(tempdr["SysNo"]);
     oParam.RefundID = Util.TrimNull(tempdr["RefundID"]);
     oParam.SOSysNo = Util.TrimIntNull(tempdr["SOSysNo"]);
     oParam.CustomerSysNo = Util.TrimIntNull(tempdr["CustomerSysNo"]);
     oParam.CreateTime = Util.TrimDateNull(tempdr["CreateTime"]);
     oParam.CreateUserSysNo = Util.TrimIntNull(tempdr["CreateUserSysNo"]);
     oParam.AuditTime = Util.TrimDateNull(tempdr["AuditTime"]);
     oParam.AuditUserSysNo = Util.TrimIntNull(tempdr["AuditUserSysNo"]);
     oParam.RefundTime = Util.TrimDateNull(tempdr["RefundTime"]);
     oParam.RefundUserSysNo = Util.TrimIntNull(tempdr["RefundUserSysNo"]);
     oParam.CompensateShipPrice = Util.TrimDecimalNull(tempdr["CompensateShipPrice"]);
     oParam.SOCashPointRate = Util.TrimDecimalNull(tempdr["SOCashPointRate"]);
     oParam.OrgCashAmt = Util.TrimDecimalNull(tempdr["OrgCashAmt"]);
     oParam.OrgPointAmt = Util.TrimIntNull(tempdr["OrgPointAmt"]);
     oParam.DeductPointFromAccount = Util.TrimIntNull(tempdr["DeductPointFromAccount"]);
     oParam.DeductPointFromCurrentCash = Util.TrimDecimalNull(tempdr["DeductPointFromCurrentCash"]);
     oParam.CashAmt = Util.TrimDecimalNull(tempdr["CashAmt"]);
     oParam.PointAmt = Util.TrimIntNull(tempdr["PointAmt"]);
     oParam.RefundPayType = Util.TrimIntNull(tempdr["RefundPayType"]);
     oParam.Note = Util.TrimNull(tempdr["Note"]);
     oParam.Status = Util.TrimIntNull(tempdr["Status"]);
 }
Esempio n. 8
0
        private void InitPageList(RMARefundInfo oRma, ROInvoiceInfo invoice)
        {
            int index = 0;
            ROInvoicePageInfo page = new ROInvoicePageInfo();
            invoice.ItemHash.Add(index++, page);
            DataSet ds = GetRefundItemDs(oRma.SysNo);

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                ROInvoicePageItemInfo printItem = new ROInvoicePageItemInfo();
                printItem.pk = dr["registersysno"].ToString();
                printItem.ProductID = Util.TrimNull(dr["ProductID"]);
                printItem.ProductName = Util.TrimNull(dr["ProductName"]);

                decimal refundCash = Util.TrimDecimalNull(dr["RefundCash"]);
                if (oRma.RefundPayType == (int)AppEnum.RMARefundPayType.TransferPointRefund)
                    refundCash = 0;

                printItem.Quantity = -1;
                printItem.Weight = 0;
                printItem.Total = (-1) * refundCash;
                printItem.Price = refundCash;
                printItem.isRoItem = true;
                if (page.AddItem(printItem) == true)
                {
                    continue;
                }
                else
                {
                    page = new ROInvoicePageInfo();
                    page.AddItem(printItem);
                    invoice.ItemHash.Add(index++, page);
                }
            }

            if (oRma.DeductPointFromCurrentCash != 0)
            {
                ROInvoicePageItemInfo printItem = new ROInvoicePageItemInfo();
                printItem.pk = "��ػ���";
                printItem.ProductID = "��ػ���";
                printItem.Total = Convert.ToDecimal(oRma.DeductPointFromCurrentCash);
                printItem.isRoItem = false;
                //				printItem.isPoint = true;
                if (page.AddItem(printItem) == false)
                {
                    page = new ROInvoicePageInfo();
                    page.AddItem(printItem);
                    invoice.ItemHash.Add(index++, page);
                }
            }

            if (oRma.CompensateShipPrice != 0)
            {
                ROInvoicePageItemInfo printItem = new ROInvoicePageItemInfo();
                printItem.pk = "�����˷�";
                printItem.ProductID = "�����˷�";
                printItem.Total = Convert.ToDecimal(-1 * oRma.CompensateShipPrice);
                printItem.isRoItem = false;
                if (page.AddItem(printItem) == false)
                {
                    page = new ROInvoicePageInfo();
                    page.AddItem(printItem);
                    invoice.ItemHash.Add(index++, page);
                }
            }

            if (oRma.PointAmt != 0)
            {
                ROInvoicePageItemInfo printItem = new ROInvoicePageItemInfo();
                printItem.pk = "Ӱ�����";
                printItem.ProductID = "Ӱ�����";

                int affectedPoint = oRma.PointAmt;
                if (oRma.RefundPayType == (int)AppEnum.RMARefundPayType.TransferPointRefund)
                    affectedPoint += Convert.ToInt32(Decimal.Round(oRma.CashAmt * AppConst.ExchangeRate, 0));

                printItem.Total = affectedPoint;
                printItem.isRoItem = false;
                printItem.isPoint = true;
                if (page.AddItem(printItem) == false)
                {
                    page = new ROInvoicePageInfo();
                    page.AddItem(printItem);
                    invoice.ItemHash.Add(index++, page);
                }
            }
        }