private void Calculation_Load(object sender, EventArgs e) { try { int month = 0, year = 0; if (label7.Text == "") { groupBox2.Text = "Amount Calculation For the Month - " + DateTime.Now.ToString("MMMM"); label1.Text = "Current Month Calculation"; month = DateTime.Now.Month; year = DateTime.Now.Year; } else { groupBox2.Text = "Amount Calculation For the Month - " + DateTime.Now.AddMonths(-1).ToString("MMMM"); label1.Text = "Last Month Calculation"; month = (DateTime.Now.Month - 1) == 0 ? 12 : DateTime.Now.Month - 1; year = DateTime.Now.Year; } this.FormBorderStyle = FormBorderStyle.FixedSingle; FilDataGrid("grid", month, year); //FilDataGrid("user", label7.Text); txtusercount.Text = Convert.ToString(ms.GetUserCount()); cd = ms.GetCalculationAmount(label7.Text); if (cd != null) { if (cd.TotRentAmount == 0) { ms.CallMessageBox("There is an No Rent amount found for this Month.\nSo the Calculation Detailes is not Completed.", "Message", "ex"); } txtrentamount.Text = Convert.ToString(decimal.Round(cd.TotRentAmount, 2)); txtfoodamount.Text = Convert.ToString(decimal.Round(cd.TotFoodAmount, 2)); txtshareamount.Text = Convert.ToString(decimal.Round(cd.ShareAmount, 2)); txtsamountnfc.Text = Convert.ToString(decimal.Round(cd.NFoodShare, 2)); } else { ms.CallMessageBox("No transaction data found.", "Message", "ex"); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\nPlease Call system Administrator.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public CalculationDomain GetCalculationAmount(string month) { CalculationDomain cd = null; try { var sql = "EXEC [dbo].[Calculation] 'grp','" + month + "'"; cn.Open(); cd = cn.Query <CalculationDomain>(sql).SingleOrDefault(); cn.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message + "\nPlease Call system Administrator.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { cn.Close(); } return(cd); }