Ejemplo n.º 1
0
        public Int64 Insert(CreditCardPaymentDetails Details)
		{
			try  
			{
                Save(Details);

                return Int64.Parse(base.getLAST_INSERT_ID(this));
			}
			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
Ejemplo n.º 2
0
        public Int64 Insert(CreditCardPaymentDetails Details)
        {
            try
            {
                Save(Details);

                return(Int64.Parse(base.getLAST_INSERT_ID(this)));
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get the cash payment details of a certain transaction.
        /// </summary>
        /// <param name="BranchID"></param>
        /// <param name="TerminalNo"></param>
        /// <param name="SyncID">Same also as the TransactionID</param>
        /// <returns></returns>
        public CreditCardPaymentDetails[] Details(Int32 BranchID, string TerminalNo, Int64 TransactionID)
        {
            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;

                string SQL = SQLSelect() + "WHERE BranchID = @BranchID AND TerminalNo = @TerminalNo AND TransactionID = @TransactionID;";

                cmd.Parameters.AddWithValue("BranchID", BranchID);
                cmd.Parameters.AddWithValue("TerminalNo", TerminalNo);
                cmd.Parameters.AddWithValue("TransactionID", TransactionID);

                cmd.CommandText = SQL;
                string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
                base.MySqlDataAdapterFill(cmd, dt);

                ArrayList items = new ArrayList();
                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    items.Add(setDetails(dr));
                }

                CreditCardPaymentDetails[] arrCashDetails = new CreditCardPaymentDetails[0];

                if (items != null)
                {
                    arrCashDetails = new CreditCardPaymentDetails[items.Count];
                    items.CopyTo(arrCashDetails);
                }

                return(arrCashDetails);
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Ejemplo n.º 4
0
        public Int32 Save(CreditCardPaymentDetails Details)
        {
            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;

                string SQL = "CALL procSaveCreditCardPayment(@BranchID, @TerminalNo, @SyncID, @CreditCardPaymentID, @TransactionID, @TransactionDate, @CashierName, @Amount, @AdditionalCharge, " +
                                                            "@ContactID, @GuarantorID, @CardTypeID, @CardTypeCode, @CardTypeName, @CardNo, @CardHolder, @ValidityDates, @Remarks, @TransactionNo, @CreatedOn, @LastModified);";

                cmd.Parameters.AddWithValue("BranchID", Details.BranchDetails.BranchID);
                cmd.Parameters.AddWithValue("TerminalNo", Details.TerminalNo);
                cmd.Parameters.AddWithValue("SyncID", Details.SyncID);
                cmd.Parameters.AddWithValue("CreditCardPaymentID", Details.CreditCardPaymentID);
                cmd.Parameters.AddWithValue("TransactionID", Details.TransactionID);
                cmd.Parameters.AddWithValue("TransactionDate", Details.TransactionDate);
                cmd.Parameters.AddWithValue("CashierName", Details.CashierName);
                cmd.Parameters.AddWithValue("Amount", Details.Amount);
                cmd.Parameters.AddWithValue("AdditionalCharge", Details.AdditionalCharge);
                cmd.Parameters.AddWithValue("ContactID", Details.CreditorDetails.ContactID);
                cmd.Parameters.AddWithValue("GuarantorID", Details.CreditorDetails.CreditDetails.GuarantorID);
                cmd.Parameters.AddWithValue("CardTypeID", Details.CardTypeID);
                cmd.Parameters.AddWithValue("CardTypeCode", Details.CardTypeCode);
                cmd.Parameters.AddWithValue("CardTypeName", Details.CardTypeName);
                cmd.Parameters.AddWithValue("CardNo", Details.CardNo);
                cmd.Parameters.AddWithValue("CardHolder", Details.CardHolder);
                cmd.Parameters.AddWithValue("ValidityDates", Details.ValidityDates);
                cmd.Parameters.AddWithValue("Remarks", Details.Remarks);
                cmd.Parameters.AddWithValue("TransactionNo", Details.TransactionNo);
                cmd.Parameters.AddWithValue("CreatedOn", Details.CreatedOn == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : Details.CreatedOn);
                cmd.Parameters.AddWithValue("LastModified", Details.LastModified == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : Details.LastModified);

                cmd.CommandText = SQL;
                Int32 iRetValue = base.ExecuteNonQuery(cmd);

                // update this if it's an insert
                if (Details.CreditCardPaymentID == 0) Details.CreditCardPaymentID = Int64.Parse(base.getLAST_INSERT_ID(this));

                //save the credit if inhouse credit
                if (Details.CreditorDetails.ContactID != 0)
                {
                    CreditPaymentDetails clsCreditPaymentDetails = new CreditPaymentDetails();

                    clsCreditPaymentDetails.BranchDetails = Details.BranchDetails;
                    clsCreditPaymentDetails.TerminalNo = Details.TerminalNo;
                    clsCreditPaymentDetails.TransactionID = Details.TransactionID;
                    clsCreditPaymentDetails.TransactionNo = Details.TransactionNo;
                    clsCreditPaymentDetails.IsRefund = Details.IsRefund;
                    clsCreditPaymentDetails.TransactionDate = Details.TransactionDate;
                    clsCreditPaymentDetails.CashierName = Details.CashierName;
                    clsCreditPaymentDetails.Amount = Details.Amount;
                    clsCreditPaymentDetails.CustomerDetails = Details.CreditorDetails;
                    clsCreditPaymentDetails.Remarks = Details.Remarks;

                    string additionalRemarks = Details.Remarks;
                    if (!string.IsNullOrEmpty(Details.Remarks))
                        additionalRemarks = ";" + (Details.Remarks.Length > 30 ? Details.Remarks.Substring(0, 30) : Details.Remarks);

                    if (!Details.IsRefund)
                        clsCreditPaymentDetails.CreditReason = CreditReason.IHCC.ToString("G") + " @ Ter#:" + Details.TerminalNo + " Br#:" + Details.BranchDetails.BranchID.ToString() + additionalRemarks;
                    else
                        clsCreditPaymentDetails.CreditReason = CreditReason.IHCC.ToString("G") + " @ Ter#:" + Details.TerminalNo + " Br#:" + Details.BranchDetails.BranchID.ToString() + additionalRemarks + " Refund";

                    clsCreditPaymentDetails.CreditCardPaymentID = Details.CreditCardPaymentID;
                    clsCreditPaymentDetails.CreditCardTypeID = Details.CardTypeDetails.CardTypeID;

                    new CreditPayments(base.Connection, base.Transaction).Insert(clsCreditPaymentDetails);

                    // no need for this this is already included in the insert of CreditPayments
                    //Contacts clsContact = new Contacts(base.Connection, base.Transaction);
                    //if (!Details.IsRefund)
                    //    clsContact.AddCredit(Details.CreditorDetails.ContactID, Details.Amount);
                    //else
                    //    clsContact.AddCredit(Details.CreditorDetails.ContactID, -Details.Amount);
                }

                return iRetValue;
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Get the cash payment details of a certain transaction.
        /// </summary>
        /// <param name="BranchID"></param>
        /// <param name="TerminalNo"></param>
        /// <param name="SyncID">Same also as the TransactionID</param>
        /// <returns></returns>
        public CreditCardPaymentDetails[] Details(Int32 BranchID, string TerminalNo, Int64 TransactionID)
        {
            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;

                string SQL = SQLSelect() + "WHERE BranchID = @BranchID AND TerminalNo = @TerminalNo AND TransactionID = @TransactionID;";

                cmd.Parameters.AddWithValue("BranchID", BranchID);
                cmd.Parameters.AddWithValue("TerminalNo", TerminalNo);
                cmd.Parameters.AddWithValue("TransactionID", TransactionID);

                cmd.CommandText = SQL;
                string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
                base.MySqlDataAdapterFill(cmd, dt);

                ArrayList items = new ArrayList();
                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    items.Add(setDetails(dr));
                }

                CreditCardPaymentDetails[] arrCashDetails = new CreditCardPaymentDetails[0];

                if (items != null)
                {
                    arrCashDetails = new CreditCardPaymentDetails[items.Count];
                    items.CopyTo(arrCashDetails);
                }

                return arrCashDetails;
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Ejemplo n.º 6
0
        public Int32 Save(CreditCardPaymentDetails Details)
        {
            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;

                string SQL = "CALL procSaveCreditCardPayment(@BranchID, @TerminalNo, @SyncID, @CreditCardPaymentID, @TransactionID, @TransactionDate, @CashierName, @Amount, @AdditionalCharge, " +
                             "@ContactID, @GuarantorID, @CardTypeID, @CardTypeCode, @CardTypeName, @CardNo, @CardHolder, @ValidityDates, @Remarks, @TransactionNo, @CreatedOn, @LastModified);";

                cmd.Parameters.AddWithValue("BranchID", Details.BranchDetails.BranchID);
                cmd.Parameters.AddWithValue("TerminalNo", Details.TerminalNo);
                cmd.Parameters.AddWithValue("SyncID", Details.SyncID);
                cmd.Parameters.AddWithValue("CreditCardPaymentID", Details.CreditCardPaymentID);
                cmd.Parameters.AddWithValue("TransactionID", Details.TransactionID);
                cmd.Parameters.AddWithValue("TransactionDate", Details.TransactionDate);
                cmd.Parameters.AddWithValue("CashierName", Details.CashierName);
                cmd.Parameters.AddWithValue("Amount", Details.Amount);
                cmd.Parameters.AddWithValue("AdditionalCharge", Details.AdditionalCharge);
                cmd.Parameters.AddWithValue("ContactID", Details.CreditorDetails.ContactID);
                cmd.Parameters.AddWithValue("GuarantorID", Details.CreditorDetails.CreditDetails.GuarantorID);
                cmd.Parameters.AddWithValue("CardTypeID", Details.CardTypeID);
                cmd.Parameters.AddWithValue("CardTypeCode", Details.CardTypeCode);
                cmd.Parameters.AddWithValue("CardTypeName", Details.CardTypeName);
                cmd.Parameters.AddWithValue("CardNo", Details.CardNo);
                cmd.Parameters.AddWithValue("CardHolder", Details.CardHolder);
                cmd.Parameters.AddWithValue("ValidityDates", Details.ValidityDates);
                cmd.Parameters.AddWithValue("Remarks", Details.Remarks);
                cmd.Parameters.AddWithValue("TransactionNo", Details.TransactionNo);
                cmd.Parameters.AddWithValue("CreatedOn", Details.CreatedOn == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : Details.CreatedOn);
                cmd.Parameters.AddWithValue("LastModified", Details.LastModified == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : Details.LastModified);

                cmd.CommandText = SQL;
                Int32 iRetValue = base.ExecuteNonQuery(cmd);

                // update this if it's an insert
                if (Details.CreditCardPaymentID == 0)
                {
                    Details.CreditCardPaymentID = Int64.Parse(base.getLAST_INSERT_ID(this));
                }

                //save the credit if inhouse credit
                if (Details.CreditorDetails.ContactID != 0)
                {
                    CreditPaymentDetails clsCreditPaymentDetails = new CreditPaymentDetails();

                    clsCreditPaymentDetails.BranchDetails   = Details.BranchDetails;
                    clsCreditPaymentDetails.TerminalNo      = Details.TerminalNo;
                    clsCreditPaymentDetails.TransactionID   = Details.TransactionID;
                    clsCreditPaymentDetails.TransactionNo   = Details.TransactionNo;
                    clsCreditPaymentDetails.IsRefund        = Details.IsRefund;
                    clsCreditPaymentDetails.TransactionDate = Details.TransactionDate;
                    clsCreditPaymentDetails.CashierName     = Details.CashierName;
                    clsCreditPaymentDetails.Amount          = Details.Amount;
                    clsCreditPaymentDetails.CustomerDetails = Details.CreditorDetails;
                    clsCreditPaymentDetails.Remarks         = Details.Remarks;

                    string additionalRemarks = Details.Remarks;
                    if (!string.IsNullOrEmpty(Details.Remarks))
                    {
                        additionalRemarks = ";" + (Details.Remarks.Length > 30 ? Details.Remarks.Substring(0, 30) : Details.Remarks);
                    }

                    if (!Details.IsRefund)
                    {
                        clsCreditPaymentDetails.CreditReason = CreditReason.IHCC.ToString("G") + " @ Ter#:" + Details.TerminalNo + " Br#:" + Details.BranchDetails.BranchID.ToString() + additionalRemarks;
                    }
                    else
                    {
                        clsCreditPaymentDetails.CreditReason = CreditReason.IHCC.ToString("G") + " @ Ter#:" + Details.TerminalNo + " Br#:" + Details.BranchDetails.BranchID.ToString() + additionalRemarks + " Refund";
                    }

                    clsCreditPaymentDetails.CreditCardPaymentID = Details.CreditCardPaymentID;
                    clsCreditPaymentDetails.CreditCardTypeID    = Details.CardTypeDetails.CardTypeID;

                    new CreditPayments(base.Connection, base.Transaction).Insert(clsCreditPaymentDetails);

                    // no need for this this is already included in the insert of CreditPayments
                    //Contacts clsContact = new Contacts(base.Connection, base.Transaction);
                    //if (!Details.IsRefund)
                    //    clsContact.AddCredit(Details.CreditorDetails.ContactID, Details.Amount);
                    //else
                    //    clsContact.AddCredit(Details.CreditorDetails.ContactID, -Details.Amount);
                }

                return(iRetValue);
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }