public List <Facilities> GetAllByFacilitiesTypeID(int _FacilitiesTypeID) { SqlConnection Connection = DBGate.GetConnection(); string SelectAll = " select * from Facilities where FacilitiesTypeID=@FacilitiesTypeID"; SqlCommand cmd = new SqlCommand(SelectAll, Connection); cmd.Parameters.AddWithValue("@FacilitiesTypeID", _FacilitiesTypeID); List <Facilities> lst = new List <Facilities>(); try { Connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Facilities _obj = new Facilities(); _obj.ID = int.Parse(reader["ID"].ToString()); _obj.FacilitiesName = reader["FacilitiesName"].ToString(); _obj.FacilitiesTypeID = int.Parse(reader["FacilitiesTypeID"].ToString()); _obj.Statuis = bool.Parse(reader["Statuis"].ToString()); lst.Add(_obj); } } catch (SqlException ex) { frmDone frmerror = new frmDone(ex.ToString()); frmerror.ShowDialog(); } finally { Connection.Close(); } return(lst); }
public List <SpecialRequests> GetAll() { SqlConnection Connection = DBGate.GetConnection(); string SelectAll = " select * from SpecialRequests "; SqlCommand cmd = new SqlCommand(SelectAll, Connection); List <SpecialRequests> lst = new List <SpecialRequests>(); try { Connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { SpecialRequests _obj = new SpecialRequests(); _obj.ID = int.Parse(reader["ID"].ToString()); _obj.Name = reader["Name"].ToString(); lst.Add(_obj); } } catch (SqlException ex) { frmDone frmerror = new frmDone(ex.ToString()); frmerror.ShowDialog(); } finally { Connection.Close(); } return(lst); }
public DAL.SpecialRequests GetByID(int ID) { SqlConnection Connection = DBGate.GetConnection(); string SelectByID = "Select * from SpecialRequests where ID = @ID "; SqlCommand cmd = new SqlCommand(SelectByID, Connection); cmd.Parameters.AddWithValue("@ID", ID); SpecialRequests _obj = new SpecialRequests(); try { Connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { _obj.ID = int.Parse(reader["ID"].ToString()); _obj.Name = reader["Name"].ToString(); } } catch (SqlException ex) { frmDone frmerror = new frmDone(ex.ToString()); frmerror.ShowDialog(); } finally { Connection.Close(); } return(_obj); }
public bool Delete(int ID) { SqlConnection Connection = DBGate.GetConnection(); string Delete = "Delete from SpecialRequests where ID=@ID "; SqlCommand cmd = new SqlCommand(Delete, Connection); cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@ID", ID); try { Connection.Open(); int count = cmd.ExecuteNonQuery(); if (count > 0) { return(true); } else { return(false); } } catch (SqlException ex) { frmDone frmerror = new frmDone(ex.ToString()); frmerror.ShowDialog(); return(false); } finally { Connection.Close(); } }
public List <Facilities> GetFacilitiesName() { SqlConnection Connection = DBGate.GetConnection(); string SelectAll = " select Facilities.id , FacilitiesType.Name as TypeName , Facilities.FacilitiesName as FacilitiesName from Facilities join Facilitiestype on FacilitiesType.ID = Facilities.FacilitiesTypeID"; SqlCommand cmd = new SqlCommand(SelectAll, Connection); List <Facilities> lst = new List <Facilities>(); try { Connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Facilities _obj = new Facilities(); _obj.ID = int.Parse(reader["ID"].ToString()); _obj.FacilitiesType = reader["TypeName"].ToString(); _obj.FacilitiesName = reader["FacilitiesName"].ToString(); lst.Add(_obj); } } catch (SqlException ex) { frmDone frmerror = new frmDone(ex.ToString()); frmerror.ShowDialog(); } finally { Connection.Close(); } return(lst); }
public bool Add() { SqlConnection Connection = DBGate.GetConnection(); string Add = "INSERT into " + " Unites " + " ( " + " UnitTypeID " + " ,FloorID " + " ,UnitName " + " ,StatusID " + " ,StatusReason " + " ) " + "VALUES " + " ( " + " @UnitTypeID " + " ,@FloorID " + " ,@UnitName " + " ,@StatusID " + " ,@StatusReason " + " ) " + ""; SqlCommand cmd = new SqlCommand(Add, Connection); cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@UnitTypeID", UnitTypeID); cmd.Parameters.AddWithValue("@FloorID", FloorID); cmd.Parameters.AddWithValue("@UnitName", UnitName); cmd.Parameters.AddWithValue("@StatusID", StatusID); cmd.Parameters.AddWithValue("@StatusReason", StatusReason); try { Connection.Open(); int count = cmd.ExecuteNonQuery(); if (count > 0) { return(true); } else { return(false); } } catch (SqlException ex) { frmDone frmerror = new frmDone(ex.ToString()); frmerror.ShowDialog(); return(false); } finally { Connection.Close(); } }
public bool Add() { SqlConnection Connection = DBGate.GetConnection(); string Add = "INSERT into " + " Pictures " + " ( " + " Image " + " ,UniteID " + " ) " + "VALUES " + " ( " + " @Image " + " ,@UniteID " + " ) " + ""; SqlCommand cmd = new SqlCommand(Add, Connection); cmd.Parameters.Clear(); // System.IO.MemoryStream Mem = new System.IO.MemoryStream(); Image.Save(Mem, System.Drawing.Imaging.ImageFormat.Png); byte[] Data = new byte[Mem.Length]; Data = Mem.ToArray(); // cmd.Parameters.AddWithValue("@Image", Data); cmd.Parameters.AddWithValue("@UniteID", UniteID); try { Connection.Open(); int count = cmd.ExecuteNonQuery(); if (count > 0) { return(true); } else { return(false); } } catch (SqlException ex) { frmDone frmerror = new frmDone(ex.ToString()); frmerror.ShowDialog(); return(false); } finally { Connection.Close(); } }
private void btnDelete_Click(object sender, EventArgs e) { bool msg = currentobj.Delete(ID); if (msg == true) { frmDone frmdone = new frmDone("Delete Done"); frmdone.ShowDialog(); BindGrid(); } else { frmDone frmdone = new frmDone("Error"); frmdone.ShowDialog(); } }
private void Save(object sender, EventArgs e) { if (valdation()) { Collect(); Properties.Settings.Default.Save(); frmDone frmdone = new frmDone("Saved Done "); frmdone.ShowDialog(); Push(); } else { frmDone frmdone = new frmDone("Sorry Not Allow To Update"); frmdone.ShowDialog(); } }
public bool Update() { SqlConnection Connection = DBGate.GetConnection(); string Update = "update Unites " + " Set " + " UnitTypeID =@UnitTypeID " + " ,FloorID =@FloorID " + " ,UnitName =@UnitName " + " ,StatusID =@StatusID " + " ,StatusReason =@StatusReason " + " where " + " ID =@ID "; SqlCommand cmd = new SqlCommand(Update, Connection); cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@ID", ID); cmd.Parameters.AddWithValue("@UnitTypeID", UnitTypeID); cmd.Parameters.AddWithValue("@FloorID", FloorID); cmd.Parameters.AddWithValue("@UnitName", UnitName); cmd.Parameters.AddWithValue("@StatusID", StatusID); cmd.Parameters.AddWithValue("@StatusReason", StatusReason); try { Connection.Open(); int count = cmd.ExecuteNonQuery(); if (count > 0) { return(true); } else { return(false); } } catch (SqlException ex) { frmDone frmerror = new frmDone(ex.ToString()); frmerror.ShowDialog(); return(false); } finally { Connection.Close(); } }
void Updated() { currentobj.Name = txtName.Text; currentobj.ID = ID; bool msg = currentobj.Update(); if (msg == true) { frmDone frmdone = new frmDone("Update Done"); frmdone.ShowDialog(); BindGrid(); } else { frmDone frmdone = new frmDone("Error"); frmdone.ShowDialog(); } }
void Add() { currentobj.Name = txtName.Text; bool msg = currentobj.Add(); if (msg == true) { frmDone frmdone = new frmDone("Saved Done"); frmdone.ShowDialog(); BindGrid(); } else { frmDone frmdone = new frmDone("Error"); frmdone.ShowDialog(); } }
public DAL.UniteDetails GetByID(int ID) { SqlConnection Connection = DBGate.GetConnection(); string SelectByID = "Select * from UniteDetails where ID = @ID "; SqlCommand cmd = new SqlCommand(SelectByID, Connection); cmd.Parameters.AddWithValue("@ID", ID); UniteDetails _obj = new UniteDetails(); try { Connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { _obj.ID = int.Parse(reader["ID"].ToString()); _obj.UnittypeID = int.Parse(reader["UnittypeID"].ToString()); _obj.UniteName = reader["UniteName"].ToString(); _obj.SmokingPolicy = bool.Parse(reader["SmokingPolicy"].ToString()); _obj.PoolPolicy = bool.Parse(reader["PoolPolicy"].ToString()); _obj.Size = reader["Size"].ToString(); // _obj.ApartmentNumber = int.Parse(reader["ApartmentNumber"].ToString()); _obj.GustNumber = int.Parse(reader["GustNumber"].ToString()); _obj.BedRoomNumber = int.Parse(reader["BedRoomNumber"].ToString()); _obj.LivingRoomNumber = int.Parse(reader["LivingRoomNumber"].ToString()); _obj.BedKind = int.Parse(reader["BedKind"].ToString()); _obj.BedNumber = int.Parse(reader["BedNumber"].ToString()); _obj.SofaBedNumber = int.Parse(reader["SofaBedNumber"].ToString()); _obj.BathroomNumber = int.Parse(reader["BathroomNumber"].ToString()); _obj.PrivateBathRoomNumber = int.Parse(reader["PrivateBathRoomNumber"].ToString()); } } catch (SqlException ex) { frmDone frmerror = new frmDone(ex.ToString()); frmerror.ShowDialog(); } finally { Connection.Close(); } return(_obj); }
public DAL.Reservations GetByID(int ID) { SqlConnection Connection = DBGate.GetConnection(); string SelectByID = "Select * from Reservations where ID = @ID "; SqlCommand cmd = new SqlCommand(SelectByID, Connection); cmd.Parameters.AddWithValue("@ID", ID); Reservations _obj = new Reservations(); try { Connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { _obj.ID = int.Parse(reader["ID"].ToString()); _obj.FirstName = reader["FirstName"].ToString(); _obj.LastName = reader["LastName"].ToString(); _obj.Mobile = reader["Mobile"].ToString(); _obj.UniteName = reader["UniteName"].ToString(); // _obj.CheckIn = DateTime.Parse(reader["CheckIn"].ToString()); _obj.CheckOut = DateTime.Parse(reader["CheckOut"].ToString()); _obj.Bookedon = DateTime.Parse(reader["Bookedon"].ToString()); _obj.Status = reader["Status"].ToString(); _obj.Days = int.Parse(reader["Days"].ToString()); // _obj.TotalPrice = double.Parse(reader["TotalPrice"].ToString()); _obj.Commission = double.Parse(reader["Commission"].ToString()); _obj.RoomNo = reader["RoomNo"].ToString(); } } catch (SqlException ex) { frmDone frmerror = new frmDone(ex.ToString()); frmerror.ShowDialog(); } finally { Connection.Close(); } return(_obj); }
void Updated() { currentobj.AmenitiesTypeID = int.Parse(CMBType.SelectedValue.ToString()); currentobj.AmenitiesName = txtName.Text; currentobj.ID = ID; bool msg = currentobj.Update(); if (msg == true) { frmDone frmdone = new frmDone("Update Done"); frmdone.ShowDialog(); BindGrid(); } else { frmDone frmdone = new frmDone("Error"); frmdone.ShowDialog(); } }
void Add() { currentobj.FacilitiesTypeID = int.Parse(CMBType.SelectedValue.ToString()); currentobj.FacilitiesName = txtName.Text; bool msg = currentobj.AddFacilities(); if (msg == true) { frmDone frmdone = new frmDone("Saved Done"); frmdone.ShowDialog(); BindGrid(); } else { frmDone frmdone = new frmDone("Error"); frmdone.ShowDialog(); } }
// FrontOffice Frm public List <Reservations> Search(DateTime _CheckOut) { SqlConnection Connection = DBGate.GetConnection(); string SelectAll = " select * from Reservations where CheckOut >= @Out "; SqlCommand cmd = new SqlCommand(SelectAll, Connection); cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@Out", _CheckOut); List <Reservations> lst = new List <Reservations>(); try { Connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Reservations _obj = new Reservations(); _obj.ID = int.Parse(reader["ID"].ToString()); _obj.FirstName = reader["FirstName"].ToString(); _obj.LastName = reader["LastName"].ToString(); _obj.Mobile = reader["Mobile"].ToString(); _obj.UniteName = reader["UniteName"].ToString(); // _obj.CheckIn = DateTime.Parse(reader["CheckIn"].ToString()); _obj.CheckOut = DateTime.Parse(reader["CheckOut"].ToString()); _obj.Bookedon = DateTime.Parse(reader["Bookedon"].ToString()); _obj.Status = reader["Status"].ToString(); _obj.Days = int.Parse(reader["Days"].ToString()); // _obj.TotalPrice = double.Parse(reader["TotalPrice"].ToString()); _obj.Commission = double.Parse(reader["Commission"].ToString()); _obj.RoomNo = reader["RoomNo"].ToString(); lst.Add(_obj); } } catch (SqlException ex) { frmDone frmerror = new frmDone(ex.ToString()); frmerror.ShowDialog(); } finally { Connection.Close(); } return(lst); }
public List <UniteDetails> GetAll() { SqlConnection Connection = DBGate.GetConnection(); string SelectAll = " select * from UniteDetails "; SqlCommand cmd = new SqlCommand(SelectAll, Connection); List <UniteDetails> lst = new List <UniteDetails>(); try { Connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { UniteDetails _obj = new UniteDetails(); _obj.ID = int.Parse(reader["ID"].ToString()); _obj.UnittypeID = int.Parse(reader["UnittypeID"].ToString()); _obj.UniteName = reader["UniteName"].ToString(); _obj.SmokingPolicy = bool.Parse(reader["SmokingPolicy"].ToString()); _obj.PoolPolicy = bool.Parse(reader["PoolPolicy"].ToString()); _obj.Size = reader["Size"].ToString(); // _obj.ApartmentNumber = int.Parse(reader["ApartmentNumber"].ToString()); _obj.GustNumber = int.Parse(reader["GustNumber"].ToString()); _obj.BedRoomNumber = int.Parse(reader["BedRoomNumber"].ToString()); _obj.LivingRoomNumber = int.Parse(reader["LivingRoomNumber"].ToString()); _obj.BedKind = int.Parse(reader["BedKind"].ToString()); _obj.BedNumber = int.Parse(reader["BedNumber"].ToString()); _obj.SofaBedNumber = int.Parse(reader["SofaBedNumber"].ToString()); _obj.BathroomNumber = int.Parse(reader["BathroomNumber"].ToString()); _obj.PrivateBathRoomNumber = int.Parse(reader["PrivateBathRoomNumber"].ToString()); lst.Add(_obj); } } catch (SqlException ex) { frmDone frmerror = new frmDone(ex.ToString()); frmerror.ShowDialog(); } finally { Connection.Close(); } return(lst); }
public bool AddFacilities() { SqlConnection Connection = DBGate.GetConnection(); string Add = "INSERT into " + " AmenitiesType " + " ( " + " Name " + " ) " + "VALUES " + " ( " + " @Name " + " ) " + ""; SqlCommand cmd = new SqlCommand(Add, Connection); cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@Name", Name); try { Connection.Open(); int count = cmd.ExecuteNonQuery(); if (count > 0) { return(true); } else { return(false); } } catch (SqlException ex) { frmDone frmerror = new frmDone(ex.ToString()); frmerror.ShowDialog(); return(false); } finally { Connection.Close(); } }
public bool Update() { SqlConnection Connection = DBGate.GetConnection(); string Update = "update Status " + " Set " + " Status =@Status " + " ,Color =@Color " + " where " + " ID =@ID "; SqlCommand cmd = new SqlCommand(Update, Connection); cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@ID", ID); cmd.Parameters.AddWithValue("@Status", _Status); cmd.Parameters.AddWithValue("@Color", Color); try { Connection.Open(); int count = cmd.ExecuteNonQuery(); if (count > 0) { return(true); } else { return(false); } } catch (SqlException ex) { frmDone frmerror = new frmDone(ex.ToString()); frmerror.ShowDialog(); return(false); } finally { Connection.Close(); } }
void Updated() { currentobj.UnitTypeID = int.Parse(CMBType.SelectedValue.ToString()); currentobj.FloorID = int.Parse(CMBFloors.SelectedValue.ToString()); currentobj.StatusID = 1; currentobj.StatusReason = " "; currentobj.UnitName = txtName.Text; currentobj.ID = ID; bool msg = currentobj.Update(); if (msg == true) { frmDone frmdone = new frmDone("Update Done"); frmdone.ShowDialog(); BindGrid(); } else { frmDone frmdone = new frmDone("Error"); frmdone.ShowDialog(); } }
void AddImage() { if (Pic1.Image == null) { Pic1.Image = Properties.Resources.download_icon_2x; } if (Pic2.Image == null) { Pic2.Image = Properties.Resources.download_icon_2x; } if (Pic3.Image == null) { Pic3.Image = Properties.Resources.download_icon_2x; } if (Pic4.Image == null) { Pic4.Image = Properties.Resources.download_icon_2x; } PictureBox[] pictureBoxs = new PictureBox[4]; pictureBoxs[0] = Pic1; pictureBoxs[1] = Pic2; pictureBoxs[2] = Pic3; pictureBoxs[3] = Pic4; for (int i = 0; i < 4; i++) { if (pictureBoxs[i].Image != null) { Picobj.UniteID = ID; Picobj.Image = pictureBoxs[i].Image; Picobj.Add(); } } frmDone frm = new frmDone("Saved Done"); frm.ShowDialog(); }
bool Valadations() { if (CMBUnitType.SelectedIndex == -1) { frmDone frm = new frmDone("Please Select Unite Type"); frm.ShowDialog(); return(false); } if (CMBBedKind.SelectedIndex == -1) { frmDone frm = new frmDone("What kind of beds are available in this room?"); frm.ShowDialog(); return(false); } if (CMBSmoking.SelectedIndex == -1) { frmDone frm = new frmDone("Please Select Smoking policy"); frm.ShowDialog(); return(false); } if (txtApartmentName.TextLength == 0) { frmDone frm = new frmDone("Please Enter ApartmentName"); frm.ShowDialog(); return(false); } // Numbers if (txtUniteSize.TextLength == 0) { frmDone frm = new frmDone("Please Enter UniteSize"); frm.ShowDialog(); return(false); } if (txtGustNumber.TextLength == 0) { frmDone frm = new frmDone("How many guests can stay in this Apartment?"); frm.ShowDialog(); return(false); } if (txtBedNumber.TextLength == 0) { frmDone frm = new frmDone("Please Enter Number of bed"); frm.ShowDialog(); return(false); } if (txtSofaBedNumber.TextLength == 0) { frmDone frm = new frmDone("Number of sofa beds in the room"); frm.ShowDialog(); return(false); } if (txtApartmentNumber.TextLength == 0) { frmDone frm = new frmDone("Number of sofa beds in the room"); frm.ShowDialog(); return(false); } if (txtBedRoomNumber.TextLength == 0) { frmDone frm = new frmDone("Number of BedRoom in the Unit"); frm.ShowDialog(); return(false); } if (txtLivingRoomNumber.TextLength == 0) { frmDone frm = new frmDone("Number of LivingRoom in the Unit"); frm.ShowDialog(); return(false); } if (txtBathroomNumber.TextLength == 0) { frmDone frm = new frmDone("Number of Bathroom in the Unit"); frm.ShowDialog(); return(false); } if (txtPrivateBathRoomNumber.TextLength == 0) { frmDone frm = new frmDone("Number of PrivateBathRoom in the Unit"); frm.ShowDialog(); return(false); } return(true); }
public bool Update() { SqlConnection Connection = DBGate.GetConnection(); string Update = "update Reservations " + " Set " // + " FirstName = @FirstName " + " ,LastName =@LastName " + " ,Mobile =@Mobile " + " ,UniteName =@UniteName " // + " ,CheckIn =@CheckIn " + " ,CheckOut =@CheckOut " + " ,Bookedon =@Bookedon " + " ,Status =@Status " + " ,Days =@Days " // + " ,TotalPrice =@TotalPrice " + " ,Commission =@Commission " + " ,RoomNo =@RoomNo " // + " where " + " ID =@ID "; SqlCommand cmd = new SqlCommand(Update, Connection); cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@ID", ID); cmd.Parameters.AddWithValue("@FirstName", FirstName); cmd.Parameters.AddWithValue("@LastName", LastName); cmd.Parameters.AddWithValue("@Mobile", Mobile); cmd.Parameters.AddWithValue("@UniteName", UniteName); // cmd.Parameters.AddWithValue("@CheckIn", CheckIn); cmd.Parameters.AddWithValue("@CheckOut", CheckOut); cmd.Parameters.AddWithValue("@Bookedon", Bookedon); cmd.Parameters.AddWithValue("@Status", Status); cmd.Parameters.AddWithValue("@Days", Days); // cmd.Parameters.AddWithValue("@TotalPrice", TotalPrice); cmd.Parameters.AddWithValue("@Commission", Commission); cmd.Parameters.AddWithValue("@RoomNo", RoomNo); try { Connection.Open(); int count = cmd.ExecuteNonQuery(); if (count > 0) { return(true); } else { return(false); } } catch (SqlException ex) { frmDone frmerror = new frmDone(ex.ToString()); frmerror.ShowDialog(); return(false); } finally { Connection.Close(); } }
public bool Add() { SqlConnection Connection = DBGate.GetConnection(); string Add = "INSERT into " + " Reservations " + " ( " + " FirstName " + " ,LastName " + " ,Mobile " + " ,UniteName " // + " ,CheckIn " + " ,CheckOut " + " ,Bookedon " + " ,Status " + " ,Days " // + " ,TotalPrice " + " ,Commission " + " ,RoomNo " // + " ) " + "VALUES " + " ( " // + " @FirstName " + " ,@LastName " + " ,@Mobile " + " ,@UniteName " // + " ,@CheckIn " + " ,@CheckOut " + " ,@Bookedon " + " ,@Status " + " ,@Days " // + " ,@TotalPrice " + " ,@Commission " + " ,@RoomNo " + " ) " + ""; SqlCommand cmd = new SqlCommand(Add, Connection); cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@FirstName", FirstName); cmd.Parameters.AddWithValue("@LastName", LastName); cmd.Parameters.AddWithValue("@Mobile", Mobile); cmd.Parameters.AddWithValue("@UniteName", UniteName); // cmd.Parameters.AddWithValue("@CheckIn", CheckIn); cmd.Parameters.AddWithValue("@CheckOut", CheckOut); cmd.Parameters.AddWithValue("@Bookedon", Bookedon); cmd.Parameters.AddWithValue("@Status", Status); cmd.Parameters.AddWithValue("@Days", Days); // cmd.Parameters.AddWithValue("@TotalPrice", TotalPrice); cmd.Parameters.AddWithValue("@Commission", Commission); cmd.Parameters.AddWithValue("@RoomNo", RoomNo); try { Connection.Open(); int count = cmd.ExecuteNonQuery(); if (count > 0) { return(true); } else { return(false); } } catch (SqlException ex) { frmDone frmerror = new frmDone(ex.ToString()); frmerror.ShowDialog(); return(false); } finally { Connection.Close(); } }
public bool Update() { SqlConnection Connection = DBGate.GetConnection(); string Update = "update UniteDetails " + " Set " // + " UnittypeID = @UnittypeID " + " ,UniteName =@UniteName " + " ,SmokingPolicy =@SmokingPolicy " + " ,PoolPolicy =@PoolPolicy " + " ,Size =@Size " // + " ,ApartmentNumber =@ApartmentNumber " + " ,GustNumber =@GustNumber " + " ,BedRoomNumber =@BedRoomNumber " + " ,LivingRoomNumber =@LivingRoomNumber " + " ,BedKind =@BedKind " + " ,BedNumber =@BedNumber " + " ,SofaBedNumber =@SofaBedNumber " + " ,BathroomNumber =@BathroomNumber " + " ,PrivateBathRoomNumber =@PrivateBathRoomNumber " // + " where " + " ID =@ID "; SqlCommand cmd = new SqlCommand(Update, Connection); cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@ID", ID); cmd.Parameters.AddWithValue("@UnittypeID", UnittypeID); cmd.Parameters.AddWithValue("@UniteName", UniteName); cmd.Parameters.AddWithValue("@SmokingPolicy", SmokingPolicy); cmd.Parameters.AddWithValue("@PoolPolicy", PoolPolicy); cmd.Parameters.AddWithValue("@Size", Size); // cmd.Parameters.AddWithValue("@ApartmentNumber", ApartmentNumber); cmd.Parameters.AddWithValue("@GustNumber", GustNumber); cmd.Parameters.AddWithValue("@BedRoomNumber", BedRoomNumber); cmd.Parameters.AddWithValue("@LivingRoomNumber", LivingRoomNumber); cmd.Parameters.AddWithValue("@BedKind", BedKind); cmd.Parameters.AddWithValue("@BedNumber", BedNumber); cmd.Parameters.AddWithValue("@SofaBedNumber", SofaBedNumber); cmd.Parameters.AddWithValue("@BathroomNumber", BathroomNumber); cmd.Parameters.AddWithValue("@PrivateBathRoomNumber", PrivateBathRoomNumber); try { Connection.Open(); int count = cmd.ExecuteNonQuery(); if (count > 0) { return(true); } else { return(false); } } catch (SqlException ex) { frmDone frmerror = new frmDone(ex.ToString()); frmerror.ShowDialog(); return(false); } finally { Connection.Close(); } }
public bool Add() { SqlConnection Connection = DBGate.GetConnection(); string Add = "INSERT into " + " UniteDetails " + " ( " + " UnittypeID " + " ,UniteName " + " ,SmokingPolicy " + " ,PoolPolicy " + " ,Size " // + " ,ApartmentNumber " + " ,GustNumber " + " ,BedRoomNumber " + " ,LivingRoomNumber " + " ,BedKind " + " ,BedNumber " + " ,SofaBedNumber " + " ,BathroomNumber " + " ,PrivateBathRoomNumber " // + " ) " + "VALUES " + " ( " // + " @UnittypeID " + " ,@UniteName " + " ,@SmokingPolicy " + " ,@PoolPolicy " + " ,@Size " // + " ,@ApartmentNumber " + " ,@GustNumber " + " ,@BedRoomNumber " + " ,@LivingRoomNumber " + " ,@BedKind " + " ,@BedNumber " + " ,@SofaBedNumber " + " ,@BathroomNumber " + " ,@PrivateBathRoomNumber " + " ) " + ""; SqlCommand cmd = new SqlCommand(Add, Connection); cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@UnittypeID", UnittypeID); cmd.Parameters.AddWithValue("@UniteName", UniteName); cmd.Parameters.AddWithValue("@SmokingPolicy", SmokingPolicy); cmd.Parameters.AddWithValue("@PoolPolicy", PoolPolicy); cmd.Parameters.AddWithValue("@Size", Size); // cmd.Parameters.AddWithValue("@ApartmentNumber", ApartmentNumber); cmd.Parameters.AddWithValue("@GustNumber", GustNumber); cmd.Parameters.AddWithValue("@BedRoomNumber", BedRoomNumber); cmd.Parameters.AddWithValue("@LivingRoomNumber", LivingRoomNumber); cmd.Parameters.AddWithValue("@BedKind", BedKind); cmd.Parameters.AddWithValue("@BedNumber", BedNumber); cmd.Parameters.AddWithValue("@SofaBedNumber", SofaBedNumber); cmd.Parameters.AddWithValue("@BathroomNumber", BathroomNumber); cmd.Parameters.AddWithValue("@PrivateBathRoomNumber", PrivateBathRoomNumber); try { Connection.Open(); int count = cmd.ExecuteNonQuery(); if (count > 0) { return(true); } else { return(false); } } catch (SqlException ex) { frmDone frmerror = new frmDone(ex.ToString()); frmerror.ShowDialog(); return(true); } finally { Connection.Close(); } }