/* * private float calculate_commission(int propertyprice) * { * float total_commission; * if(propertyprice <= 100000) * { * total_commission = propertyprice * (float)0.07; * total_commission = total_commission / 2; * } * else * { * float fixed_partcommission = (float)0.07 * 100000; * propertyprice -= 100000; * float second_partcommission = propertyprice * (float)0.03; * total_commission = fixed_partcommission + second_partcommission; * total_commission = total_commission/2; * } * return total_commission; * }*/ private void MANreset_Click(object sender, EventArgs e) { transactionidpreview.Clear(); Agentfirstlastname.Clear(); Customerfirstlastname.Clear(); propertypriceforsale.Clear(); managersalespropID.Clear(); transactiondatepreview.Clear(); customerpreview.Clear(); transactiondatepreview.Clear(); customerregpreview.Clear(); agentassignedpreview.Clear(); flatratepreview.Clear(); additionalpreview.Clear(); gstpreview.Clear(); transactionidcheck = 0; }
private void ontextchangepropertyid(object sender, EventArgs e) { Agentfirstlastname.Clear(); Customerfirstlastname.Clear(); propertypriceforsale.Clear(); transactionidpreview.Clear(); transactiondatepreview.Clear(); customerregpreview.Clear(); agentassignedpreview.Clear(); customerpreview.Clear(); flatratepreview.Clear(); additionalpreview.Clear(); gstpreview.Clear(); transactionidcheck = 0; if (int.TryParse(managersalespropID.Text.ToString().Trim(), out targetproperty)) { string query = "select P.Agent_ID , T.Transaction_ID, T.Trans_date, T.Flatrate, T.Additional, T.GST, C.Customer_ID, C.Cust_fname, C.Cust_lname, A.Agent_fname,A.Agent_lname, P.Prop_price, R.Reg_date "; query += "from Property P "; query += "inner join Agent A on A.Agent_ID = P.Agent_ID "; query += "inner join Registration R on R.Property_ID = P.Property_ID "; query += "inner join Customer C on C.Customer_ID = R.Customer_ID "; query += "left join Transaction T on T.Property_ID = P.Property_ID "; query += "where P.Property_ID = \"" + targetproperty + "\""; try { connection.Open(); MySqlCommand cmd = new MySqlCommand(query, connection); MySqlDataAdapter mcmd = new MySqlDataAdapter(); MySqlDataReader reader; mcmd.SelectCommand = cmd; reader = cmd.ExecuteReader(); if (reader.Read()) { propertyprice = int.Parse(reader["Prop_price"].ToString().Trim()); propertypriceforsale.Text = propertyprice.ToString(); agentidforsale = int.Parse(reader["Agent_ID"].ToString().Trim()); agentfirstname = reader["Agent_fname"].ToString(); agentlastname = reader["Agent_lname"].ToString(); customerfirstname = reader["Cust_fname"].ToString(); customerlastname = reader["Cust_lname"].ToString(); Agentfirstlastname.Text = agentfirstname + " " + agentlastname; Customerfirstlastname.Text = customerfirstname + " " + customerlastname; Registrationdate = (DateTime)reader["Reg_date"]; //Commission.Text = calculate_commission(propertyprice).ToString(); customerid = int.Parse(reader["Customer_ID"].ToString().Trim()); try { transactionidcheck = int.Parse(reader["Transaction_ID"].ToString().Trim()); Transactiondate = (DateTime)reader["Trans_date"]; MessageBox.Show("This property has already been sold on: " + Transactiondate.ToString("d")); flatrate = reader["Flatrate"].ToString(); additionalrate = reader["Additional"].ToString(); gst = reader["GST"].ToString(); transactionidpreview.Text = transactionidcheck.ToString(); transactiondatepreview.Text = Transactiondate.ToString("d"); customerpreview.Text = customerfirstname + " " + customerlastname; customerregpreview.Text = Registrationdate.ToString("d"); flatratepreview.Text = flatrate; additionalpreview.Text = additionalrate; gstpreview.Text = gst; agentassignedpreview.Text = agentfirstname + " " + agentlastname; } catch { } } } catch { MessageBox.Show("error occured"); } connection.Close(); } }