private void LoadDefaultsFromDatabase() { string sql = "select * from Defaults"; DefaultsModel model = SqliteDataAccess.LoadData <DefaultsModel>(sql, new Dictionary <string, object>()).FirstOrDefault(); if (model != null) { hourlyRateTextbox.Text = model.HourlyRate.ToString(); preBillCheckbox.IsChecked = (model.HourlyRate > 0); hasCutOffCheckbox.IsChecked = (model.HasCutOff > 0); cutoffTextbox.Text = model.CutOff.ToString(); minimumHoursTextbox.Text = model.MinimumHours.ToString(); billingIncrementTextbox.Text = model.BillingIncrement.ToString(); roundUpAfterXMinuteTextbox.Text = model.RoundUpAfterXMinutes.ToString(); } else { hourlyRateTextbox.Text = "0"; preBillCheckbox.IsChecked = true; hasCutOffCheckbox.IsChecked = false; cutoffTextbox.Text = "0"; minimumHoursTextbox.Text = "0.25"; billingIncrementTextbox.Text = "0.25"; roundUpAfterXMinuteTextbox.Text = "0"; } }
public void InsertDefaultsData(DefaultsModel parameters) { var sqlString = "insert into Defaults (HourlyRate, PreBill, HasCutOff, CutOff, MinimumHours, BillingIncrement, RoundUpAfterXMinutes) " + "values (@HourlyRate, @PreBill, @HasCutOff, @CutOff, @MinimumHours, @BillingIncrement, @RoundUpAfterXMinutes)"; var sql = new SqlDataAccess(); sql.SaveData(sqlString, parameters, _connectionString); }
public static void SaveDefaults(int stackSize, int graphMin, int graphMax) { DefaultsModel defaults = new DefaultsModel(stackSize, graphMin, graphMax); using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) { cnn.Execute("insert or replace into Defaults (Id, StackSize, GraphMin, GraphMax) values (@Id, @StackSize, @GraphMin, @GraphMax)", defaults); } }
public async Task <IActionResult> SaveDefaults([FromBody] DefaultsModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await WorkerServices.SaveSettingsDefaults(model); return(Ok()); }
public AdminSettings() { InitializeComponent(); txtCompany.Text = SqliteDataAccess.LoadCompanyName(); defaults = SqliteDataAccess.LoadDefaults(); numGraphMin.Value = defaults.GraphMin; numGraphMax.Value = defaults.GraphMax; numStackSize.Value = defaults.StackSize; }
public async Task SaveSettingsDefaults(DefaultsModel model) { var subscriptionId = Guid.Empty; await Commands.SaveSettingsDefaults( subscriptionId, model.MinimumTaxpayerRegime, model.ElectronicInvoiceEnabled, model.SplitPayment, model.VatRate?.Id, model.ProvidenceFund?.Id, model.WithholdingTax?.Id); }
private DefaultsModel PopulateDefaultsModel() { var output = new DefaultsModel { PreBill = PreBill ? 1 : 0, HasCutOff = HasCutOff ? 1 : 0, HourlyRate = double.Parse(HourlyRate), CutOff = int.Parse(CutOff), MinimumHours = double.Parse(MinimumHours), BillingIncrement = double.Parse(BillingIncrement), RoundUpAfterXMinutes = int.Parse(RoundUpAfterXMinutes) }; return(output); }
public void DisplayData() { devices = SqliteDataAccess.LoadDevices(); probes = SqliteDataAccess.LoadProbes(); defaults = SqliteDataAccess.LoadDefaults(); lblCompany.Text = SqliteDataAccess.LoadCompanyName(); ArrangeTempDisplays(); // Device Settings for (int i = 0; i < devices.Count; i++) { tabTemperature.TabPages[i].Text = devices[i].Name; lblGraphs[i].Text = devices[i].Name; btnShowGraphics[i].Enabled = devices[i].Active; // If device is active, enable graphic button; else disable it. } // Probe Settings for (int i = 0; i < probes.Count; i++) { groupBoxes[i].Text = probes[i].Name; numMins[i].Value = probes[i].Min; numMaxs[i].Value = probes[i].Max; numMarkers[i].Value = probes[i].Marker; //tempDisplays[i].Font = font; if (probes[i].Active) { if (measurementStacks[i] == null) { measurementStacks[i] = new Stack <MeasurementModel>(30); } groupBoxes[i].Enabled = true; } else { groupBoxes[i].Enabled = false; } } // Graph Defaults numMinGraph.Value = defaults.GraphMin; numMaxGraph.Value = defaults.GraphMax; stackSize = defaults.StackSize; timer2.Interval = stackSize * 1000; }
public DefaultsModel GetSettingsDefaults() { var subscriptionId = Guid.Empty; var model = new DefaultsModel(); var defaults = Database.SettingsDefaults .BySubscriptionId(subscriptionId) .Include(s => s.Vat) .Include(s => s.WithholdingTax) .Include(s => s.ProvidenceFund) .SingleOrDefault(); if (defaults != null) { var vat = defaults.Vat; var providenceFund = defaults.ProvidenceFund; var withholdingTax = defaults.WithholdingTax; model.ElectronicInvoiceEnabled = defaults.ElectronicInvoiceEnabled; model.MinimumTaxpayerRegime = defaults.MinimumTaxPayerRegime; model.SplitPayment = defaults.SplitPaymentApplied; model.VatRate = vat == null ? null : new DefaultsModel.VatRateDescriptor { Id = vat.Id, Rate = vat.Rate }; model.ProvidenceFund = providenceFund == null ? null : new DefaultsModel.ProvidenceFundDescriptor { Id = providenceFund.Id, Description = providenceFund.Description, Rate = providenceFund.Rate, AppliedInWithholdingTax = providenceFund.AppliedInWithholdingTax }; model.WithholdingTax = withholdingTax == null ? null : new DefaultsModel.WithholdingTaxDescriptor { Id = withholdingTax.Id, Description = withholdingTax.Description, Rate = withholdingTax.Rate, TaxableAmountRate = withholdingTax.TaxableAmountRate }; } return(model); }
private void SaveToDatabase(DefaultsModel model) { string sql = "delete from Defaults"; SqliteDataAccess.SaveData(sql, new Dictionary <string, object>()); sql = "insert into Defaults (HourlyRate, PreBill, HasCutOff, CutOff, MinimumHours, BillingIncrement, RoundUpAfterXMinutes) " + "values (@HourlyRate, @PreBill, @HasCutOff, @CutOff, @MinimumHours, @BillingIncrement, @RoundUpAfterXMinutes)"; Dictionary <string, object> parameters = new Dictionary <string, object> { { "@HourlyRate", model.HourlyRate }, { "@PreBill", model.PreBill }, { "@HasCutOff", model.HasCutOff }, { "@CutOff", model.CutOff }, { "@MinimumHours", model.MinimumHours }, { "@BillingIncrement", model.BillingIncrement }, { "@RoundUpAfterXMinutes", model.RoundUpAfterXMinutes }, }; SqliteDataAccess.SaveData(sql, parameters); }
private (bool isValid, DefaultsModel model) ValidateForm() { bool isValid = true; DefaultsModel model = new DefaultsModel(); try { model.PreBill = (bool)preBillCheckbox.IsChecked ? 1 : 0; model.HasCutOff = (bool)hasCutOffCheckbox.IsChecked ? 1: 0; model.HourlyRate = double.Parse(hourlyRateTextbox.Text); model.CutOff = int.Parse(cutoffTextbox.Text); model.MinimumHours = double.Parse(minimumHoursTextbox.Text); model.BillingIncrement = double.Parse(billingIncrementTextbox.Text); model.RoundUpAfterXMinutes = int.Parse(roundUpAfterXMinuteTextbox.Text); } catch { isValid = false; } return(isValid, model); }
private void UpdateDatabase(DefaultsModel model) { _data.DeleteDefaultsData(); _data.InsertDefaultsData(model); }