protected void cboCode_SelectedIndexChanged(object sender, System.EventArgs e) { clsTransaction DB = new clsTransaction(); cboCode.Text = cboCode.SelectedValue.Substring(0, 2); cboType.Text = DB.Find_Type(cboCode.Text); lblDescription.Text = DB.Find_Description(cboCode.Text); }
protected void cboRegNo_SelectedIndexChanged(object sender, System.EventArgs e) { clsTransaction DB = new clsTransaction(); decimal varExpense = DB.Find_Expense(cboRegNo.Text); lblExpense.Text = varExpense.ToString(); lblIncome.Text = DB.Find_Income(cboRegNo.Text).ToString(); decimal varBalance = decimal.Parse(lblExpense.Text) - decimal.Parse(lblIncome.Text); lblBalance.Text = varBalance.ToString(); }
protected void cmdAdd_Click(object sender, EventArgs e) { clsTransaction DB = new clsTransaction(); try { //Validate values if (dtTransDate.GetType() != typeof(DateTime)) { lblResults.Text = "Select a valid date"; } if (cboCode.GetType() != typeof(int)) { lblResults.Text = "Account code cannot be empty"; } if (cboType.Text == null) { lblResults.Text = "Account type cannot be empty"; } if (lblDescription.Text == null) { lblResults.Text = "Description cannot be empty"; } if (txtAmount.GetType() != typeof(decimal)) { lblResults.Text = "Amount must be numeric"; } if (cboRegNo.GetType() != typeof(String)) { lblResults.Text = "Please select a valid vehicle registration number"; } DB.Add_rec(DateTime.Parse(dtTransDate.SelectedDate.ToString()), cboCode.Text, cboType.Text, lblDescription.Text, decimal.Parse(txtAmount.Text), txtUserLabel.Text, txtChequeno.Text, cboRegNo.Text); //string selectSQL = "SELECT * FROM tb_Customer ORDER BY convert(int,customerno)"; //SqlConnection con = new SqlConnection(connectionString); //SqlCommand cmd = new SqlCommand(selectSQL, con); //SqlDataAdapter adapter = new SqlDataAdapter(cmd); // Fill the DataSet. DataSet ds = new DataSet(); ds = DB.FindTable(); //adapter.Fill(ds, "tb_Customer"); // Perform the binding. GridView1.DataSource = ds; GridView1.DataBind(); lblResults.Text = "Operation successful"; cboCode.Text = ""; cboType.Text = ""; lblDescription.Text = ""; txtAmount.Text = "0"; txtChequeno.Text = ""; cboRegNo.Text = ""; return; } catch (Exception err) { EventLog log = new EventLog(); log.Source = "Milorry Frontend"; log.WriteEntry(err.Message, EventLogEntryType.Error); return; } finally { //con.Close(); } }