public bool AddNew() { if (Save()) { if (_record != null) { _priorRecord = _record; } _record = new TRecord(); _suspend = true; foreach (var action in _setDefaults) { action.SetControl.Invoke(); if (action.InvokeSetProperty) { action.SetProperty.Invoke(_record); } } NewRecord?.Invoke(this, new EventArgs()); FirstControl?.Focus(); ValidationPanel?.SetStatus(RecordStatus.Valid, "New record started"); ToolStrip?.OnNew(); _suspend = false; return(true); } return(false); }
public async Task Add(NewRecord record) { await _validator.RecordIsNotInStore(record.Id); CreateArtistAndLabelProfiles(record); await AddRecordToStore(record); }
public bool Execute(Add args) { var res = new NewRecord(); if (string.IsNullOrEmpty(args.Municipality) || string.IsNullOrEmpty(args.Municipality.Trim())) { throw new MunicipalityEmptyException("Municipality name cannot be empty!"); } res.Municipality = args.Municipality; if (args.TaxRate < 0) { throw new TexRateBelow0Exception("Tax rate cannot be below 0!"); } res.TaxRate = args.TaxRate; if (string.IsNullOrEmpty(args.TaxType) || string.IsNullOrEmpty(args.TaxType.Trim())) { throw new TaxTypeEmptyException("Tax type cannot be empty!"); } switch (args.TaxType.ToLower()) { case "yearly": res.TaxType = TaxScheduleType.Yearly; break; case "monthly": res.TaxType = TaxScheduleType.Monthly; break; case "weekly": res.TaxType = TaxScheduleType.Weekly; break; case "daily": res.TaxType = TaxScheduleType.Daily; break; default: throw new TaxTypeNotFoundException("Tax type is not supported. Please check tax type again!"); } if (string.IsNullOrEmpty(args.StartDate) || string.IsNullOrEmpty(args.StartDate.Trim())) { throw new TaxRateStartDateEmptyException("Tax rate date cannot be empty!"); } try { res.StartDate = Convert.ToDateTime(args.StartDate); } catch (FormatException) { throw new TaxRateStartDateInvalidFormatException("Tax rate date was not recognised as valid date format"); } NewRecordRequested?.Invoke(res); return(true); }
private void ListViewMenu_SelectionChanged(object sender, SelectionChangedEventArgs e) { switch (((ListViewItem)((ListView)sender).SelectedItem).Name) { case "ItemHome": MenuScreen menu = new MenuScreen(arr); menu.Show(); this.Close(); break; case "AddRec": NewRecord nR = new NewRecord(arr); nR.Show(); nR.WindowState = WindowState.Maximized; this.Close(); break; case "GitHub": System.Diagnostics.Process.Start("https://github.com/CIMDBORG/CIMMigrationProject/issues"); break; default: break; } }
private async Task AddRecordToStore(NewRecord record) { await _db.Records.Add(record); await _db.Stocks.Add(record.Id, record.Quantity); await _db.SaveChanges(); }
/// <summary> /// Объявить рекорд или объявить GameOver. /// </summary> private void SetGameOver() { if (_state.CheckNewRecord(_gamePoinst)) { NewRecord?.Invoke(); } else { GameOver?.Invoke(); } }
public void AddTaxRate(NewRecord entry) { if (!TaxRates.MunicipalitiesAndTheirRates.ContainsKey(entry.Municipality)) { TaxRates.MunicipalitiesAndTheirRates[entry.Municipality] = new List <MunicipalityTaxRate>(); } TaxRates.MunicipalitiesAndTheirRates[entry.Municipality].Add(new MunicipalityTaxRate() { ScheduleType = entry.TaxType, StartDate = entry.StartDate, TaxRate = entry.TaxRate }); SaveDataToFile(); }
public void Execute_ValidArguments_ExpectValidModel() { var command = new AddCommand(Substitute.For <IProgramLogger>()); NewRecord res = null; command.NewRecordRequested += (NewRecord rec) => res = rec; Assert.IsTrue(command.Execute( new Municipalities.Cmd.Options.Add() { Municipality = "something", TaxRate = 100, TaxType = "DAILY", StartDate = "2019-05-06" })); Assert.AreEqual("something", res.Municipality); Assert.AreEqual(100, res.TaxRate); Assert.AreEqual(TaxScheduleType.Daily, res.TaxType); Assert.AreEqual(Convert.ToDateTime("2019-05-06"), res.StartDate); }
void OnEndGameClicked(object _, EventArgs e) { var bestResult = GameManager.Instance.PlayerResults[0]; GameManager.Instance.PlayerResults.ForEach(result => { if (result.Score > bestResult.Score) { bestResult = result; } }); if (bestResult.Score == 0) { WillNotRecord?.Invoke(null, null); return; } for (int i = 0; i < Records.List.Count; i++) { if (bestResult.Score > Records.List[i].Score) { NewRecord?.Invoke(null, new RecordEventArgs() { Position = i, Result = bestResult }); return; } } if (Records.List.Count < 10) { NewRecord?.Invoke(null, new RecordEventArgs() { Position = Records.List.Count == 0 ? 1 : Records.List.Count - 1, Result = bestResult }); return; } WillNotRecord?.Invoke(null, null); }
private void addStockRecordbtn_Click(object sender, EventArgs e) { try { NewRecord newRecord = new NewRecord(); newRecord.ShowDialog(); if (isChanged) { InformationForm information = new InformationForm("New stock record is added.", "Info"); information.Show(); } } catch (Exception) { MessageBox.Show("Something wrong!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.ViewStocks_Load(sender, e); } }
public void AddRecord(Call newCall) { int lastIndex = ListOfCalls.Count - 1; if (lastIndex < 0) { ListOfCalls.Add(newCall); } else { Call lastCall = ListOfCalls[lastIndex]; if (lastCall.Equals(newCall)) { var combinedCall = lastCall as CombinedCall; if (combinedCall != null) { combinedCall.LastCallTime = newCall.CallTime; combinedCall.NumberOfCalls++; } else { combinedCall = new CombinedCall(lastCall); combinedCall.NumberOfCalls = 2; combinedCall.LastCallTime = newCall.CallTime; ListOfCalls[lastIndex] = combinedCall; } } else { ListOfCalls.Add(newCall); } } lastIndex = ListOfCalls.Count - 1; ListOfCalls[lastIndex].FormTextRepOfCaller(); NewRecord?.Invoke(); }
public void FillSpread() { //Fill Spread with new days Exceptions DbCommand oCmd = UpgradeHelpers.DB.AdoFactoryManager.GetFactory().CreateCommand(); string CurrDate = ""; string CurrRecord = ""; StringBuilder NewRecord = new System.Text.StringBuilder(); string CurrEmp = ""; string CurrPos = ""; string CurrKOT = ""; string CurrLeave = ""; int CurrPayUp = 0; string CurrJobCode = ""; string strAMPM = ""; ClearSpread(); string StartDate = DateTime.Parse(ViewModel.calWeek.Text).ToString("M/d/yyyy"); string EndDate = DateTime.Parse(StartDate).AddDays(14).ToString("M/d/yyyy"); ViewModel.sprWeek.Col = 5; ViewModel.sprWeek.Row = 2; ViewModel.sprWeek.Text = StartDate; ViewModel.sprWeek.Col = 7; ViewModel.sprWeek.Text = EndDate; int CurrRow = 4; oCmd.Connection = modGlobal.oConn; oCmd.CommandType = CommandType.Text; oCmd.CommandText = "spReport_TimeSheetX '" + StartDate + "','" + EndDate + "','" + modGlobal.Shared.gRType + "'"; ADORecordSetHelper oRec = ADORecordSetHelper.Open(oCmd, ""); if (!oRec.EOF) { CurrPos = Convert.ToString(oRec["unit_code"]).Trim() + "-" + Convert.ToString(oRec["position_code"]).Trim(); NewRecord = new System.Text.StringBuilder(Convert.ToString(oRec["name_full"]).Trim() + CurrPos + modGlobal.Clean(oRec["work_time"])); //UPGRADE_WARNING: (1049) Use of Null/IsNull() detected. More Information: http://www.vbtonet.com/ewis/ewi1049.aspx if (!Convert.IsDBNull(oRec["leave_time"])) { NewRecord.Append(modGlobal.Clean(oRec["leave_time"])); } if (Convert.ToBoolean(oRec["pay_upgrade"])) { NewRecord.Append(Convert.ToString(oRec["job_code_id"])); } } while (!oRec.EOF) { if (CurrDate != Convert.ToString(oRec["shift_date"])) { CurrRow++; ViewModel.sprWeek.Row = CurrRow; ViewModel.sprWeek.Col = 1; ViewModel.sprWeek.Text = Convert.ToString(oRec["shift_date"]); CurrDate = Convert.ToString(oRec["shift_date"]); CurrRecord = ""; } if (CurrRecord != NewRecord.ToString()) { ViewModel.sprWeek.Row = CurrRow; ViewModel.sprWeek.Col = 3; ViewModel.sprWeek.Text = Convert.ToString(oRec["name_full"]); ViewModel.sprWeek.Col = 2; CurrPos = Convert.ToString(oRec["unit_code"]).Trim() + "-" + Convert.ToString(oRec["position_code"]).Trim(); ViewModel.sprWeek.Text = CurrPos; ViewModel.sprWeek.Col = 4; ViewModel.sprWeek.Text = modGlobal.Clean(oRec["work_time"]); //UPGRADE_WARNING: (1049) Use of Null/IsNull() detected. More Information: http://www.vbtonet.com/ewis/ewi1049.aspx if (!Convert.IsDBNull(oRec["leave_time"])) { ViewModel.sprWeek.Col = 5; ViewModel.sprWeek.Text = modGlobal.Clean(oRec["leave_time"]); if (UpgradeHelpers.Helpers.StringsHelper.ToDoubleSafe(modGlobal.Clean(oRec["vacation_bank_flag"])) == 1) { ViewModel.sprWeek.FontBold = true; } } if (Convert.ToBoolean(oRec["pay_upgrade"])) { ViewModel.sprWeek.Col = 6; ViewModel.sprWeek.Text = "X"; ViewModel.sprWeek.Col = 7; ViewModel.sprWeek.Text = Convert.ToString(oRec["job_code_id"]); ViewModel.sprWeek.Col = 8; ViewModel.sprWeek.Text = modGlobal.Clean(oRec["step"]); } ViewModel.sprWeek.Col = 9; ViewModel.sprWeek.Text = Convert.ToString(oRec["AMPM"]); CurrEmp = Convert.ToString(oRec["name_full"]); CurrKOT = modGlobal.Clean(oRec["work_time"]); //UPGRADE_WARNING: (1049) Use of Null/IsNull() detected. More Information: http://www.vbtonet.com/ewis/ewi1049.aspx if (!Convert.IsDBNull(oRec["leave_time"])) { CurrLeave = modGlobal.Clean(oRec["leave_time"]); } else { CurrLeave = ""; } CurrPayUp = Convert.ToInt32(oRec["pay_upgrade"]); if (CurrPayUp != 0) { CurrJobCode = Convert.ToString(oRec["job_code_id"]); } else { CurrJobCode = ""; } CurrRow++; CurrRecord = NewRecord.ToString(); } else { ViewModel.sprWeek.Col = 9; strAMPM = ViewModel.sprWeek.Text + "/" + Convert.ToString(oRec["AMPM"]); ViewModel.sprWeek.Text = strAMPM; } oRec.MoveNext(); if (!oRec.EOF) { CurrPos = Convert.ToString(oRec["unit_code"]).Trim() + "-" + Convert.ToString(oRec["position_code"]).Trim(); NewRecord = new System.Text.StringBuilder(Convert.ToString(oRec["name_full"]).Trim() + CurrPos + modGlobal.Clean(oRec["work_time"])); //UPGRADE_WARNING: (1049) Use of Null/IsNull() detected. More Information: http://www.vbtonet.com/ewis/ewi1049.aspx if (!Convert.IsDBNull(oRec["leave_time"])) { NewRecord.Append(modGlobal.Clean(oRec["leave_time"])); } if (Convert.ToBoolean(oRec["pay_upgrade"])) { NewRecord.Append(Convert.ToString(oRec["job_code_id"])); } } } ; }
private void CreateArtistAndLabelProfiles(NewRecord recordInfo) { Task.WaitAll( _db.Artists.Add(recordInfo.Artist), _db.Labels.Add(recordInfo.Label)); }
public Task Add([FromBody] NewRecord record) { return(_records.Add(record)); }
public Task Add(NewRecord record) { return(_set.AddAsync(_mapper.Map <Record>(record))); }
public void AppendRequest(NewRecord record) { _requests.Add(record); }
private void RemoveTracklistHeadings(NewRecord record) { // record.Tracklist = record.Tracklist.Where(t => t.Type_ == "track"); }
static void Main(string[] args) { NewRecord a = new NewRecord(); a.InitializeClass(); }