private void button3_Click(object sender, EventArgs e) { string ssn = SSNText.Text; SqlCommand delete = SqlConnectionCommand.getCommand(); delete.CommandText = "USE SRDB DELETE FROM BUYERSELLER WHERE SSN = @strssn;"; delete.Parameters.AddWithValue("@strssn", ssn); try { delete.ExecuteNonQuery(); MessageBox.Show("Successfully deleted"); } catch (Exception ex) { MessageBox.Show(" Cannot save ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); // MessageBox.Show("Faild to Add a property: " + ex.Message, "Add Property Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); }//end this.Hide(); HomePage home = new HomePage(); home.Show(); }
public void delete_trans(string tnum) { var delete = MessageBox.Show("Delete Selected Transaction ?", "Confirm Delete Transaction", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk); if (delete == DialogResult.Yes) { SqlCommand delete_trans = SqlConnectionCommand.getCommand(); delete_trans.CommandText = "USE SRDB DELETE FROM TRANSACTIONS WHERE tnum = @strtno"; delete_trans.Parameters.AddWithValue("@strtno", tnum); delete_trans.ExecuteNonQuery(); try { MessageBox.Show("Successfully Deleted" + " " + tnum, "Deleted transaction", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); ViewTransactions Trans_page = new ViewTransactions(); Trans_page.Show(); } catch (Exception ex) { } } }
public void Updateowner(string pnum, string bssn) { SqlCommand Update_ownerssn = SqlConnectionCommand.getCommand(); Update_ownerssn.CommandText = "USE srdb UPDATE PROPERTY SET " + "Ownerssn = @strbssn WHERE Pno = @strpno ;"; //addproperty.Parameters.AddWithValue("@strproperty", comboboxtype.SelectedText); Update_ownerssn.Parameters.AddWithValue("@strpno", pnum); Update_ownerssn.Parameters.AddWithValue("@strbssn", bssn); try { Update_ownerssn.ExecuteNonQuery(); /* MessageBox.Show("Successfully Updated" + " " + tno + " " + date, * "Updated Transaction", MessageBoxButtons.OK, MessageBoxIcon.Information); * * this.Hide(); * SelectedTransaction select_trans = new SelectedTransaction(); * select_trans.Show(); */ } catch (Exception ex) { } }
//---------------------------- delete function------------------- public void delete_props(string Pno) { var delete = MessageBox.Show("Delete Property ?", "Confirm Delete Property", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk); if (delete == DialogResult.Yes) { SqlCommand delete_props = SqlConnectionCommand.getCommand(); delete_props.CommandText = "USE SRDB DELETE FROM PROPERTY WHERE Pno = @pno"; delete_props.Parameters.AddWithValue("@Pno", Pno); delete_props.ExecuteNonQuery(); try { MessageBox.Show("Successfully Deleted" + " " + Pno, "Added property", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); ViewProps Props_page = new ViewProps(); Props_page.Show(); } catch (Exception ex) { } } // MessageBox.Show(delete_props.CommandText.ToString()); }
public void newtrans(string tno, string bssn, string sssn, string pno, string ptype, DateTimePicker date, float price, float profit, string agentids) { SqlCommand newtran = SqlConnectionCommand.getCommand(); newtran.CommandText = "USE SRDB INSERT INTO TRANSACTIONS Values " + "(@strtno, @strbssn, @strsssn, @strpno, @strptype, @strdate, @floatprice, @floatprofit, @stragent)"; newtran.Parameters.AddWithValue("@strtno", tno); newtran.Parameters.AddWithValue("@strbssn", bssn); newtran.Parameters.AddWithValue("@strsssn", sssn); newtran.Parameters.AddWithValue("@strpno", pno); newtran.Parameters.AddWithValue("@strptype", ptype); newtran.Parameters.AddWithValue("@strdate", dateTimePicker1.Value); newtran.Parameters.AddWithValue("@floatprice", price); newtran.Parameters.AddWithValue("@floatprofit", profit); newtran.Parameters.AddWithValue("@stragent", agentids); try { newtran.ExecuteNonQuery(); MessageBox.Show("Successfully added" + " " + tno + " " + date, "new transaction", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { // MessageBox.Show(ex.ToString()); // MessageBox.Show("Please make sure BSSN, SSSN, Property Number and Agent ID is valid", MessageBoxButtons.OK, MessageBoxIcon.Information); // MessageBox.Show("Please make sure BSSN, SSSN, Property Number and Agent ID is valid" , MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show(" Please make sure BSSN, SSSN, Property Number and Agent ID is valid ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); // MessageBox.Show("Faild to Add a property: " + ex.Message, "Add Property Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); } //end }
public void updateBUYERSELLER(string aSSN, string afname, string amname, string alname, string aemail, string aphone, string astreetAdd, string acity, string aBS_State, string azip, string status) { { float zero = 0; SqlCommand addbs = SqlConnectionCommand.getCommand(); addbs.CommandText = "USE SRDB UPDATE BUYERSELLER SET " + "Fname = @strfname, Mname = @strmname, Lname = @strlname, Email = @stremail, Phone = @strphone, " + "StreetAddress = @strstreetAdd, City = @strcity, BS_State = @strstate, Zip = @strzip, status = @strstatus" + " WHERE SSN = @strSSN;"; addbs.Parameters.AddWithValue("@strSSN", aSSN); addbs.Parameters.AddWithValue("@strfname", afname); addbs.Parameters.AddWithValue("@strmname", amname); addbs.Parameters.AddWithValue("@strlname", alname); addbs.Parameters.AddWithValue("@stremail", aemail); addbs.Parameters.AddWithValue("@strphone", aphone); addbs.Parameters.AddWithValue("@strstreetAdd", astreetAdd); addbs.Parameters.AddWithValue("@strcity", acity); addbs.Parameters.AddWithValue("@strState", aBS_State); addbs.Parameters.AddWithValue("@strzip", azip); addbs.Parameters.AddWithValue("@strstatus", status); try { addbs.ExecuteNonQuery(); MessageBox.Show("Successfully updated"); } catch (Exception ex) { MessageBox.Show("Could not update. Please try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { SqlCommand view_trans = SqlConnectionCommand.getCommand(); view_trans.CommandText = "USE SRDB SELECT(*) FROM TRANSACTIONS WHERE Pno = @pno"; view_trans.Parameters.AddWithValue("@Pno", Pnotextbox); view_trans.ExecuteNonQuery(); }
private void NumTans_TextChanged(object sender, EventArgs e) { NumTans.ReadOnly = true; SqlCommand GetData = SqlConnectionCommand.getCommand(); GetData.CommandText = "USE srdb SELECT COUNT (*) FROM PROPERTY ; "; SqlDataReader reader = GetData.ExecuteReader(); reader.Read(); NumTans.Text = reader[0].ToString(); }
private void NumSellers_TextChanged(object sender, EventArgs e) { NumSellers.ReadOnly = true; SqlCommand GetData = SqlConnectionCommand.getCommand(); GetData.CommandText = "USE srdb SELECT COUNT (*) FROM BUYERSELLER WHERE Type = 'Seller' ; "; SqlDataReader reader = GetData.ExecuteReader(); reader.Read(); NumSellers.Text = reader[0].ToString(); }
private void TotProfit_TextChanged(object sender, EventArgs e) { TotProfit.ReadOnly = true; SqlCommand GetData = SqlConnectionCommand.getCommand(); GetData.CommandText = "USE srdb SELECT SUM (Profit) FROM TRANSACTIONS ; "; SqlDataReader reader = GetData.ExecuteReader(); reader.Read(); TotProfit.Text = reader[0].ToString(); }
private void button2_Click_1(object sender, EventArgs e) { dataGridView1.ReadOnly = true; SqlCommand GetTransinfo = SqlConnectionCommand.getCommand(); GetTransinfo.CommandText = "USE SRDB SELECT * FROM TRANSACTIONS"; SqlDataReader reader = GetTransinfo.ExecuteReader(); DataTable dataTable = new DataTable(); dataTable.Load(reader); dataGridView1.DataSource = dataTable; }
private void ViewProps_Load(object sender, EventArgs e) { SqlCommand GetProperty = SqlConnectionCommand.getCommand(); GetProperty.CommandText = "USE srdb SELECT * FROM PROPERTY"; SqlDataReader reader = GetProperty.ExecuteReader(); DataTable dataTable = new DataTable(); dataTable.Load(reader); dataGridViewProperties.DataSource = dataTable; }
private void button1_Click_1(object sender, EventArgs e) { dataGridViewProperties.ReadOnly = true; SqlCommand GetBuyerSeller = SqlConnectionCommand.getCommand(); GetBuyerSeller.CommandText = "USE srdb SELECT * FROM PROPERTY"; SqlDataReader reader = GetBuyerSeller.ExecuteReader(); DataTable dataTable = new DataTable(); dataTable.Load(reader); dataGridViewProperties.DataSource = dataTable; }
private void ViewBuyerSeller_Load(object sender, EventArgs e) { dataGridViewBuyerSeller.ReadOnly = true; SqlCommand GetBuyerSeller = SqlConnectionCommand.getCommand(); GetBuyerSeller.CommandText = "USE srdb SELECT * FROM BUYERSELLER"; SqlDataReader reader = GetBuyerSeller.ExecuteReader(); DataTable dataTable = new DataTable(); dataTable.Load(reader); dataGridViewBuyerSeller.DataSource = dataTable; }
public float GetPrice(float propertynum) { SqlCommand profit = SqlConnectionCommand.getCommand(); profit.CommandText = "USE SRDB SELECT Price FROM PROPERTY WHERE Pno = @strpno ; "; profit.Parameters.AddWithValue("@strpno", propertynum); SqlDataReader Rd = profit.ExecuteReader(); Rd.Read(); MessageBox.Show(Rd[0].ToString()); return(float.Parse(Rd[0].ToString())); }
private void button2_Click_1(object sender, EventArgs e) { Agentgrid.ReadOnly = true; SqlCommand GetAgentinfo = SqlConnectionCommand.getCommand(); GetAgentinfo.CommandText = "USE srdb SELECT * FROM AGENTS"; SqlDataReader reader = GetAgentinfo.ExecuteReader(); DataTable dataTable = new DataTable(); dataTable.Load(reader); Agentgrid.DataSource = dataTable; }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { SqlCommand GetAgents = SqlConnectionCommand.getCommand(); GetAgents.CommandText = "USE srdb SELECT * FROM AGENT "; SqlDataReader reader = GetAgents.ExecuteReader(); DataTable dataTable = new DataTable(); dataTable.Load(reader); Agentgrid.DataSource = dataTable; Agentgrid.ReadOnly = true; String type = Agentgrid.Rows[e.RowIndex].Cells[0].Value.ToString(); this.Hide(); SelectedAgent Agent_page = new SelectedAgent(); Agent_page.AgentIDBox.Text = Agentgrid.Rows[e.RowIndex].Cells[0].Value.ToString(); Agent_page.Firstnamebox.Text = Agentgrid.Rows[e.RowIndex].Cells[1].Value.ToString(); Agent_page.Lastnamrbox.Text = Agentgrid.Rows[e.RowIndex].Cells[2].Value.ToString(); Agent_page.AddressBox.Text = Agentgrid.Rows[e.RowIndex].Cells[3].Value.ToString(); Agent_page.CityBox.Text = Agentgrid.Rows[e.RowIndex].Cells[4].Value.ToString(); Agent_page.statetextbox.Text = Agentgrid.Rows[e.RowIndex].Cells[5].Value.ToString(); Agent_page.Zipcodebox.Text = Agentgrid.Rows[e.RowIndex].Cells[6].Value.ToString(); Agent_page.PhoneBox.Text = Agentgrid.Rows[e.RowIndex].Cells[7].Value.ToString(); Agent_page.EmailBox.Text = Agentgrid.Rows[e.RowIndex].Cells[8].Value.ToString(); Agent_page.StartDateBOx.Text = Agentgrid.Rows[e.RowIndex].Cells[9].Value.ToString(); Agent_page.DOBBox.Text = Agentgrid.Rows[e.RowIndex].Cells[10].Value.ToString(); Agent_page.StatusBox.Text = Agentgrid.Rows[e.RowIndex].Cells[11].Value.ToString(); /*Property_page.Fname.Text = dataGridViewBuyerSeller.Rows[e.RowIndex].Cells[2].Value.ToString(); * Property_page.Mname.Text = dataGridViewBuyerSeller.Rows[e.RowIndex].Cells[3].Value.ToString(); * Property_page.Lname.Text = dataGridViewBuyerSeller.Rows[e.RowIndex].Cells[4].Value.ToString(); * Property_page.Email.Text = dataGridViewBuyerSeller.Rows[e.RowIndex].Cells[5].Value.ToString(); * Property_page.Phone.Text = dataGridViewBuyerSeller.Rows[e.RowIndex].Cells[6].Value.ToString(); * Property_page.StrAdd.Text = dataGridViewBuyerSeller.Rows[e.RowIndex].Cells[7].Value.ToString(); * Property_page.City.Text = dataGridViewBuyerSeller.Rows[e.RowIndex].Cells[8].Value.ToString(); * Property_page.State.Text = dataGridViewBuyerSeller.Rows[e.RowIndex].Cells[9].Value.ToString(); * Property_page.Zip.Text = dataGridViewBuyerSeller.Rows[e.RowIndex].Cells[10].Value.ToString();*/ Agent_page.Show(); }
private void ViewBuyerSeller_Load(object sender, EventArgs e) { dataGridView1.ReadOnly = true; SqlCommand GetProp = SqlConnectionCommand.getCommand(); GetProp.CommandText = "USE srdb SELECT * FROM PROPERTY Where Ownerssn = @strssn;"; SqlDataReader reader = GetProp.ExecuteReader(); GetProp.Parameters.AddWithValue("@strssn", SSNText.Text); DataTable dataTable = new DataTable(); dataTable.Load(reader); dataGridView1.DataSource = dataTable; }
private void GVPropOwn_CellContentClick(object sender, DataGridViewCellEventArgs e) { GVPropOwn.ReadOnly = true; SqlCommand GetProps = SqlConnectionCommand.getCommand(); GetProps.CommandText = "USE srdb SELECT * FROM PROPERTY Where Ownerssn = @strssn;"; SqlDataReader reader = GetProps.ExecuteReader(); GetProps.Parameters.AddWithValue("@strssn", SSNText.Text); DataTable dataTable = new DataTable(); dataTable.Load(reader); GVPropOwn.DataSource = dataTable; }
private void ViewAgents_Load(object sender, EventArgs e) { SqlCommand GetAgent = SqlConnectionCommand.getCommand(); GetAgent.CommandText = "USE srdb SELECT * FROM AGENT"; SqlDataReader reader = GetAgent.ExecuteReader(); DataTable dataTable = new DataTable(); dataTable.Load(reader); Agentgrid.DataSource = dataTable; // DOBdateTimePicker.Value.tos = null; // SDdateTimePicker.Value = null; }
private void dataGridView2_Load(object sender, EventArgs e) { TransGV.ReadOnly = true; SqlCommand GetData = SqlConnectionCommand.getCommand(); GetData.Parameters.AddWithValue("@strssn", SSNText.Text); GetData.CommandText = "USE srdb SELECT * FROM TRANSACTIONS Where sssn = @strssn ; "; SqlDataReader reader = GetData.ExecuteReader(); DataTable dataTable = new DataTable(); dataTable.Load(reader); TransGV.DataSource = dataTable; }
private void ViewTransactions_Load(object sender, EventArgs e) { /*dataGridView1.ReadOnly = true; SqlCommand GetTransactions = SqlConnectionCommand.getCommand(); GetTransactions.CommandText = "USE srdb SELECT * FROM TRANSACTIONS"; SqlDataReader reader = GetTransactions.ExecuteReader(); DataTable dataTable = new DataTable(); dataTable.Load(reader); dataGridView1.DataSource = dataTable; */ //// dataGridView1.ReadOnly = true; //SqlCommand GetTransactions = SqlConnectionCommand.getCommand(); // GetTransactions.CommandText = "USE srdb SELECT * FROM TRANSACTIONS"; //SqlDataReader reader = GetTransactions.ExecuteReader(); //DataTable dataTable = new DataTable(); //dataTable.Load(reader); //dataGridView1.DataSource = dataTable; // MessageBox.Show(.ToString()); SqlCommand searchtransactions = SqlConnectionCommand.getCommand(); searchtransactions.CommandText = "USE SRDB SELECT * FROM TRANSACTIONS"; try { SqlDataReader reader = searchtransactions.ExecuteReader(); DataTable dataTable = new DataTable(); dataTable.Load(reader); dataGridView1.DataSource = dataTable; // MessageBox.Show("Successfully added" + " " + + " " + type, } catch (Exception ex) { }//end }
public void updateAgent(string AgentID, string Fname, string Lname, string Address, string city, string state, string zip, string phone, string Email, DateTimePicker DOB, DateTimePicker StartDate, string Status) { { SqlCommand updateAgent = SqlConnectionCommand.getCommand(); updateAgent.CommandText = "USE SRDB UPDATE AGENT SET " + "First_name = @strFirst_name, Last_name = @strLast_name, Street = @strStreet, City = @strCity, State = @strState, Zip = @strZip, A_phone = @strA_phone," + " A_email = @strA_email, Start_Date = @strDate, DOB = @strDOB, Status = @strstatus WHERE Agent_id = @strAgent_id"; //addproperty.Parameters.AddWithValue("@strproperty", comboboxtype.SelectedText); updateAgent.Parameters.AddWithValue("@strAgent_id", AgentID); updateAgent.Parameters.AddWithValue("@strFirst_name", Fname); updateAgent.Parameters.AddWithValue("@strLast_name", Lname); updateAgent.Parameters.AddWithValue("@strStreet", Address); updateAgent.Parameters.AddWithValue("@strCity", city); updateAgent.Parameters.AddWithValue("@strState", state); updateAgent.Parameters.AddWithValue("@strZip", zip); updateAgent.Parameters.AddWithValue("@strA_phone", phone); updateAgent.Parameters.AddWithValue("@strA_email", Email); updateAgent.Parameters.AddWithValue("@strDate", StartDate.Value); updateAgent.Parameters.AddWithValue("@strDOB", DOB.Value); updateAgent.Parameters.AddWithValue("@strstatus", Status); // MessageBox.Show(updateAgent.CommandText.ToString()); try { updateAgent.ExecuteNonQuery(); MessageBox.Show("Successfully Updated" + " " + AgentID + " " + Fname, "Added as an Agent", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); ViewAgents view_agent = new ViewAgents(); view_agent.Show(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); // MessageBox.Show(" Please Enter a Different Agent Number ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); // MessageBox.Show("Faild to Add a property: " + ex.Message, "Add Property Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); } //end } }
public void addproperty(string Pno, string type, string status, string Address, string city, string state, string zip, string county, float Area, float price, float tax, string Date, string ownerssn) { { SqlCommand addproperty = SqlConnectionCommand.getCommand(); addproperty.CommandText = "USE SRDB INSERT INTO PROPERTY Values" + "(@strPNO, @strtype, @strDate, @floatprice, @strstatus, @floatTax, @strAddress, @strcity, @strstate, @strzip," + "@strcounty, @floatArea, @strownerssn)"; //addproperty.Parameters.AddWithValue("@strproperty", comboboxtype.SelectedText); addproperty.Parameters.AddWithValue("@strPno", Pno); addproperty.Parameters.AddWithValue("@strtype", type); addproperty.Parameters.AddWithValue("@strstatus", status); addproperty.Parameters.AddWithValue("@strAddress", Address); addproperty.Parameters.AddWithValue("@strCity", city); addproperty.Parameters.AddWithValue("@strstate", state); addproperty.Parameters.AddWithValue("@strzip", zip); addproperty.Parameters.AddWithValue("@strcounty", county); addproperty.Parameters.AddWithValue("@floatarea", Area); addproperty.Parameters.AddWithValue("@floatprice", price); addproperty.Parameters.AddWithValue("@floatTax", tax); addproperty.Parameters.AddWithValue("@strDate", Date); addproperty.Parameters.AddWithValue("@strownerssn", ownerssn); // MessageBox.Show(addproperty.CommandText.ToString()); try { addproperty.ExecuteNonQuery(); MessageBox.Show("Successfully added" + " " + Pno + " " + type, "Added property", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); ViewProps view_props = new ViewProps(); view_props.Show(); } catch (Exception ex) { MessageBox.Show(" Please Make sure that you Entered a Valid Seller SSN Number in the OwnerSSN Box ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); // MessageBox.Show("Faild to Add a property: " + ex.Message, "Add Property Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); }//end } }
public void Update_Property(string type, string Pno, string Address, string city, string state, string zip, string county, string status, float Area, float price, float tax, string Date, string ownerssn) { { SqlCommand Update_Property = SqlConnectionCommand.getCommand(); Update_Property.CommandText = "USE srdb UPDATE PROPERTY SET " + "Type = @strtype, Date = @strDate, price = @floatprice, status = @strstatus, Tax = @floatTax, Address = @strAddress, city = @strcity, state = @strstate, zip = @strzip," + " county = @strcounty, Area = @floatArea, ownerssn = @strOwnerssn WHERE PNO = @strPno"; //addproperty.Parameters.AddWithValue("@strproperty", comboboxtype.SelectedText); Update_Property.Parameters.AddWithValue("@strPno", Pno); Update_Property.Parameters.AddWithValue("@strtype", type); Update_Property.Parameters.AddWithValue("@strstatus", status); Update_Property.Parameters.AddWithValue("@strAddress", Address); Update_Property.Parameters.AddWithValue("@strCity", city); Update_Property.Parameters.AddWithValue("@strstate", state); Update_Property.Parameters.AddWithValue("@strzip", zip); Update_Property.Parameters.AddWithValue("@strcounty", county); Update_Property.Parameters.AddWithValue("@floatarea", Area); Update_Property.Parameters.AddWithValue("@floatprice", price); Update_Property.Parameters.AddWithValue("@floatTax", tax); Update_Property.Parameters.AddWithValue("@strDate", Date); Update_Property.Parameters.AddWithValue("@strOwnerssn", ownerssn); // MessageBox.Show(Update_Property.CommandText.ToString()); try { Update_Property.ExecuteNonQuery(); MessageBox.Show("Successfully Updated" + " " + Pno + " " + type, "Updated property", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); ViewProps view_props = new ViewProps(); view_props.Show(); } catch (Exception ex) { //MessageBox.Show(" Please Enter a Different PNO Number ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Faild to Update a property: " + ex.Message, "Update Property Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); }//end } }
public void SearchAgent(string AgentID, string Fname, string Lname, string Address, string city, string state, string zip, string phone, string Email, DateTimePicker DOB, DateTimePicker StartDate, string status) { { SqlCommand SearchAgent = SqlConnectionCommand.getCommand(); SearchAgent.CommandText = "USE SRDB INSERT INTO AGENT Values" + "(@strAgent_id, @strFirst_name, @strLast_name, @strStreet, @strCity, @strState, @strZip, @strA_phone," + " @strA_email, @strDate, @strDOB, @strstatus)"; //addproperty.Parameters.AddWithValue("@strproperty", comboboxtype.SelectedText); SearchAgent.Parameters.AddWithValue("@strstatus", status); SearchAgent.Parameters.AddWithValue("@strAgent_id", AgentID); SearchAgent.Parameters.AddWithValue("@strFirst_name", Fname); SearchAgent.Parameters.AddWithValue("@strLast_name", Lname); SearchAgent.Parameters.AddWithValue("@strStreet", Address); SearchAgent.Parameters.AddWithValue("@strCity", city); SearchAgent.Parameters.AddWithValue("@strState", state); SearchAgent.Parameters.AddWithValue("@strZip", zip); SearchAgent.Parameters.AddWithValue("@strA_phone", phone); SearchAgent.Parameters.AddWithValue("@strA_email", Email); SearchAgent.Parameters.AddWithValue("@strDate", StartDate.Value); SearchAgent.Parameters.AddWithValue("@strDOB", DOB.Value); // MessageBox.Show(SearchAgent.CommandText.ToString()); try { SearchAgent.ExecuteNonQuery(); MessageBox.Show("Successfully added" + " " + AgentID + " " + Fname, "Added as an Agent", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); ViewAgents Home_page = new ViewAgents(); Home_page.Show(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); // MessageBox.Show(" Please Enter a Different Agent Number ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); // MessageBox.Show("Faild to Add a property: " + ex.Message, "Add Property Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); }//end } }
public string Gettype(string propertynumb) { SqlCommand ptype = SqlConnectionCommand.getCommand(); ptype.CommandText = "USE SRDB SELECT Type FROM PROPERTY WHERE Pno = @strpno ; "; ptype.Parameters.AddWithValue("@strpno", propertynumb); var proptype = ptype.ExecuteScalar(); if (proptype == DBNull.Value) { MessageBox.Show("error"); return(null); } else { MessageBox.Show(proptype.ToString()); return(proptype.ToString()); } }
private void SelectedAgent_Load(object sender, EventArgs e) { SqlCommand Seach_trans_Agent = SqlConnectionCommand.getCommand(); Seach_trans_Agent.CommandText = "USE SRDB SELECT * FROM TRANSACTIONS Where AgentId = @Agent_ID"; Seach_trans_Agent.Parameters.AddWithValue("@Agent_ID", AgentIDBox.Text); try { SqlDataReader reader = Seach_trans_Agent.ExecuteReader(); DataTable dataTable = new DataTable(); dataTable.Load(reader); agentgrid.DataSource = dataTable; // MessageBox.Show("Successfully added" + " " + + " " + type, } catch (Exception ex) { }//end }
public void Update_Transaction(string tno, string bssn, string sssn, string pno, string ptype, DateTimePicker date, float price, float profit, string agent) { { SqlCommand Update_Transaction = SqlConnectionCommand.getCommand(); Update_Transaction.CommandText = "USE srdb UPDATE TRANSACTIONS SET " + "BSSN = @strbssn, SSSN = @strsssn, Pno = @strpno,PType = @strptype, Date = @strdate, Price = @floatprice, Profit = @floatprofit, AgentID = @stragent WHERE tnum = @strtno;"; //addproperty.Parameters.AddWithValue("@strproperty", comboboxtype.SelectedText); Update_Transaction.Parameters.AddWithValue("@strtno", tno); Update_Transaction.Parameters.AddWithValue("@strbssn", bssn); Update_Transaction.Parameters.AddWithValue("@strsssn", sssn); Update_Transaction.Parameters.AddWithValue("@strpno", pno); Update_Transaction.Parameters.AddWithValue("@strptype", ptype); Update_Transaction.Parameters.AddWithValue("@strdate", dateTimePicker1.Value); Update_Transaction.Parameters.AddWithValue("@floatprice", price); Update_Transaction.Parameters.AddWithValue("@floatprofit", profit); Update_Transaction.Parameters.AddWithValue("@stragent", agent); MessageBox.Show(Update_Transaction.CommandText.ToString()); try { Update_Transaction.ExecuteNonQuery(); MessageBox.Show("Successfully Updated" + " " + tno + " " + date, "Updated Transaction", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); SelectedTransaction select_trans = new SelectedTransaction(); select_trans.Show(); } catch (Exception ex) { MessageBox.Show(" Please make sure BSSN, SSSN, Property Number and Agent ID is valid ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); //MessageBox.Show(" Please Enter a Different PNO Number ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); // MessageBox.Show("Failed to Update a transaction: " + ex.Message, "Update transaction Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); }//end Updateowner(propertynum.Text, buyerssn.Text); } }
private void SelectedProperty_Load(object sender, EventArgs e) { SqlCommand Seach_trans_Props = SqlConnectionCommand.getCommand(); Seach_trans_Props.CommandText = "USE SRDB SELECT * FROM TRANSACTIONS Where Pno = @Pno"; Seach_trans_Props.Parameters.AddWithValue("@Pno", Pnotextbox.Text); try { SqlDataReader reader = Seach_trans_Props.ExecuteReader(); DataTable dataTable = new DataTable(); dataTable.Load(reader); dataGridView1.DataSource = dataTable; // MessageBox.Show("Successfully added" + " " + + " " + type, } catch (Exception ex) { }//end }