Ejemplo n.º 1
0
        public void addReturnRow(decimal dec, string strCashType, string strCashBoxId, string strSaleType)
        {
            int i = 0;

            while (i < Rows.Count)
            {
                if (Rows[i].PaymentForm.Code == "CASH" && Rows[i].PaymentForm.Code != strRoundingCashTypeNegative && Rows[i].PaymentForm.Code != strRoundingCashTypePositive)
                {
                    //found an existing cash line
                    Rows[i].Amount     += dec;
                    Rows[i].AmountPaid += dec;
                }
                i++;
            }
            //not found, add a new cash line
            if (i == Rows.Count)
            {
                InvoiceRow aRow = new InvoiceRow();
                aRow.PaymentForm.Code = "CASH";
                aRow.PaymentType.Code = strCashType;
                aRow.CashBoxId        = strCashBoxId;
                aRow.AmountPaid       = dec;
                aRow.AmountChange     = 0;
                aRow.Amount           = dec;
                aRow.Quantity         = 0;
                aRow.SaleType         = strSaleType;
                Rows.Add(aRow);
            }
        }
Ejemplo n.º 2
0
        public void addRoundingRow(clsCashBox CashBox, string strCashFormName, string strNegativeRoundingCashTypeName, string strPositiveRoundingCashTypeName, string strCashBoxId)
        {
            int     i = 0;
            int     nIndexRounding = -1;
            decimal nAmount        = 0;

            while (i < Rows.Count)
            {
                if (Rows[i].PaymentForm.Code == "CASH")
                {
                    if (Rows[i].PaymentType.Code == strRoundingCashTypePositive || Rows[i].PaymentType.Code == strRoundingCashTypeNegative)
                    {
                        nIndexRounding = i;
                    }
                    else
                    {
                        nAmount = nAmount + Rows[i].Amount;
                    }
                }
                i++;
            }
            //Remove the existing rounding line
            if (nIndexRounding >= 0)
            {
                Rows.RemoveAt(nIndexRounding);
            }
            //Add a new rounding line
            decimal remainAmount = CashBox.roundToLocalCurrency(nAmount, strRoundingCashTypePositive) - nAmount;

            if (remainAmount != 0)
            {
                InvoiceRow roundingRow = new InvoiceRow();
                roundingRow.PaymentForm.Code = "CASH";
                roundingRow.PaymentForm.Name = strCashFormName;
                string strSaleType = "";
                if (remainAmount > 0)
                {
                    roundingRow.PaymentType.Code = strRoundingCashTypePositive;
                    roundingRow.PaymentType.Name = strPositiveRoundingCashTypeName;
                    strSaleType = CashBox.getSaleTypeOfType(strRoundingCashTypePositive);
                }
                else
                {
                    roundingRow.PaymentType.Code = strRoundingCashTypeNegative;
                    roundingRow.PaymentType.Name = strNegativeRoundingCashTypeName;
                    strSaleType = CashBox.getSaleTypeOfType(strRoundingCashTypeNegative);
                }
                roundingRow.CashBoxId    = strCashBoxId;
                roundingRow.AmountPaid   = remainAmount;
                roundingRow.AmountChange = 0;
                roundingRow.Amount       = remainAmount;
                roundingRow.Quantity     = 0;
                roundingRow.SaleType     = strSaleType;
                Rows.Add(roundingRow);
            }
        }
Ejemplo n.º 3
0
 public bool loadRows()
 {
     Rows.Clear();
     if ((ReceiptNo > 0) && (Paid == true))
     {
         clsSqlFactory hSql = new clsSqlFactory();
         hSql.NewCommand("select CASHFORM,CASHTYPE,isnull(QTY,0),isnull(AMOUNT,0),SALETYPE,ROWNO, isnull(b.C2,'') as CASHFORM_NAME,"
                         + " isnull(c.C2,'') as CASHTYPE_NAME, isnull(FEE,0) as FEE, isnull(CC_TERMINALID,'') as CARDTYPE, isnull(d.C2,'') as CARDNAME from " + objUtil.getTable("CASHTRANSR")
                         + " left join " + objUtil.getTable("CORW") + " b on b.CODAID = 'CASHFORM' and b.C1=CASHFORM "
                         + " left join " + objUtil.getTable("CORW") + " c on c.CODAID = 'CASHTYPE' and c.C1=CASHTYPE "
                         + " left join " + objUtil.getTable("CORW") + " d on d.CODAID = 'CASHCCTYPE' and d.C1=CC_TERMINALID "
                         + " where RECEIPTNO=?");
         hSql.Com.Parameters.AddWithValue("RECEIPTNO", ReceiptNo);
         hSql.ExecuteReader();
         while (hSql.Read())
         {
             InvoiceRow aRow = new InvoiceRow();
             aRow.CashBoxId        = strCashBoxId;
             aRow.Receiptno        = ReceiptNo;
             aRow.PaymentForm.Code = hSql.Reader.GetString(0);
             aRow.PaymentType.Code = hSql.Reader.GetString(1);
             aRow.Quantity         = hSql.Reader.GetDecimal(2);
             aRow.Amount           = hSql.Reader.GetDecimal(3);
             aRow.AmountPaid       = aRow.Amount;
             aRow.AmountChange     = 0;
             aRow.SaleType         = hSql.Reader.GetString(4);
             aRow.Rowno            = hSql.Reader.GetInt32(5);
             aRow.PaymentForm.Name = aRow.PaymentForm.Code + "=" + hSql.Reader.GetString(6);
             aRow.PaymentType.Name = aRow.PaymentType.Code + "=" + hSql.Reader.GetString(7);
             aRow.AmountFee        = hSql.Reader.GetDecimal(hSql.Reader.GetOrdinal("FEE"));
             aRow.CardType.Code    = hSql.Reader.GetString(hSql.Reader.GetOrdinal("CARDTYPE"));
             aRow.CardType.Name    = aRow.CardType.Code + "=" + hSql.Reader.GetString(hSql.Reader.GetOrdinal("CARDNAME"));
             Rows.Add(aRow);
         }
         hSql.Close();
     }
     return(true);
 }