You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
2.2 KiB
49 lines
2.2 KiB
using BiskLog_Point_Of_Sale.Properties;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BiskLog_Point_Of_Sale.POSDialogs
|
|
{
|
|
public static class PreviousSettlement
|
|
{
|
|
public static void settlement(SqlConnection cn, string customerID, decimal investment, SortedList<string, decimal> receiptList,SqlTransaction tn)
|
|
{
|
|
SqlCommand cm;
|
|
foreach (var settle in receiptList)
|
|
{
|
|
decimal arrears = investment - settle.Value;
|
|
if (arrears >= 0)
|
|
{
|
|
cm = new SqlCommand("Update CreditPurchases set paid = totalBill, status = @status where receiptID = @receiptID and " +
|
|
"customerID = @customerID and branchID = @branchID " +
|
|
"Update tblCart set status = @status1 where transno = @receiptID and branchID = @branchID", cn,tn);
|
|
cm.Parameters.AddWithValue("@customerID", customerID);
|
|
cm.Parameters.AddWithValue("@receiptID", settle.Key);
|
|
cm.Parameters.AddWithValue("@status", "settled");
|
|
cm.Parameters.AddWithValue("@status1", "SOLD");
|
|
cm.Parameters.AddWithValue("@branchID", Settings.Default.BranchID);
|
|
cm.ExecuteNonQuery();
|
|
}
|
|
else
|
|
{
|
|
cm = new SqlCommand("Update CreditPurchases set paid = paid + @investment, status = @status where receiptID = @receiptID and " +
|
|
"customerID = @customerID and branchID = @branchID", cn, tn);
|
|
cm.Parameters.AddWithValue("@customerID", customerID);
|
|
cm.Parameters.AddWithValue("@receiptID", settle.Key);
|
|
cm.Parameters.AddWithValue("@investment", investment);
|
|
cm.Parameters.AddWithValue("@status", "unsettled");
|
|
cm.Parameters.AddWithValue("@branchID", Settings.Default.BranchID);
|
|
cm.ExecuteNonQuery();
|
|
}
|
|
|
|
investment = investment - settle.Value;
|
|
if (investment <= 0)
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|