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.
109 lines
4.1 KiB
109 lines
4.1 KiB
3 months ago
|
using BiskLog_Point_Of_Sale.Classes;
|
||
|
using BiskLog_Point_Of_Sale.Company_Setup;
|
||
|
using BiskLog_Point_Of_Sale.Multiple_Login;
|
||
|
using BiskLog_Point_Of_Sale.Properties;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.ComponentModel;
|
||
|
using System.Data;
|
||
|
using System.Data.SqlClient;
|
||
|
using System.Drawing;
|
||
|
using System.Linq;
|
||
|
using System.Text;
|
||
|
using System.Threading.Tasks;
|
||
|
using System.Windows.Forms;
|
||
|
|
||
|
namespace Point_Of_Sale_Managment.CashierModule
|
||
|
{
|
||
|
public partial class DailySales : Form
|
||
|
{
|
||
|
DatabaseConn conn = new DatabaseConn();
|
||
|
SqlConnection cn;
|
||
|
SqlCommand cm;
|
||
|
SqlDataReader dr;
|
||
|
public DailySales()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
cn = new SqlConnection(conn.MyConnection());
|
||
|
holding.Left = (ClientSize.Width - holding.Width) / 2;
|
||
|
holding.Top = (ClientSize.Height - holding.Height) / 2;
|
||
|
}
|
||
|
|
||
|
private void DailySales_KeyDown(object sender, KeyEventArgs e)
|
||
|
{
|
||
|
if (e.KeyCode == Keys.Escape)
|
||
|
{
|
||
|
this.Close();
|
||
|
}
|
||
|
}
|
||
|
public int getForDay(DateTime date, string cashier)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
dataGridView1.Invoke(new Action(() =>
|
||
|
{
|
||
|
dataGridView1.Rows.Clear();
|
||
|
dailyIncome.Text = "";
|
||
|
numberCustomers.Text = "";
|
||
|
decimal TotalSale = 0;
|
||
|
int i = 1;
|
||
|
cn.Open();
|
||
|
cm = new SqlCommand("usp_cashier_daily_sales @BranchID = @branchID,@month=@dateMonth,@year=@dateYear,@day=@dateDay," +
|
||
|
"@cashier = @cashier1", cn);
|
||
|
cm.Parameters.AddWithValue("@dateYear", date.Year);
|
||
|
cm.Parameters.AddWithValue("@dateMonth", date.Month);
|
||
|
cm.Parameters.AddWithValue("@dateDay", date.Day);
|
||
|
cm.Parameters.AddWithValue("@cashier1", cashier);
|
||
|
cm.Parameters.AddWithValue("@branchID", Settings.Default.BranchID);
|
||
|
dr = cm.ExecuteReader();
|
||
|
while (dr.Read())
|
||
|
{
|
||
|
dataGridView1.Rows.Add(i, dr["Customer"].ToString(), dr["transno"].ToString(), Convert.ToDateTime(dr["date"].ToString()).ToLocalTime(), Settings.Default.currrencyCode + " " + dr["Receipt Total"].ToString());
|
||
|
TotalSale += decimal.Parse(dr["Receipt Total"].ToString());
|
||
|
i++;
|
||
|
dailyIncome.Text = Settings.Default.currrencyCode + " " + TotalSale.ToString();
|
||
|
}
|
||
|
numberCustomers.Text = cashier;
|
||
|
dr.Close();
|
||
|
cn.Close();
|
||
|
}));
|
||
|
return 1;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
cn.Close();
|
||
|
MessageBox.Show(ex.ToString());
|
||
|
ErrorLogging.WriteToFile(ex.ToString());
|
||
|
return 0;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
private async void DateTimePicker1_ValueChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
Task<int> task = new Task<int>(() => getForDay(dateTimePicker1.Value, MainLogin.login_user));
|
||
|
holding.Visible = true;
|
||
|
task.Start();
|
||
|
int result = await task;
|
||
|
if (result == 0)
|
||
|
{
|
||
|
string title = "Error Occurred";
|
||
|
string message = "Sorry an error occurred while looking up sales on this date";
|
||
|
NoAction noAction = new NoAction(title, message);
|
||
|
noAction.BringToFront();
|
||
|
noAction.ShowDialog();
|
||
|
}
|
||
|
holding.Visible = false;
|
||
|
}
|
||
|
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
|
||
|
{
|
||
|
if (e.RowIndex != -1)
|
||
|
{
|
||
|
string receiptid = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
|
||
|
ReceiptModule receipt = new ReceiptModule(receiptid);
|
||
|
receipt.BringToFront();
|
||
|
receipt.ShowDialog();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|