public int CheckAvabilityAndInsert(Reservation partyReservation) { int reservationId = 0; bool check = CheckAvabilityByDateAndArea(partyReservation); if(check) { try { this.OpenConnection(); string sqlCommand = string.Format(SqlQueries.GetQuery(Query.Insertreservation),partyReservation.PartyDate,partyReservation.FromTime,partyReservation.ToTime,partyReservation.BookingArea ); this.ExecuteNonQuery(sqlCommand); sqlCommand = SqlQueries.GetQuery(Query.ScopeIdentity); IDataReader oReader = this.ExecuteReader(sqlCommand); if (oReader != null) { bool bIsRead = oReader.Read(); if (bIsRead) { try { reservationId = Int32.Parse(oReader[0].ToString()); } catch (Exception) { } } oReader.Close(); } } catch (Exception ex) { return reservationId; } finally { this.CloseConnection(); } } return reservationId; }
private void PrintDocumentForPOS(Reservation partyReservation, string sr) { //int printlenght = oItemList.Count + 30; printReportLogoType = 2; PrintDocument doc = new TextDocument(PrintReportForPOS(), 50); doc.PrintPage += this.Doc_PrintPage; doc.DefaultPageSettings.Landscape = true; PrintDialog dlgSettings = new PrintDialog(); dlgSettings.Document = doc; dlgSettings.UseEXDialog = true; if (dlgSettings.ShowDialog() == DialogResult.OK) { if (sr == "Confirm") { for (int i = 0; i < 3; i++) { doc.Print(); } } else { doc.Print(); } } }
private bool CheckAvabilityByDateAndArea(Reservation partyReservation) { List<string> fromtimes = new List<string>(); List<string> totimes = new List<string>(); try { this.OpenConnection(); string sqlCommand = string.Format(SqlQueries.GetQuery(Query.CheckAvabilityByDateAndArea), partyReservation.PartyDate,partyReservation.BookingArea); IDataReader oReader = this.ExecuteReader(sqlCommand); if (oReader != null) { while (oReader.Read()) { string fromtime = oReader["fromtime"].ToString(); string totime = oReader["totime"].ToString(); fromtimes.Add(fromtime); totimes.Add(totime); } } } catch (Exception ex) { } finally { this.CloseConnection(); } int fromminute = Getminute(partyReservation.FromTime); int tominute = Getminute(partyReservation.ToTime); if (fromtimes.Count == 0) return true; else { bool flag = true; for(int i=0;i<fromtimes.Count;i++) { int from = Getminute(fromtimes[i]); int to= Getminute(totimes[i]); if((from<fromminute && to< fromminute )||(from>fromminute && to>tominute)) { } else { flag = false; } } return flag; } }
public string UpdatePartyReservation(Reservation partyReservation) { string result = ""; try { this.OpenConnection(); string sqlCommand = string.Format(SqlQueries.GetQuery(Query.UpdatePartyReservation),partyReservation.ReservationId,partyReservation.BookingDate, partyReservation.LoginPerson,partyReservation.BookingArea,partyReservation.BookingType,partyReservation.NumberOfGuest,partyReservation.NumberofOtherGuest, partyReservation.MainGuestAmount,partyReservation.OtherGuestAmount,partyReservation.UtilityCostAmount,partyReservation.TotalPayableAmount,partyReservation.DepositeAmount, partyReservation.DueAmount,partyReservation.SpecialInstruction,partyReservation.ClientName,partyReservation.ClientPhone,partyReservation.ClientEmail, partyReservation.ServiceCharge,partyReservation.Vat,partyReservation.Discount,partyReservation.PrintPreview); this.ExecuteNonQuery(sqlCommand); result = "Reservation Update Sucessfully"; } catch (Exception ex) { result = "Couldn't Update sucessfully"; } finally { this.CloseConnection(); } return result; }