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.
196 lines
6.1 KiB
196 lines
6.1 KiB
3 months ago
|
using BiskLog_Point_Of_Sale.Multiple_Login;
|
||
|
using BiskLog_Point_Of_Sale.Properties;
|
||
|
using System;
|
||
|
using System.Data.SqlClient;
|
||
|
using System.Drawing;
|
||
|
using System.Threading.Tasks;
|
||
|
using System.Windows.Forms;
|
||
|
|
||
|
namespace Point_Of_Sale_Managment.CashierModule
|
||
|
{
|
||
|
public partial class settlePayment : Form
|
||
|
{
|
||
|
string currency;
|
||
|
NewSalesPOS selling;
|
||
|
decimal balponit, paymentponit;
|
||
|
public settlePayment(NewSalesPOS sales)
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
currency = Settings.Default.currrencyCode + " ";
|
||
|
selling = sales;
|
||
|
holding.Left = (this.Width - holding.Width) / 2;
|
||
|
}
|
||
|
|
||
|
private void settlePayment_KeyDown(object sender, KeyEventArgs e)
|
||
|
{
|
||
|
if (e.KeyCode == Keys.Escape)
|
||
|
{
|
||
|
this.Close();
|
||
|
}
|
||
|
}
|
||
|
private void button16_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
payment.AppendText("1");
|
||
|
}
|
||
|
private void button17_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
payment.AppendText("2");
|
||
|
}
|
||
|
private void button18_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
payment.AppendText("3");
|
||
|
}
|
||
|
private void button19_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
payment.AppendText(".");
|
||
|
}
|
||
|
private void button15_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
payment.AppendText("0");
|
||
|
}
|
||
|
private void button11_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
payment.Text = "";
|
||
|
}
|
||
|
private void button14_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
payment.AppendText("6");
|
||
|
}
|
||
|
private void button13_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
payment.AppendText("5");
|
||
|
}
|
||
|
private void button12_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
payment.AppendText("4");
|
||
|
}
|
||
|
private void button10_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
payment.AppendText("9");
|
||
|
}
|
||
|
private void button9_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
payment.AppendText("8");
|
||
|
}
|
||
|
private void btnSave_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
payment.AppendText("7");
|
||
|
}
|
||
|
private void settlePayment_Load(object sender, EventArgs e)
|
||
|
{
|
||
|
payment.Focus();
|
||
|
cost.Text = currency + NewSalesPOS.mainTotal.ToString();
|
||
|
owe.Text = currency + NewSalesPOS.mainTotal.ToString();
|
||
|
}
|
||
|
private void payment_TextChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
if (!String.IsNullOrEmpty(payment.Text))
|
||
|
{
|
||
|
decimal amount = decimal.Parse(payment.Text);
|
||
|
if (!String.IsNullOrEmpty(payment.Text))
|
||
|
{
|
||
|
arrangement(amount);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
arrangement(decimal.Parse("0.00"));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
public void arrangement(decimal payment)
|
||
|
{
|
||
|
decimal paid = NewSalesPOS.mainTotal - payment;
|
||
|
paymentponit = payment;
|
||
|
|
||
|
if (paid < 0)
|
||
|
{
|
||
|
bal.Text = currency + (paid * -1).ToString();
|
||
|
balponit = decimal.Parse((paid * -1).ToString());
|
||
|
owe.Text = currency + 0.00;
|
||
|
}
|
||
|
else if (paid == 0)
|
||
|
{
|
||
|
bal.Text = currency + paid.ToString();
|
||
|
balponit = decimal.Parse(paid.ToString());
|
||
|
owe.Text = currency + 0.00;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
owe.Text = currency + paid.ToString();
|
||
|
bal.Text = currency + 0.00;
|
||
|
balponit = decimal.Parse("00.00");
|
||
|
}
|
||
|
}
|
||
|
private void payment_KeyPress(object sender, KeyPressEventArgs e)
|
||
|
{
|
||
|
if (e.KeyChar == 8)
|
||
|
{
|
||
|
//accepts backspace
|
||
|
}
|
||
|
else if ((e.KeyChar < 48) || (e.KeyChar > 57)) //ascii code 48-57 between 0-9
|
||
|
{
|
||
|
e.Handled = true;
|
||
|
}
|
||
|
else if (e.KeyChar == 46)
|
||
|
{
|
||
|
// accepts . character
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void Close_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
this.Close();
|
||
|
}
|
||
|
|
||
|
private void Close_MouseEnter(object sender, EventArgs e)
|
||
|
{
|
||
|
close.BackColor = Color.Crimson;
|
||
|
}
|
||
|
|
||
|
private void Close_MouseLeave(object sender, EventArgs e)
|
||
|
{
|
||
|
close.BackColor = Color.Transparent;
|
||
|
}
|
||
|
|
||
|
private async void Button21_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
if (owe.Text.Equals(currency + 0.00))
|
||
|
{
|
||
|
Task<int> task = new Task<int>(() => selling.makePayment(balponit, paymentponit));
|
||
|
holding.Visible = true;
|
||
|
task.Start();
|
||
|
int result = await task;
|
||
|
if (result == 1)
|
||
|
{
|
||
|
holding.Visible = false;
|
||
|
string title = "Success";
|
||
|
string message = "Payment made successfully";
|
||
|
NoAction noAction = new NoAction(title, message);
|
||
|
noAction.BringToFront();
|
||
|
noAction.ShowDialog();
|
||
|
this.Close();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
holding.Visible = false;
|
||
|
string title = "Error Occurred";
|
||
|
string message = "Sorry an error occurred while making payment, please try again";
|
||
|
NoAction noAction = new NoAction(title, message);
|
||
|
noAction.BringToFront();
|
||
|
noAction.ShowDialog();
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
holding.Visible = false;
|
||
|
string title = "Full amount not paid";
|
||
|
string message = "Bill needs to be fully settled to continue";
|
||
|
NoAction noAction = new NoAction(title, message);
|
||
|
noAction.BringToFront();
|
||
|
noAction.ShowDialog();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|