private void button1_Click(object sender, EventArgs e) { double total = 0; double hrs = 0; double payOver = 0; double days = 0; try { fromDate = Convert.ToDateTime(startLbl.Text).ToString("dd-MM-yyyy"); toDate = Convert.ToDateTime(endLbl.Text).ToString("dd-MM-yyyy"); } catch (Exception k) { fromDate = DateTime.Now.ToString("dd-MM-yyyy"); toDate = DateTime.Now.ToString("dd-MM-yyyy"); } LoadingWindow.ShowSplashScreen(); LoadDeduction(fromDate, toDate); string Qs = "SELECT starts,period,userID,customerID FROM schedule WHERE `date` >= '" + fromDate + "' AND `date` <= '" + toDate + "'"; MySqlDataReader Reader1 = MySQL.Reading(Qs); OnDays l = new OnDays(); List <OnDays> oD = new List <OnDays>(); while (Reader1.Read()) { l = new OnDays(Convert.ToDateTime(Reader1["starts"]).ToString("ddd"), Reader1["period"].ToString(), Reader1["userID"].ToString(), Reader1["customerID"].ToString()); oD.Add(l); } DBConnect.CloseMySqlConn(); Payroll r = new Payroll(); string Q = "SELECT users.name,rate.period AS maxs ,customer.name AS client,customer.id AS customerID,rate.amount,account.bank,account.routing,SUM(schedule.period ) AS totalhours,SUM(schedule.cost ) AS cost,schedule.userID AS userID FROM schedule LEFT JOIN users ON schedule.userID = users.id LEFT JOIN customer ON schedule.customerID = customer.id LEFT JOIN rate ON users.id = rate.userID LEFT JOIN account ON users.id = account.userid LEFT JOIN deduction ON users.id = deduction.userID WHERE (schedule.`date` >= '" + fromDate + "' AND schedule.`date` <= '" + toDate + "') GROUP BY schedule.userID,users.name,customer.name,users.name,account.bank,account.routing,rate.amount,rate.period,customer.id"; MySqlDataReader Reader = MySQL.Reading(Q); int ct = 0; double ded = 0; double totalHrs = 0; double maxs = 0; double amount = 0; while (Reader.Read()) { if (ct == 1) { ded = deductionDictionary.Where(u => u.Key.Contains(Reader["userID"].ToString())).Sum(k => k.Value); } else { ded = 0; } totalHrs = Convert.ToDouble(Reader["totalhours"]); try { maxs = Convert.ToDouble(Reader["maxs"]); } catch { } try { amount = Convert.ToDouble(Reader["amount"]); } catch { } total = Convert.ToDouble(Reader["cost"]); double overtime = 0; if (totalHrs > maxs) { overtime = totalHrs - maxs; } else { overtime = 0; } double half = amount / 2; double timeHalf = amount + half; double overtimePay = timeHalf * overtime; double pay = (total + overtimePay) - ded; string daying = ""; foreach (OnDays u in oD.Where(y => y.UserID.Contains(Reader["userID"].ToString()) && y.ClientID.Contains(Reader["customerID"].ToString()))) { daying = daying + "\n" + u.Day + "\t\t" + u.Hrs; } r = new Payroll(Reader["name"].ToString(), Reader["client"].ToString(), Reader["bank"].ToString() + " " + Reader["routing"].ToString(), daying, days, "", Convert.ToDouble(Reader["totalhours"]), amount, Convert.ToDouble(Reader["cost"]), ded, pay, overtime, overtimePay); reports.Add(r); ct++; } DBConnect.CloseMySqlConn(); /** end restaurant profit**/ // Microsoft.Reporting.WinForms.ReportParameter rp = new Microsoft.Reporting.WinForms.ReportParameter("week", week.ToString()); // this.reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter[] { rp }); this.PayrollBindingSource.DataSource = reports; reportViewer1.RefreshReport(); LoadingWindow.CloseForm(); }
static private void ShowForm() { splashForm = new LoadingWindow(); Application.Run(splashForm); }