public static OverDue CalculateOverDueRate(DateTime CheckOutTime, long ReservationID, HotelBookingCalculate msg, HotelBookingObject hObject) { bool isWeekend = DateIsWeekend(CheckOutTime); string query = string.Format("Select {0} from CheckTime as a, RoomOverDueRate as b where a.ReservationID = @ReservationID and a.RoomTypeID = b.RoomTypeID", isWeekend ? "b.WeekendRate" : "b.WeekDayRate"); SQLClient sqlclient = new SQLClient(); double overDueRate = sqlclient.GetOverDueRate(query, ReservationID); DateTime expectedCheckIn = Convert.ToDateTime(hObject.ExpectedCheckInTime); DateTime expectedCheckOut = Convert.ToDateTime(hObject.ExpectedCheckOutTime); double expectedHours = expectedCheckOut.Subtract(expectedCheckIn).TotalHours; bool hoursStretched = ExpectedHoursStretched(expectedHours); int calculatedHours = Convert.ToInt32(Math.Ceiling(expectedHours)); WriteToFile(string.Format("Calculated Hours for ReservationID {0}: {1}", ReservationID, calculatedHours)); double initialAmount = Convert.ToDouble(hObject.HourlyRate) * calculatedHours; double overDueAmount = GetOverDueAmount(CheckOutTime, expectedCheckOut, hoursStretched, overDueRate, Convert.ToDouble(hObject.HourlyRate)); double totalAmount = initialAmount + overDueAmount; OverDue overdue = new OverDue { InitialAmount = initialAmount, OverDueAmount = overDueAmount, TotalAmount = totalAmount, WeekendRate = isWeekend }; return(overdue); }
public AddClassificationWindow(SQLClient client) : this() { _SQLClient = client; SelectClassificationTypes(); SelectConcepts(); }
public static Dictionary <string, object> InsertHotelBooking(HotelBookingSave msg) { try { SQLClient sqlClient = new SQLClient(); string query = "insert into CheckTime (RoomTypeID, CustomerID, [Status], ExpectedCheckIn, ExpectedCheckOut) values (@RoomTypeID, @CustomerID, @Status, @ExpectedCheckIn, @ExpectedCheckOut)"; // Save the Booking in the Hotel List <HotelBookingObject> hObjects = sqlClient.SaveHotelBooking(query, msg); HotelBookingObject hObject = hObjects[0]; if (string.IsNullOrEmpty(hObject.Error)) { return(DeserializeToDictionary(JsonConvert.SerializeObject(hObject))); } else { Error err = new Error(); err.ErrorMessage = hObject.Error; return(DeserializeToDictionary(JsonConvert.SerializeObject(err))); } } catch (Exception ex) { WriteToFile(string.Format("{0}, {1}, {2}", ex.Message, ex.InnerException, ex.StackTrace)); return(DeserializeToDictionary(string.Format(ex.ToString()))); } }
public Sources(SQLClient client) : this() { _SQLClient = client; DataTables.SourcesDataTable = new System.Data.DataTable(); SelectSources(); }
public AddDefinitionWindow(SQLClient client) : this() { _SQLClient = client; SelectClassifications(); SelectSources(); }
private TaskItemRepository CreateSUT() { var connectionString = ConfigurationManager.ConnectionStrings["TaskManager"].ConnectionString; var sqlClient = new SQLClient(connectionString); var sut = new TaskItemRepository(sqlClient); return(sut); }
public FluDataCreate() { this.hqmsUrl = OperateIniFile.read("FILESAVEPATH", "hqms", ""); this.fluUrl = OperateIniFile.read("FILESAVEPATH", "flu", ""); this.backUpUrl = OperateIniFile.read("FILESAVEPATH", "backUp", ""); sqlClient = new SQLClient(); log = Logger.Instance; }
public AddClassificationToConceptWindow(SQLClient client, int selectedClassificationId) : this(client) { _SelectedClassificationId = selectedClassificationId; ClassificationsComboBox.SelectedIndex = ClassificationsComboBox .Items.OfType <string>().ToList() .FindIndex(item => int.Parse(item.Split('.').First()) == _SelectedClassificationId); }
public AddClassificationToConceptWindow(SQLClient client, int selectedClassificationId, int selectedParentConceptId) : this(client, selectedClassificationId) { ParentConceptComboBox.SelectedIndex = ParentConceptComboBox .Items.OfType <string>().ToList() .FindIndex(item => item == _conceptsInClassification .First(c => c.Key == selectedParentConceptId) .Value); }
//---------------------------------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Recupere DataTable avec tous les documents /// </summary> /// <returns></returns> private static DataTable GetDTDocuments() { String sqlQuery = "SELECT " + "* " + "FROM " + "document"; return(SQLClient.GetDataTable(_connectionString, sqlQuery)); }
public Properties(SQLClient client) : this() { _SQLClient = client; DataTables.PropertiesDataTable = new DataTable(); RefreshDataGrid(); DataTables.PropertyArousedConceptsDataTable = new DataTable(); }
public ChangeClassificationWindow(SQLClient sqlClient, int classificationId) { InitializeComponent(); _sqlClient = sqlClient; SelectClassification(classificationId); SelectClassificationTypes(); }
public Classifications(SQLClient client) : this() { _sqlClient = client; DataTables.ClassificationsDataTable = new DataTable(); SelectClassifications(); DataTables.ClassificationConceptsDataTable = new DataTable(); }
//---------------------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Recupere DataTable de tous les auteurs /// </summary> /// <returns></returns> private static DataTable GetDTAuteurs() { String sqlQuery = "SELECT " + "* " + "FROM " + "auteur"; return(SQLClient.GetDataTable(_connectionString, sqlQuery)); }
public Definitions(SQLClient client) : this() { _SQLClient = client; DataTables.DefinitiosDataTable = new System.Data.DataTable(); DefinitionsDataGrid.ItemsSource = DataTables.DefinitiosDataTable?.DefaultView; SelectClassifications(); }
//-------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Recupere une DataTable de toutes les relances /// </summary> /// <returns></returns> private static DataTable GetDTRelances() { String sqlQuery = "SELECT " + "* " + "FROM " + "relance"; return(SQLClient.GetDataTable(_connectionString, sqlQuery)); }
public ChangeConceptWindow(SQLClient sqlClient, int conceptId) { InitializeComponent(); _sqlClient = sqlClient; SelectConcept(conceptId); ConceptNameTextBox.Text = _concept.Name; }
public AddPropertyToConceptWindow(SQLClient client, int conceptId, TreeVisualizationPage page) : this(client) { SenderPage = page; ConceptsComboBox.SelectedIndex = _concepts .First(c => c.Key == conceptId) .Value; SelectProperties(conceptId); }
//---------------------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Recupere DataRow d'un lecteur /// </summary> /// <returns></returns> private static DataRow GetDRAuteur(Int32 idAuteur) { String sqlQuery = "SELECT " + "* " + "FROM " + "auteur " + "WHERE " + "id_auteur = " + idAuteur; return(SQLClient.GetUniqueDataRow(_connectionString, sqlQuery)); }
public MainWindow() { InitializeComponent(); Instance = this; _SQLClient = new SQLClient(); InitPages(); MainFrame.NavigationService.Navigate(_ClassificationPage); }
//---------------------------------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Recupere un DataTable des documents avec un idTitre /// </summary> /// <param name="idTitre">Id du titre</param> /// <returns></returns> private static DataTable GetDTDocuments_idTitre(Int32 idTitre) { String sqlQuery = "SELECT " + "* " + "FROM " + "document " + "WHERE " + "id_document = " + idTitre; return(SQLClient.GetDataTable(_connectionString, sqlQuery)); }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------- /// <summary> /// Recupere DataRow avec un ID Genre /// </summary> /// <param name="idGenre">ID du genre</param> /// <returns></returns> private static DataRow GetDRGenre(Int32 idGenre) { String sqlQuery = "SELECT " + "* " + "FROM " + "genre " + "WHERE " + "id_genre = " + idGenre; return(SQLClient.GetUniqueDataRow(_connectionSring, sqlQuery)); }
//----------------------------------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Recuperation d'une DataRow avec les données d'une relance /// </summary> /// <param name="idRelance">ID de la relance</param> /// <returns></returns> private static DataRow GetDRRelance(Int32 idRelance) { String sqlQuery = "SELECT " + "* " + "FROM " + "relance " + "WHERE " + "idRelance = " + idRelance; return(SQLClient.GetUniqueDataRow(_connectionString, sqlQuery)); }
public Concepts(SQLClient client) : this() { _SQLClient = client; DataTables.ConceptsDataTable = new DataTable(); SelectConcepts(); DataTables.ConceptChildsDataTable = new DataTable(); ConceptChildsDataGrid.ItemsSource = DataTables.ConceptChildsDataTable?.DefaultView; SelectClassifications(); }
public async Task SQLClient_GetComplex() { var connectionString = ConfigurationManager.ConnectionStrings["TaskManager"].ConnectionString; var csb = new DbConnectionStringBuilder(); csb.ConnectionString = connectionString; csb["database"] = "SQLClientTest"; var sut = new SQLClient(csb.ConnectionString); var entity = await sut.RunSpReturnGraph <TestComplexEntity, TestSimpleEntity, TestComplexEntity>("spGetTestComplexEntities", (complex, simple) => { complex.Parent = simple; return(complex); }, "TestSimpleEntityID"); }
public async Task SQLClient_GetEntityList() { var connectionString = ConfigurationManager.ConnectionStrings["TaskManager"].ConnectionString; var csb = new DbConnectionStringBuilder(); csb.ConnectionString = connectionString; csb["database"] = "SQLClientTest"; var sut = new SQLClient(csb.ConnectionString); var list = await sut.RunSpReturnGraph <TestSimpleEntity>("spGetTestSimpleEntityList"); Assert.NotNull(list); Assert.True(list.Count() > 0); }
public ChangeDefinitionWindow(SQLClient client, int selectedClassificationId, int selectedConceptId, string definition) : this(client) { _SelectedClassificationId = selectedClassificationId; _SelectedConceptId = selectedConceptId; _Definition = definition; /* * FindClassConcept(); * FindClassification(); * FindConcept(); * SelectSources(); * FindDefinition(); */ }
public static object ListHotelBooking() { try { // Fetch all Bookings in the Hotel SQLClient sqlClient = new SQLClient(); string query = "select a.ReservationID, b.RoomTypeName, a.CustomerID, b.HourlyRate, a.Status, a.ExpectedCheckIn, a.ExpectedCheckOut from CheckTime as a, RoomTypes as b where a.RoomTypeID = b.RoomTypeID"; List <HotelBookingObject> hObjects = sqlClient.FetchHotelBooking(query); WriteToFile("List of Fetched Bookings: " + JsonConvert.SerializeObject(hObjects)); return(DeserializeToDictionaryOrList(JsonConvert.SerializeObject(hObjects))); } catch (Exception ex) { WriteToFile(string.Format("{0}, {1}, {2}", ex.Message, ex.InnerException, ex.StackTrace)); return(DeserializeToDictionaryOrList(string.Format(ex.ToString()))); } }
public ChangeClassConceptWindow(SQLClient sqlClient, int classificationId, int conceptId) { InitializeComponent(); _sqlClient = sqlClient; _conceptId = conceptId; _classificationId = classificationId; SelectConcept(conceptId); ConceptNameTextBox.Text = _concept.Name.Trim(); SpecDifferenceNameTextBox.Text = _sqlClient.FindClassConcept(classificationId, conceptId) .Field <string>("SpecDifference") .Trim(); }
private static void InsertSql(object sender, System.Timers.ElapsedEventArgs e) { SqlInsertTimer.Enabled = false; SQLClient sqlclnt = new SQLClient(sLogFilePath); DataTable dtItems = new DataTable("OPCItems"); dtItems.Columns.AddRange(new DataColumn[] { new DataColumn("ItemID"), new DataColumn("ItemValue"), new DataColumn("ItemQualitie"), new DataColumn("ItemTimeStamp"), new DataColumn("UpdateTime"), }); sqlclnt.sConnectStr = sSqlStr; bool bsqlcnt = sqlclnt.ConnectSql(); if (bsqlcnt == true) { DateTime UpdataTime = DateTime.Now; for (int i = 0; i < opcKepClient.lKepItem.Count; i++) { string ItemID = opcKepClient.lKepItem[i].ItemID; var ItemValue = opcKepClient.lKepItem[i].Value; int? ItemQuality = opcKepClient.lKepItem[i].Quality; DateTime?ItemTimeStamp = opcKepClient.lKepItem[i].TimeStamp.AddHours(8); DataRow drItem = dtItems.NewRow(); drItem[0] = opcKepClient.lKepItem[i].ItemID; drItem[1] = opcKepClient.lKepItem[i].Value; drItem[2] = opcKepClient.lKepItem[i].Quality; drItem[3] = opcKepClient.lKepItem[i].TimeStamp.AddHours(8); drItem[4] = DateTime.Now; dtItems.Rows.Add(drItem); } } int iUpdateRows; string sqldelet = string.Format("delete from {0} where 1=1 ", "Runtimes"); sqlclnt.sqlExecuteNonQuery(sqldelet, out iUpdateRows, CommandType.Text); sqlclnt.sqlBulkCopyData("Runtimes", dtItems); sqlclnt.SqlClose(); SqlInsertTimer.Enabled = true; }