/* * Реализация */ #region private bool ValidateRTSDate() /// <summary> /// Проверяем введенную дату /// </summary> /// <returns></returns> private bool ValidateRTSDate() { if (UsefulMethods.StringToDate(textRTSDate.Text) == null) { SimpleBalloon.Show(textRTSDate, ToolTipIcon.Warning, "Incorrect date format", "Please enter the date in the following format: DD.MM.YYYY"); return(false); } // return(true); }
/// <summary> /// Проверяет правильность ввода дробного числа /// </summary> /// <param name="textBox"></param> /// <returns></returns> private bool ValidateDoubleTextBox(TextBox textBox) { double d; if (!UsefulMethods.StringToDouble(textBox.Text, out d)) { SimpleBalloon.Show(textBox, ToolTipIcon.Warning, "Incorrect numeric format", "Enter valid number"); return(false); } // return(true); }
/* * Реализация */ #region private bool ValidateTimePeriod(TextBox textBox) /// <summary> /// Проверяем введенный интервал времени /// </summary> /// <returns></returns> private bool ValidateTimePeriod(TextBox textBox) { TimeSpan time1, time2; if (!UsefulMethods.ParseTimePeriod(textBox.Text, out time1, out time2)) { SimpleBalloon.Show(textBox, ToolTipIcon.Warning, "Incorrect time format", "Please enter the time period in the following format:\nHH.MM - HH.MM"); return(false); } // return(true); }
/// <summary> /// Проверяет правильность введенных данных /// </summary> /// <param name="condition"></param> /// <param name="labelTitle"></param> /// <param name="textN1"></param> /// <param name="textN2"></param> /// <returns></returns> private bool ValidateBundle(LandingGearCondition condition, Label labelTitle, TextBox textN1, TextBox textN2) { double d; if (!UsefulMethods.StringToDouble(textN1.Text, out d)) { SimpleBalloon.Show(textN1, ToolTipIcon.Warning, "Incorrect numeric format", "Enter valid number"); return(false); } if (!UsefulMethods.StringToDouble(textN2.Text, out d)) { SimpleBalloon.Show(textN2, ToolTipIcon.Warning, "Incorrect numeric format", "Enter valid number"); return(false); } // return(true); }
/// <summary> /// Данные работы обновляются по введенным значениям /// </summary> private bool SaveData() { double eps = 0.00000001; double hours; double cycles; if (!UsefulMethods.CheckDoubleValue(textBoxHours.Text, out hours, "Hours")) { SimpleBalloon.Show(textBoxHours, ToolTipIcon.Warning, "Incorrect value", "Please enter the float number"); return(false); } if (!UsefulMethods.CheckDoubleValue(textBoxCycles.Text, out cycles, "Cycles")) { SimpleBalloon.Show(textBoxCycles, ToolTipIcon.Warning, "Incorrect value", "Please enter the float number"); return(false); } if (currentAircraft.UtilizationInterval.UtilizationIntervalType != UtilzationIntervalType) { currentAircraft.UtilizationInterval.UtilizationIntervalType = UtilzationIntervalType; } if (Math.Abs(currentAircraft.UtilizationInterval.Hours - hours) > eps) { currentAircraft.UtilizationInterval.Hours = hours; } if (Math.Abs(currentAircraft.UtilizationInterval.Cycles - cycles) > eps) { currentAircraft.UtilizationInterval.Cycles = cycles; } try { currentAircraft.Save(true); } catch (Exception ex) { Program.Provider.Logger.Log("Error while saving data", ex); return(false); } return(true); }
private void buttonOK_Click(object sender, EventArgs e) { if (textBoxModel.Text == "") { SimpleBalloon.Show(textBoxModel, ToolTipIcon.Warning, "Value expected", "Please enter aircraft model"); return; } DialogResult = DialogResult.OK; TemplateAircraft aircraft = new TemplateAircraft(); aircraft.Model = textBoxModel.Text; aircraft.Type = AircraftType; try { TemplateAircraftCollection.Instance.Add(aircraft); aircraft.AddAircraftFrame("", MaintenanceTypeCollection.Instance.UnknownType, "", "", ""); } catch (Exception ex) { Program.Provider.Logger.Log("Error while saving data", ex); DialogResult = DialogResult.Cancel; } Close(); }
/// <summary> /// Данные работы обновляются по введенным значениям /// </summary> private bool SaveData() { TimeSpan hours; int cycles; if (!UsefulMethods.ParseTime(textBoxFlightHours.Text, out hours)) { SimpleBalloon.Show(textBoxFlightHours, ToolTipIcon.Warning, "Incorrect time format", "Please enter the time period in the following format:\nHH:MM"); return(false); } if (!int.TryParse(textBoxFlightCycles.Text, out cycles)) { SimpleBalloon.Show(textBoxFlightCycles, ToolTipIcon.Warning, "Incorrect value", "Please enter integer value"); return(false); } if (currentRecord.RecordDate != dateTimePickerDate.Value) { currentRecord.RecordDate = dateTimePickerDate.Value; } if (currentRecord.Lifelength.Hours.ToString() != textBoxFlightHours.Text || currentRecord.Lifelength.Cycles.ToString() != textBoxFlightCycles.Text) { currentRecord.Lifelength = new Lifelength(new TimeSpan(0), cycles, hours); } if (currentRecord.Description != textBoxRemarks.Text) { currentRecord.Description = textBoxRemarks.Text; } try { if (mode == ScreenMode.Add) { if (parentDetail != null) { parentDetail.AddRecord(currentRecord); } else { for (int i = 0; i < parentDetails.Count; i++) { parentDetails[i].AddRecord(new ActualStateRecord(currentRecord)); } } mode = ScreenMode.Edit; } else { currentRecord.Save(true); } if (RecordChanged != null) { RecordChanged(this, EventArgs.Empty); } } catch (Exception ex) { Program.Provider.Logger.Log("Error while saving data", ex); return(false); } return(true); }
/// <summary> /// Данные работы обновляются по введенным значениям /// </summary> private bool SaveData() { if (SerialNumber == "") { SimpleBalloon.Show(textBoxSerialNumber, ToolTipIcon.Warning, "Value expected", "Please enter serial number"); return(false); } if (PartNumber == "") { SimpleBalloon.Show(textBoxPartNumber, ToolTipIcon.Warning, "Value expected", "Please enter part number"); return(false); } if (DetailPattern != currentDetail.DetailPattern) { currentDetail.DetailPattern = DetailPattern; } if (SerialNumber != currentDetail.SerialNumber) { currentDetail.SerialNumber = SerialNumber; } if (PartNumber != currentDetail.PartNumber) { currentDetail.PartNumber = PartNumber; } if (Description != currentDetail.Description) { currentDetail.Description = Description; } if (ShelfLife != currentDetail.ShelfLife) { currentDetail.ShelfLife = ShelfLife; } if (ExpiryDate != currentDetail.ExpirationDate) { currentDetail.ExpirationDate = ExpiryDate; } if (NotificationDate != currentDetail.NotificationDate) { currentDetail.NotificationDate = NotificationDate; } if (Serviceable != currentDetail.Serviceable) { currentDetail.Serviceable = Serviceable; } if (Remarks != currentDetail.Remarks) { currentDetail.Remarks = Remarks; } try { if (mode == ScreenMode.Add) { parentStore.Add(currentDetail); mode = ScreenMode.Edit; } else { currentDetail.Save(); } } catch (Exception ex) { Program.Provider.Logger.Log("Error while saving data", ex); return(false); } return(true); }
/* * Реализация */ #region private bool ValidatePageNo() /// <summary> /// Проверяем Номер страницы /// </summary> /// <returns></returns> private bool ValidatePageNo() { //Проверка формата написания номера страницы int pageNum; if (!int.TryParse(textBoxPageNum.Text, out pageNum)) { SimpleBalloon.Show(textBoxPageNum, ToolTipIcon.Warning, "Incorrect page num", "Please enter the date in the following format: XXXPageNum"); return(false); } #region//проверка серии в номере страницы //if (Flight.ATLBId <= 0) return true;//отсутсвует родительский борт-журнал //AircraftFlight firstInAtlb = Flight.ParentAircraft.Flights.GetFirstFlightInAtlb(Flight.ATLBId); //AircraftFlight lastInAtlb = Flight.ParentAircraft.Flights.GetLastFlightInAtlb(Flight.ATLBId); //if (firstInAtlb == null || (firstInAtlb.PageNo == "" && lastInAtlb.PageNo == "")) // return true; //отсутсвуют первый (а значит и последний) полеты, несчем сравнивать //int firstPageNum, lastPageNum; ////проверка на правильность формата введения номера страницы //int.TryParse(firstInAtlb.PageNo, out firstPageNum); //int.TryParse(lastInAtlb.PageNo, out lastPageNum); //if (firstPageNum < 0 && lastPageNum < 0) return true; ////Получение серийных номеров //string firstSerial = firstPageNum >= 0 ? firstInAtlb.PageNo.Replace(firstPageNum.ToString(), "") : ""; //string lastSerial = lastPageNum >= 0 ? lastInAtlb.PageNo.Replace(lastPageNum.ToString(), "") : ""; //string currentSerial = textBoxPageNum.Text.Replace(pageNum.ToString(), ""); //if (Flight != firstInAtlb && Flight != lastInAtlb && // firstSerial != currentSerial && lastSerial != currentSerial) //{ // //SimpleBalloon.Show(textBoxPageNum, ToolTipIcon.Warning, "Incorrect page num Serial", // // "Please enter the serial in the following format: " + firstSerial + "PageNum"); // //return false; // MessageBox.Show("Incorrect page num Serial. " + // "\nPlease enter the serial in the following format: " + firstSerial + "PageNum." + // "\nOr create a new Log", // new GlobalTermsProvider()["SystemName"].ToString(), // MessageBoxButtons.OK, // MessageBoxIcon.Exclamation); // return false; //} #endregion #region//проверка на диапазон //if (lastPageNum > firstPageNum) //{ // //нумерация страниц идет по возрастанию // if((firstPageNum >= 0 && Math.Abs(pageNum - firstPageNum) >= 150 ) && // (lastPageNum >= 0 && Math.Abs(lastPageNum - pageNum) >= 150)) // { // MessageBox.Show("Incorrect page num. " + // "\nPlease enter the page number in the range from: " + firstPageNum + " to: " + lastPageNum + "." + // "\nOr create a new Log", // new GlobalTermsProvider()["SystemName"].ToString(), // MessageBoxButtons.OK, // MessageBoxIcon.Exclamation); // return false; // } //} //else if (firstPageNum > lastPageNum) //{ // //нумерация страниц идет по по убыванию // if ((firstPageNum >= 0 && Math.Abs(firstPageNum - pageNum) >= 150) && // (lastPageNum >= 0 && Math.Abs(pageNum - lastPageNum) >= 150)) // { // MessageBox.Show("Incorrect page num. " + // "\nPlease enter the page number in the range from: " + lastPageNum + " to: " + firstPageNum + "." + // "\nOr create a new Log", // new GlobalTermsProvider()["SystemName"].ToString(), // MessageBoxButtons.OK, // MessageBoxIcon.Exclamation); // return false; // } //} //else //{ // if (firstPageNum >= 0 && Math.Abs(firstPageNum - pageNum) >= 150) // { // MessageBox.Show("Incorrect page num. " + // "\nPlease enter the page number in the range from: " + firstPageNum + " +- 150." + // "\nOr create a new Log", // new GlobalTermsProvider()["SystemName"].ToString(), // MessageBoxButtons.OK, // MessageBoxIcon.Exclamation); // return false; // } //} #endregion #region//Проверка на наличие полета с таким же номером страницы var temp = GlobalObjects.AircraftFlightsCore.GetFlightWithPageNum(Flight.AircraftId, pageNum, Flight.ATLBId); if (Flight.ParentATLB != null && temp.Count >= Flight.ParentATLB.PageFlightCount && !temp.Contains(Flight)) { MessageBox.Show(@"The number of flights on a given page number" + "\nexceeds the possible quantitative flight " + "\non the same page of the logbook." + "\nPlease enter another page num", new GlobalTermsProvider()["SystemName"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } #endregion //DateTime? flightDate = UsefulMethods.StringToDate(textDate.Text); //AircraftFlight lastFlightInAtlb = flightDate != null // ? Flight.ParentAircraft.Flights.GetPreviousKnownRecord(flightDate.Value) // : null; //int prevPageNum; //if(lastFlightInAtlb != null && int.TryParse(lastFlightInAtlb.PageNo, out prevPageNum)) //{ // //сравнивание номеров страниц предыдущего и текущего полета // if(Math.Abs(prevPageNum - pageNum) > 1) // { // SimpleBalloon.Show(textBoxPageNum, ToolTipIcon.Warning, "Incorrect page num", // "introduced by the page number is different from the previous more than one unit"); // return false; // } //} return(true); }
/// <summary> /// Данные работы обновляются по введенным значениям /// </summary> private bool SaveData() { TimeSpan timeFrom; TimeSpan timeTo; if (FlightNo == "") { SimpleBalloon.Show(textBoxFlightNo, ToolTipIcon.Warning, "Value expected", "Please enter the Flight No"); return(false); } if (DirectionFrom == "") { SimpleBalloon.Show(textBoxDirectionFrom, ToolTipIcon.Warning, "Value expected", "Please enter the Direction (from)"); return(false); } if (DirectionTo == "") { SimpleBalloon.Show(textBoxDirectionTo, ToolTipIcon.Warning, "Value expected", "Please enter the Direction (to)"); return(false); } if (!TimeSpan.TryParse(textBoxFlightTimeFrom.Text, out timeFrom)) { SimpleBalloon.Show(textBoxFlightTimeFrom, ToolTipIcon.Warning, "Incorrect time format", "Please enter the time period in the following format:\nHH.MM"); return(false); } if (!TimeSpan.TryParse(textBoxFlightTimeTo.Text, out timeTo)) { SimpleBalloon.Show(textBoxFlightTimeTo, ToolTipIcon.Warning, "Incorrect time format", "Please enter the time period in the following format:\nHH.MM"); return(false); } if (currentAircraftFlight.FlightDate != Date) { currentAircraftFlight.FlightDate = Date; } if (currentAircraftFlight.FlightNo != FlightNo) { currentAircraftFlight.FlightNo = FlightNo; } if (currentAircraftFlight.StationFrom != DirectionFrom) { currentAircraftFlight.StationFrom = DirectionFrom; } if (currentAircraftFlight.StationTo != DirectionTo) { currentAircraftFlight.StationTo = DirectionTo; } if (currentAircraftFlight.Reference != Reference) { currentAircraftFlight.Reference = Reference; } if (currentAircraftFlight.TakeOffTime != timeFrom) { currentAircraftFlight.TakeOffTime = timeFrom; } if (currentAircraftFlight.LdgTime != timeTo) { currentAircraftFlight.LdgTime = timeTo; } if (currentAircraftFlight.Correct != Correct) { currentAircraftFlight.Correct = Correct; } try { if (mode == ScreenMode.Add) { parentAircraft.GetATLB(Date).AddFlight(currentAircraftFlight); mode = ScreenMode.Edit; } else { currentAircraftFlight.Save(true); } } catch (Exception ex) { Program.Provider.Logger.Log("Error while saving data", ex); return(false); } return(true); }
/// <summary> /// Данные работы обновляются по введенным значениям /// </summary> private bool SaveData() { TimeSpan hours; int cycles; if (!UsefulMethods.ParseTime(textBoxHours.Text, out hours)) { SimpleBalloon.Show(textBoxHours, ToolTipIcon.Warning, "Incorrect time format", "Please enter the time period in the following format:\nHH:MM"); return(false); } if (!int.TryParse(textBoxCycles.Text, out cycles)) { SimpleBalloon.Show(textBoxCycles, ToolTipIcon.Warning, "Incorrect value", "Please enter integer value"); return(false); } if (currentRecord.RecordDate != Date) { currentRecord.RecordDate = Date; } if (currentRecord.Description != Remarks) { currentRecord.Description = Remarks; } if (currentRecord.AttachedFile != AttachedFile) { currentRecord.AttachedFile.FileName = AttachedFile.FileName; currentRecord.AttachedFile.FileData = AttachedFile.FileData; } if (currentRecord.MaintenanceOrganization != MaintenanceOrganization) { currentRecord.MaintenanceOrganization = MaintenanceOrganization; } if (currentRecord.Reference != Reference) { currentRecord.Reference = Reference; } if (currentRecord.OfficialDocumentsReceived != OfficialRecordsReceived) { currentRecord.OfficialDocumentsReceived = OfficialRecordsReceived; } try { if (mode == ScreenMode.Add) { currentRecord.Completed = true; if (currentDetail != null) { currentRecord = new DetailDirectiveRecord(currentRecord); ((DetailDirective)comboBoxWorkType.SelectedItem).AddPerformance((DetailDirectiveRecord)currentRecord); } else { if (currentRecord.RecordType != RecordType) { currentRecord.RecordType = RecordType; } if (currentRecord.RecordType == RecordTypesCollection.Instance.DirectivePerformanceRecordType && !currentDirective.RepeatedlyPerform) { currentRecord.RecordType = RecordTypesCollection.Instance.DirectiveClosingRecordType; } currentDirective.AddRecord(currentRecord); } if (AttachedFile != null) { currentRecord.AttachedFile.FileName = AttachedFile.FileName; currentRecord.AttachedFile.FileData = AttachedFile.FileData; } mode = ScreenMode.Edit; } currentRecord.Save(true); if (actualStateChanged) { bool exist = false; int index = -1; for (int i = actualStateRecords.Length - 1; i >= 0; i--) { if (UsefulMethods.CompareDates(actualStateRecords[i].RecordDate, dateTimePickerDate.Value)) { exist = true; index = i; break; } } if (exist) { if (MessageBox.Show("There is another actual state record for this date.\nExisting data will be updated.\nContinue?", new GlobalTermsProvider()["SystemName"].ToString(), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation) == DialogResult.Yes) { actualStateRecords[index].Lifelength = new Lifelength(new TimeSpan(0), cycles, hours); actualStateRecords[index].Save(); } } else { ActualStateRecord record = new ActualStateRecord(new Lifelength(new TimeSpan(0), cycles, hours)); record.RecordDate = dateTimePickerDate.Value; if (currentRecord.Parent.Parent is BaseDetail) { ((BaseDetail)currentRecord.Parent.Parent).AddRecord(record); } else { ((BaseDetail)currentRecord.Parent.Parent.Parent).AddRecord(record); } } } if (RecordChanged != null) { RecordChanged(this, EventArgs.Empty); } } catch (Exception ex) { Program.Provider.Logger.Log("Error while saving data", ex); return(false); } return(true); }