private void saveData() { if (!validationProvider1.Validate()) { this.validationProvider1.ValidationMessages(!this.validationProvider1.Validate()); return; } // if (propPresent()) // { // MessageBox.Show($"Property '{PName.Text}' is already registered!!"); // return; // } byte[] imagePath = null; int available = (availability.Checked) ? 1 : 0; int gard = (garden.Checked) ? 1 : 0; int corn = (corner.Checked) ? 1 : 0; String pidVal = ""; if (image.Text != "") { FileStream stream = new FileStream(image.Text, FileMode.Open, FileAccess.Read); imagePath = new BinaryReader(stream).ReadBytes((int)stream.Length); } String property_name = PName.Text; con.Open(); String qry1 = $"Update property set PropertyName='{PName.Text}',Address='{Address.Text}',AskPrice={askPrice.Text},Availablity={available} where PID={selectedpid} ;"; SqlDataReader dr = new SqlCommand(qry1, con).ExecuteReader(); dr.Close(); String qry2 = $"Update {Buy_RentText.Text} set Area={area.Text},Rooms={rooms.Text},NoFloors={noFloor.Text},Floor={floorNo.Text},Parking={parking.Text}," + $"Road={roads.Text},RegYear=@regYear,Garden={gard},Corner={corn},Additional='{additional.Text}' where PID={selectedpid}; "; if (imagePath != null) { qry2 = $"Update {Buy_RentText.Text} set Area={area.Text},Rooms={rooms.Text},NoFloors={noFloor.Text},Floor={floorNo.Text},Parking={parking.Text}," + $"Road={roads.Text},RegYear=@regYear,Garden={gard},Corner={corn},Additional={additional.Text},Photo=@imagePath where PID={selectedpid}; "; } SqlCommand cmd = new SqlCommand(qry2, con); cmd.Parameters.Add("@regYear", SqlDbType.Date).Value = regDate.Value.Date; if (imagePath != null) { cmd.Parameters.Add("@imagePath", imagePath); } cmd.ExecuteReader(); MessageBox.Show("Changes Saved successfully"); dr.Close(); con.Close(); MyProperties_UserControl.Instance.refreshDataGridView(User_Details.UID); Property_Viewer obj = new Property_Viewer(selectedpid); obj.Show(); this.Hide(); }
private void boughtView_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { DataGridViewRow row = this.boughtView.Rows[e.RowIndex]; String selected_pid = row.Cells["PID"].Value.ToString(); if (MessageBox.Show($"Do you want to see property '{row.Cells["PID"].Value.ToString()}'??", "Message", MessageBoxButtons.YesNo) == DialogResult.Yes) { Property_Viewer obj = new Property_Viewer(selected_pid); obj.Show(); } } }