protected void frmDisplayPersonalDetails_DataBound(object sender, EventArgs e) { int AccountID; if (grdAccounts.SelectedDataKey != null) { int.TryParse(grdAccounts.SelectedDataKey.Value.ToString(), out AccountID); string txt = ((Label)frmDisplayPersonalDetails.FindControl("txtTotalAmountCollected")).Text; txt = txt + String.Format("{0:#.##}", DBClass.Scalar("Select sum(Amount) from DailyTransactions where AccountID=@AccountID", System.Data.CommandType.Text, new SqlParameter("@AccountID", AccountID))); ((Label)frmDisplayPersonalDetails.FindControl("txtTotalAmountCollected")).Text = txt; txt = ((Label)frmDisplayPersonalDetails.FindControl("txtLastTransactionDate")).Text; SqlDataReader dr = DBClass.Reader("Select TransactionDate from DailyTransactions where AccountID=@AccountID order by TransactionDate DESC", System.Data.CommandType.Text, new SqlParameter("@AccountID", AccountID)); if (dr.Read()) { txt = txt + String.Format("{0:dd-MMM-yyyy}", dr[0]); } ((Label)frmDisplayPersonalDetails.FindControl("txtLastTransactionDate")).Text = txt; dr.Close(); } else { Response.Redirect("~/SomethingWentWrong.aspx"); } }
protected string GetTotalAmountCollected(string AccountID) { int GrandAmount = 0; int.TryParse(String.Format("{0:#.#}", DBClass.Scalar("Select sum(DailyTransactions.Amount) from DailyTransactions where DailyTransactions.AccountID = @AccountID", System.Data.CommandType.Text, new SqlParameter("@AccountID", AccountID))), out GrandAmount); return(GrandAmount.ToString()); }
private long GetTotalAmountCollected() { long AmountOfTheDay = 0; string FormattedAmount = String.Format("{0:#.#}", DBClass.Scalar("Select sum(Amount) as Total from DailyTransactions where TransactionDate=@TransactionDate", System.Data.CommandType.Text, new SqlParameter("@TransactionDate", GetSystemDate))); long.TryParse(FormattedAmount, out AmountOfTheDay); return(AmountOfTheDay); }
protected string GetNoOfLinkedAccounts(string CustomerID) { int Count = 0; Count = Convert.ToInt32(DBClass.Scalar("Select count(*) from Accounts where Accounts.CustomerID=@CustomerID", System.Data.CommandType.Text, new SqlParameter("@CustomerID", CustomerID))); return(Count.ToString()); }
private bool ChangePassword() { return(Convert.ToBoolean(DBClass.Scalar("spChangePassword", CommandType.StoredProcedure, new SqlParameter("@UserName", User.Identity.Name), new SqlParameter("@CurrentPassword", txtCurrentPassword.Text.Trim()), new SqlParameter("@NewPassword", txtNewPassword.Text.Trim()) ) )); }
protected void txtEditAccNo_TextChanged(object sender, EventArgs e) { int AccNo; if (int.TryParse(((TextBox)frmEditTransaction.FindControl("txtEditAccNo")).Text, out AccNo)) { string name = DBClass.Scalar("Select Name from Customers where CustomerID=(Select CustomerID from Accounts where AccNo=@AccNo)", System.Data.CommandType.Text, new SqlParameter("@AccNo", AccNo)).ToString(); Label lbl = ((Label)frmEditTransaction.FindControl("lblCustomerName")); lbl.Text = "Customer: " + name; lbl.Visible = true; Label AccID = ((Label)frmEditTransaction.FindControl("lblEditAccountID")); AccID.Text = DBClass.Scalar("Select AccountID from Accounts where AccNo=@AccNo", System.Data.CommandType.Text, new SqlParameter("@AccNo", AccNo)).ToString(); } }
protected void lnkSave_Click(object sender, EventArgs e) { if (Page.IsValid) { DBClass.NonQuery("spDailyTransactions", System.Data.CommandType.StoredProcedure, new SqlParameter("@AccountID", DBClass.Scalar("Select AccountID from Accounts where AccNo=@AccNo", System.Data.CommandType.Text, new SqlParameter("@AccNo", ((TextBox)frmDailyEntries.FindControl("txtAccNo")).Text))), new SqlParameter("@TransactionDate", GetSystemDate), new SqlParameter("@Amount", ((TextBox)frmDailyEntries.FindControl("txtAmount")).Text), new SqlParameter("@UserName", UserName)); DailyEntries.TotalCollectedAmount = GetTotalAmountCollected(); lnkRefresh_Click(sender, e); Page_Load(sender, e); LoadNextActiveAccount(); ((TextBox)frmDailyEntries.FindControl("txtAmount")).Text = ""; } }
private void AuthenticateUser(String Username, String Password) { int authenticate = Convert.ToInt32(DBClass.Scalar("spAuthenticate", CommandType.StoredProcedure, new SqlParameter("@UserName", Username), new SqlParameter("@Password", Password))); if (authenticate == 1) { Session["LoggedInTime"] = String.Format("{0:t}", DateTime.Now); FormsAuthentication.RedirectFromLoginPage(Username, false); } else { lblMsg.Text = "Invalid Username or Password ! Try Again"; } }
protected void txtAccNo_TextChanged(object sender, EventArgs e) { int IsAvailable = ((int)DBClass.Scalar("IsAccNoAvailable", System.Data.CommandType.StoredProcedure, new SqlParameter("AccNo", ((TextBox)frmAccounts.FindControl("txtAccNo")).Text))); if (IsAvailable == 0) { ((CustomValidator)frmAccounts.FindControl("cvIsAccNoAvailable")).IsValid = false; ((LinkButton)frmAccounts.FindControl("lnkSave")).Enabled = false; ((TextBox)frmAccounts.FindControl("txtAccNo")).Focus(); } else { ((LinkButton)frmAccounts.FindControl("lnkSave")).Enabled = true; ((CustomValidator)frmAccounts.FindControl("cvIsAccNoAvailable")).IsValid = true; } }
protected string GetGrandTotal() { string result = String.Format("{0:#.#}", DBClass.Scalar("Select sum(Amount) from DailyTransactions")); return(result); }