/// <summary> /// On leave from txtToDate /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtToDate_Leave(object sender, EventArgs e) { try { DateValidation dv = new DateValidation(); dv.DateValidationFunction(txtToDate); if (txtToDate.Text == string.Empty) { txtToDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy"); } string d = txtToDate.Text; dtpToDate.Value = Convert.ToDateTime(d.ToString()); } catch (Exception ex) { MessageBox.Show("VRR:11" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Date validation /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtToDate_Leave(object sender, EventArgs e) { try { DateValidation obj = new DateValidation(); bool isInvalid = obj.DateValidationFunction(txtToDate); if (!isInvalid) { txtToDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy"); } string date = txtToDate.Text; dtpToDate.Value = Convert.ToDateTime(date); } catch (Exception ex) { MessageBox.Show("DNTREG10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// For date validation and set dtp value as textbox value /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtCheckDateTo_Leave(object sender, EventArgs e) { try { DateValidation obj = new DateValidation(); obj.DateValidationFunction(txtCheckDateTo); if (txtCheckDateTo.Text == string.Empty) { txtCheckDateTo.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy"); } string strdate = txtCheckDateTo.Text; dtpCheckDateTo.Value = Convert.ToDateTime(strdate.ToString()); } catch (Exception ex) { MessageBox.Show("PRREP18:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public Response <Reservation> MakeReservation(int CarID, int UserID, DateTime startingDate, DateTime endTime) { try { Reservation reservation = new Reservation() { Car = new Car() { CarID = CarID }, User = new User() { UserID = UserID }, StartingDate = startingDate, EndDate = endTime }; Response <Reservation> res = new Response <Reservation>(); if (DateValidation.CheckIfValid(startingDate, endTime)) // check the dates if they are valid (more detail in the function definition) { using (var repo = new ReservationRepository()) { res.isSuccess = repo.Insert(reservation); if (res.isSuccess) { res.Message = "Rezervasyon işlemi başarı ile gerçekleştirilmiştir"; } else { res.Message = "Rezervasyon işlemi gerçekleştirilirken bir sorun ile karşılaşılmıştır"; } return(res); } } else { res.isSuccess = false; res.Message = "Geçersiz rezervasyon tarihleri !"; } return(res); } catch (Exception ex) { throw new Exception("An error occured in MakeReservation() function in SpiceApp.BusinessLayer.CarBusiness", ex); } }
/// <summary> /// On leave from txtFromDate /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtFromDate_Leave(object sender, EventArgs e) { try { DateValidation objValidation = new DateValidation(); objValidation.DateValidationFunction(txtFromDate); if (txtFromDate.Text == "") { txtFromDate.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy"); } DateTime dt; DateTime.TryParse(txtFromDate.Text, out dt); dtpFrmDate.Value = dt; } catch (Exception ex) { MessageBox.Show("FSR :12" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// DateValidation /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtDate_Leave(object sender, EventArgs e) { try { DateValidation DateValidationObj = new DateValidation(); DateValidationObj.DateValidationFunction(txtDate); if (txtDate.Text == string.Empty) { txtDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy"); } //---for change date in Date time picker----// string strDate = txtDate.Text; dtpDate.Value = Convert.ToDateTime(strDate.ToString()); } catch (Exception ex) { MessageBox.Show("DAR:7" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Date Validation /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dtpdate_Leave(object sender, EventArgs e) { try { DateValidation objValidation = new DateValidation(); objValidation.DateValidationFunction(txtToDate); if (txtToDate.Text == string.Empty) { txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy"); } DateTime dt; DateTime.TryParse(txtToDate.Text, out dt); dtpdate.Value = dt; } catch (Exception ex) { MessageBox.Show("BS :7" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function for initial date settings /// </summary> public void InitialDateSettings() { try { dtpAgeingDate.Value = PublicVariables._dtToDate; dtpAgeingDate.MinDate = PublicVariables._dtFromDate; dtpAgeingDate.MaxDate = PublicVariables._dtToDate; DateValidation objValidation = new DateValidation(); objValidation.DateValidationFunction(txtToDate); if (txtToDate.Text == string.Empty) { txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy"); } } catch (Exception ex) { MessageBox.Show("AR10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// DateValidation /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtToDate_Leave(object sender, EventArgs e) { try { DateValidation dateValidationObj = new DateValidation(); dateValidationObj.DateValidationFunction(txtToDate); if (txtToDate.Text == String.Empty) { txtToDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy"); } dtpToDate.Value = DateTime.Parse(txtToDate.Text); } catch (Exception ex) { MessageBox.Show("RIReport:13" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Date validation /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtToDate_Leave(object sender, EventArgs e) { try { if (txtToDate.Text == string.Empty) { txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy"); } DateValidation DateValidationObj = new DateValidation(); DateValidationObj.DateValidationFunction(txtToDate); if (txtToDate.Text == string.Empty) { txtToDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy"); } } catch (Exception ex) { MessageBox.Show("PAL :13" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Date validation and set dtp's value as textbox text /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtFromDate_TextChanged(object sender, EventArgs e) { try { if (txtFromDate.Text == string.Empty && !txtFromDate.Focused) { DateValidation obj = new DateValidation(); bool isInvalid = obj.DateValidationFunction(txtFromDate); if (!isInvalid) { txtFromDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy"); } string date = txtFromDate.Text; dtpFromDate.Value = Convert.ToDateTime(date); } } catch (Exception ex) { MessageBox.Show("PIREP19:" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private DateValidation validateModifiedCriteria() { DateCriteria modifiedCriteria = (DateCriteria)EnumEx.GetValueFromDescription(typeof(DateCriteria), modifiedCriteriaCombo.SelectedItem.ToString()); DateTime firstDateTime = firstModifiedDatePicker.Value.Date; firstDateTime = firstDateTime.Add(firstModifiedTimePicker.Value.TimeOfDay); DateTime secondDateTime = secondModifiedDatePicker.Value.Date; secondDateTime = secondDateTime.Add(secondModifiedTimePicker.Value.TimeOfDay); DateValidation modifiedResult = validateDateCriteria(modifiedCriteria, firstDateTime, secondDateTime); searchCriteria.ModifiedDateCriteria = modifiedCriteria; searchCriteria.FirstModifiedDate = firstDateTime; searchCriteria.SecondModifiedDate = secondDateTime; return(modifiedResult); }
private DateValidation validateCreationCriteria() { DateCriteria creationCriteria = (DateCriteria)EnumEx.GetValueFromDescription(typeof(DateCriteria), creationCriteriaCombo.SelectedItem.ToString()); DateTime firstDateTime = firstCreationDatePicker.Value.Date; firstDateTime = firstDateTime.Add(firstCreationTimePicker.Value.TimeOfDay); DateTime secondDateTime = secondCreationDatePicker.Value.Date; secondDateTime = secondDateTime.Add(secondCreationTimePicker.Value.TimeOfDay); DateValidation creationResult = validateDateCriteria(creationCriteria, firstDateTime, secondDateTime); searchCriteria.CreatedDateCriteria = creationCriteria; searchCriteria.FirstCreatedDate = firstDateTime; searchCriteria.SecondCreatedDate = secondDateTime; return(creationResult); }
/// <summary> /// Function to check or validate dates /// </summary> /// <param name="txt"></param> /// <param name="dtp"></param> public void DateValidation(TextBox txt, DateTimePicker dtp) { try { DateValidation obj = new DateValidation(); obj.DateValidationFunction(txt); if (txtFromDate.Text == String.Empty) { txt.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy"); } if (txtToDate.Text == String.Empty) { txt.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy"); } dtp.Value = DateTime.Parse(txt.Text); } catch (Exception ex) { MessageBox.Show("SVRT 11 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Fills Datagirdview on 'Search' button click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSearch_Click(object sender, EventArgs e) { try { DateValidation ObjValidation = new DateValidation(); ObjValidation.DateValidationFunction(txtToDate); dtFromDate = Convert.ToDateTime(txtFromDate.Text); dtToDate = Convert.ToDateTime(txtToDate.Text); decVoucherType = Convert.ToDecimal(cmbVoucherType.SelectedValue); strVocherNo = txtVoucherNo.Text; decCashOrParty = Convert.ToDecimal(cmbCashorParty.SelectedValue); if (cmbDeliveryNoteNo.SelectedIndex != -1) { decDeliveryNoteNo = Convert.ToDecimal(cmbDeliveryNoteNo.SelectedValue.ToString()); } decSalesManId = Convert.ToDecimal(cmbSalesMan.SelectedValue); strProductCode = txtProductCode.Text; if (Convert.ToDateTime(txtToDate.Text) < Convert.ToDateTime(txtFromDate.Text)) { MessageBox.Show("todate should be greater than fromdate", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy"); txtFromDate.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy"); DateTime dt; DateTime.TryParse(txtToDate.Text, out dt); dtpToDate.Value = dt; RejectionInReportFill(); } else { DateTime dt; DateTime.TryParse(txtToDate.Text, out dt); dtpToDate.Value = dt; RejectionInReportFill(); } } catch (Exception ex) { MessageBox.Show("RIReport:15" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public async ValueTask <ActionResult <List <FilialWithIncomeOutputModel> > > GetTotalFilialSumPerPeriod(PeriodInputModel inputModel) { if (!DateValidation.IsValidDate(inputModel.StartDate)) { return(BadRequest("StartDate should be in dd.MM.yyyy format.")); } if (!DateValidation.IsValidDate(inputModel.EndDate)) { return(BadRequest("EndDate should be in dd.mm.yyyy format.")); } var result = await _reportRepository.GetTotalFilialSumPerPeriod(_mapper.Map <Period>(inputModel)); if (result.IsOkay) { if (result.RequestData == null) { return(Problem($"Sorry, there is no information about total filial sum per period.", statusCode: 520)); } return(Ok(_mapper.Map <List <FilialWithIncomeOutputModel> >(result.RequestData))); } return(Problem($"Transaction failed {result.ExMessage}", statusCode: 520)); }
/// <summary> /// Date validation and fill dtp value into the todate textbox /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtToDate_Leave(object sender, EventArgs e) { try { DateValidation DateValidationObj = new DateValidation(); DateValidationObj.DateValidationFunction(txtToDate); if (txtToDate.Text != string.Empty && txtFromDate.Text != string.Empty) { if (Convert.ToDateTime(txtToDate.Text) <= Convert.ToDateTime(txtFromDate.Text)) { txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy"); txtFromDate.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy"); DateTime dt; DateTime.TryParse(txtToDate.Text, out dt); dtpToDate.Value = dt; } else { txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy"); DateTime dt; DateTime.TryParse(txtToDate.Text, out dt); dtpToDate.Value = dt; } } else { txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy"); DateTime dt; DateTime.TryParse(txtToDate.Text, out dt); dtpToDate.Value = dt; } } catch (Exception ex) { MessageBox.Show("VPS :17" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// On 'Search' button click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnRefersh_Click(object sender, EventArgs e) { try { DateValidation ObjValidation = new DateValidation(); ObjValidation.DateValidationFunction(txtToDate); if (Convert.ToDateTime(txtToDate.Text) < Convert.ToDateTime(txtFromDate.Text)) { MessageBox.Show("To-Date should be greater than From-Date", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); txtToDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy"); txtFromDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy"); DateTime dt; DateTime.TryParse(txtToDate.Text, out dt); dtpToDate.Value = dt; dtpFromDate.Value = dt; } StockJournalRegisterGrideFill(); } catch (Exception ex) { MessageBox.Show("SJREG:7" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Search button click call the search function /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSearch_Click(object sender, EventArgs e) { try { DateValidation ObjValidation = new DateValidation(); ObjValidation.DateValidationFunction(txtToDate); if (Convert.ToDateTime(txtToDate.Text) < Convert.ToDateTime(txtFromDate.Text)) { MessageBox.Show("todate should be greater than fromdate", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy"); txtFromDate.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy"); Search(); } else { Search(); } } catch (Exception ex) { MessageBox.Show("PRREP12:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Date validation and fill datagridview /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtCompanyCurrentdate_Leave(object sender, EventArgs e) { try { DateValidation obj = new DateValidation(); obj.DateValidationFunction(txtCompanyCurrentdate); if (txtCompanyCurrentdate.Text == String.Empty) { txtCompanyCurrentdate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy"); } if (DateTime.Parse(txtCompanyCurrentdate.Text) > PublicVariables._dtCurrentDate) { txtCompanyCurrentdate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy"); } dtpCompanyCurrentDate.Value = DateTime.Parse(txtCompanyCurrentdate.Text); GridFill(); HolidayIndication(); } catch (Exception ex) { MessageBox.Show("A24" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void FindCheapestAndBestHotelForGivenDate_TC6() { string[] date = "11Sep2020,12Sep2020".Split(","); string expectedHotel = "Bridgewood"; int expectedRate = 200; string actualHotel = ""; int actualRate = 0; try { HotelReservation reservation = new HotelReservation(); string[] days = DateValidation.Validate(date); Dictionary <string, int> hotel = reservation.FindCheapestRatesAndBestRatingHotel("Regular", date); foreach (KeyValuePair <string, int> kv in hotel) { actualHotel = kv.Key; actualRate = kv.Value; } Assert.AreEqual(expectedHotel, actualHotel); Assert.AreEqual(expectedRate, actualRate); } catch (HotelCustomException e) { Console.WriteLine(e.Message); } }
static void Main(string[] args) { //Debug args parameters if (args[0] == "debug") { args = new string[] { "01.01.2000", "01.02.2000" }; } //views initialization var dateView = new DateView(); var programView = new ProgramView(); DateValidation dateValidation; //models initialization var inputValidation = new InputValidation(args); if (args.Length == 3) { dateValidation = new DateValidation(args[2]); } else { dateValidation = new DateValidation(); } var dateParser = new DateParser(); var calculateDateRange = new CalculateDateRange(); //controller initialization var dateController = new DateController(dateValidation, dateParser, calculateDateRange, dateView); var programController = new ProgramController(inputValidation, programView, dateController, args); //Program turn on programController.RunProgram(); }
/// <summary> /// Datevalidation /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtFromDateSearch_Leave(object sender, EventArgs e) { try { DateValidation obj = new DateValidation(); bool isInvalide = obj.DateValidationFunction(txtFromDateSearch); if (!isInvalide) { txtFromDateSearch.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy"); } if (txtFromDateSearch.Text == string.Empty) { txtFromDateSearch.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy"); } //---for change date in Date time picker----// string strdate = txtFromDateSearch.Text; dtpFromDateSeach.Value = Convert.ToDateTime(strdate.ToString()); //------------------// } catch (Exception ex) { MessageBox.Show("PREM16:" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public Response <Car> FetchAvailableCarsForResv(int UserID, DateTime startingDate, DateTime endTime) { try { Response <Car> res = new Response <Car>(); if (DateValidation.CheckIfValid(startingDate, endTime)) // check the dates if they are valid (more detail in the function definition) { using (var repo = new ReservationRepository()) { res.Data = repo.FetchAvailableCarsForResv(UserID, startingDate, endTime); if (res.Data.Count > 0) { res.Message = "Rezervasyon için uygun olan arabaların listesi"; res.isSuccess = true; } else { res.Message = "Rezervasyona uygun araçları getirirken bir hata ile karşılaşıldı"; res.isSuccess = false; } return(res); } } else { res.Message = "Geçersiz rezervasyon tarihleri !"; res.isSuccess = false; } return(res); } catch (Exception ex) { throw new Exception("An error occured in FetchAvailableCarsForResv() in SpiceApp.BusinessLayer.CarBusiness", ex); } }
/// <summary> /// For date validation and set the date as text box date /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtFromDate_Leave(object sender, EventArgs e) { try { DateValidation obj = new DateValidation(); bool isInvalid = obj.DateValidationFunction(txtFromDate); if (!isInvalid) { txtFromDate.Text = strFromDateToKeep; } else { string date = txtFromDate.Text; dtpFromDate.Value = Convert.ToDateTime(date); } dtpToDate.MinDate = Convert.ToDateTime(txtFromDate.Text); //dtpToDate.Value = dtpFromDate.Value; //txtToDate.Clear(); } catch (Exception ex) { MessageBox.Show("NFY 16 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
//[HttpPost] //public ActionResult Endorsement(Endorsement endorsement, HttpPostedFileBase GLpostedFileDoc, HttpPostedFileBase GLpostedFilePage, HttpPostedFileBase WLpostedFilePage) //{ //} public static CsvFileBulkUplaod FromCsv(string csvLineData) { string[] values = csvLineData.Split(','); CsvFileBulkUplaod objCsvFileBulkUplaod = new CsvFileBulkUplaod(); objCsvFileBulkUplaod.DivisionCode = values[0]; objCsvFileBulkUplaod.ProductCode = values[1]; objCsvFileBulkUplaod.ClassName = values[2]; objCsvFileBulkUplaod.ProductName = values[3]; objCsvFileBulkUplaod.PolicyNumber = values[4]; objCsvFileBulkUplaod.InsuredName = values[5]; objCsvFileBulkUplaod.PeriodFrom = DateValidation.ConvertDateTimeFormatter(values[6], "MM-dd-yyyy HH:mm"); objCsvFileBulkUplaod.PeriodTo = DateValidation.ConvertDateTimeFormatter(values[7], "MM-dd-yyyy HH:mm"); objCsvFileBulkUplaod.CustomerPhoneNo = values[8]; objCsvFileBulkUplaod.CustomerType = values[9]; objCsvFileBulkUplaod.CustomerCode = values[10]; objCsvFileBulkUplaod.CustomerName = values[11]; objCsvFileBulkUplaod.SourceCode = values[12]; objCsvFileBulkUplaod.SourceName = values[13]; objCsvFileBulkUplaod.VehicleType = values[14]; objCsvFileBulkUplaod.VehicleMake = values[15]; objCsvFileBulkUplaod.RegNo = values[16]; objCsvFileBulkUplaod.EngineNo = values[17]; objCsvFileBulkUplaod.ChassisNo = values[18]; objCsvFileBulkUplaod.SumInsured = Convert.ToDecimal(values[19]); objCsvFileBulkUplaod.RevisedSumInsured = Convert.ToDecimal(values[20]); objCsvFileBulkUplaod.TotalGrossPremium = Convert.ToDecimal(values[21]); objCsvFileBulkUplaod.RevisedGrossPremium = Convert.ToDecimal(values[22]); objCsvFileBulkUplaod.Geo = values[23]; objCsvFileBulkUplaod.RenewalStatus = values[24]; objCsvFileBulkUplaod.MarketingCode = values[25]; objCsvFileBulkUplaod.UserName = values[26]; return objCsvFileBulkUplaod; }
public void Init() { _dateValidation = new DateValidation(); }
private void okayBtn_OnClick(object sender, EventArgs e) { NameValidation nameResult = validateNameCriteria(); switch (nameResult) { case NameValidation.BadRegex: warningLabel.Text = "Warning: A bad regular expression was provided for the name criteria"; warningLabel.Visible = true; return; } DateValidation modifiedResult = validateModifiedCriteria(); switch (modifiedResult) { case DateValidation.AfterNow: warningLabel.Text = "Warning: The modified date criteria is in the future"; warningLabel.Visible = true; return; case DateValidation.NegativeSpan: warningLabel.Text = "Warning: The modified date criteria has inverted begin and end dates"; warningLabel.Visible = true; return; } DateValidation creationResult = validateCreationCriteria(); switch (creationResult) { case DateValidation.AfterNow: warningLabel.Text = "Warning: The creation date criteria is in the future"; warningLabel.Visible = true; return; case DateValidation.NegativeSpan: warningLabel.Text = "Warning: The creation date criteria has inverted begin and end dates"; warningLabel.Visible = true; return; } SizeValidation sizeResult = validateSizeCriteria(); switch (sizeResult) { case SizeValidation.SizeBad: warningLabel.Text = "Warning: The size criteria is not a valid number"; warningLabel.Visible = true; return; case SizeValidation.FirstSizeBad: warningLabel.Text = "Warning: The size criteria minimum is not a valid number"; warningLabel.Visible = true; return; case SizeValidation.SecondSizeBad: warningLabel.Text = "Warning: The size criteria maximum is not a valid number"; warningLabel.Visible = true; return; case SizeValidation.NegativeSpan: warningLabel.Text = "Warning: The size criteria has inverted miniumum and maximum values"; warningLabel.Visible = true; return; case SizeValidation.LessThanZero: warningLabel.Text = "Warning: The size criteria is less than zero"; warningLabel.Visible = true; return; } warningLabel.Visible = false; DialogResult = DialogResult.OK; }
private bool ValidateForm() { // TODO - check if Item already exists bool output = true; errorsItem.Clear(); // Item validation - check if exists one already //if (SqlConnector.CheckIfItemExists(itemItemText.Text, itemAssetText.Text).Count != 0) //{ // output = false; // errorsItem.Add($"{ itemItemText.Text } { itemAssetText.Text } already exists"); //} // asset validation if (itemAssetText.Text.Length > 20) { output = false; errorsItem.Add("Asset Length should be <= 20"); } // Arrived validation DateValidation dateValidation = new DateValidation(itemArrivedText.Text); if (itemArrivedText.Text.Length == 0) { output = false; errorsItem.Add("Date couldn't be empty"); } if (itemArrivedText.Text.Length > 10) { output = false; errorsItem.Add("Date Length should be 10 simbols"); } if (!dateValidation.ValidateDate()) { output = false; errorsItem.Add("Wrong Date pattern"); } // Invoice validation InvoiceValidation invoiceValidation = new InvoiceValidation(itemInvoiceText.Text); if (itemInvoiceText.Text.Length == 0) { output = false; errorsItem.Add("Invoice couldn't be empty"); } if (itemInvoiceText.Text.Length > 10) { output = false; errorsItem.Add("Invoice Length should be <= 10"); } if (!invoiceValidation.ValidateInvoice()) { output = false; errorsItem.Add("Wrong Invoice pattern, should be like X/MM/YY"); } // ccd validation CCDValidation ccdValidation = new CCDValidation(itemCcdText.Text); if (itemCcdText.Text.Length == 0) { output = false; errorsItem.Add("CCD couldn't be empty"); } if (itemCcdText.Text.Length > 25) { output = false; errorsItem.Add("CCD Length should be <= 25"); } if (!ccdValidation.ValidateCCD()) { output = false; errorsItem.Add("Wrong CCD pattern"); } // positionCCD validation int positionInCCD = 0; bool positionrValidNumber = int.TryParse(itemPositionCcdText.Text, out positionInCCD); if (positionrValidNumber == false) { output = false; errorsItem.Add("Wrong Position number"); } // status validation if (itemStatusText.Text.Length > 20) { output = false; errorsItem.Add("Item Status is Tool long, should be <= 20"); } // container validation if (itemContainerText.Text.Length > 10) { output = false; errorsItem.Add("Container Name Too long"); } return(output); }
/// <summary> /// Function to fill Datagridview /// </summary> public void FillGrid() { try { if (!isFormLoad) { DateValidation objValidation = new DateValidation(); objValidation.DateValidationFunction(txtToDate); if (txtToDate.Text == string.Empty) { txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy"); } Font newFont = new Font(dgvReport.Font, FontStyle.Bold); CurrencyInfo InfoCurrency = new CurrencyInfo(); CurrencySP SpCurrency = new CurrencySP(); InfoCurrency = SpCurrency.CurrencyView(1); int inDecimalPlaces = InfoCurrency.NoOfDecimalPlaces; dgvReport.Rows.Clear(); FinancialStatementSP SpFinance = new FinancialStatementSP(); DataSet DsetBalanceSheet = new DataSet(); DataTable dtbl = new DataTable(); SettingsInfo InfoSettings = new SettingsInfo(); SettingsSP SpSettings = new SettingsSP(); //--------------- Selection Of Calculation Method According To Settings ------------------// if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "FIFO") { calculationMethod = "FIFO"; } else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Average Cost") { calculationMethod = "Average Cost"; } else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "High Cost") { calculationMethod = "High Cost"; } else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Low Cost") { calculationMethod = "Low Cost"; } else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Last Purchase Rate") { calculationMethod = "Last Purchase Rate"; } DsetBalanceSheet = SpFinance.BalanceSheet(PublicVariables._dtFromDate, DateTime.Parse(txtToDate.Text)); //------------------- Asset -------------------------------// dtbl = DsetBalanceSheet.Tables[0]; foreach (DataRow rw in dtbl.Rows) { dgvReport.Rows.Add(); dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value = rw["Name"].ToString(); dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Value = rw["Balance"].ToString(); dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["GroupId1"].Value = rw["ID"].ToString(); } decimal dcTotalAsset = 0; if (dtbl.Rows.Count > 0) { dcTotalAsset = decimal.Parse(dtbl.Compute("Sum(Balance)", string.Empty).ToString()); } //------------------------ Liability ---------------------// dtbl = new DataTable(); dtbl = DsetBalanceSheet.Tables[1]; int index = 0; foreach (DataRow rw in dtbl.Rows) { if (index < dgvReport.Rows.Count) { dgvReport.Rows[index].Cells["dgvtxtLiability"].Value = rw["Name"].ToString(); dgvReport.Rows[index].Cells["Amount2"].Value = rw["Balance"].ToString(); dgvReport.Rows[index].Cells["GroupId2"].Value = rw["ID"].ToString(); } else { dgvReport.Rows.Add(); dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value = rw["Name"].ToString(); dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Value = rw["Balance"].ToString(); dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["GroupId2"].Value = rw["ID"].ToString(); } index++; } decimal dcTotalLiability = 0; if (dtbl.Rows.Count > 0) { dcTotalLiability = decimal.Parse(dtbl.Compute("Sum(Balance)", string.Empty).ToString()); } decimal dcClosingStock = SpFinance.StockValueGetOnDate(Convert.ToDateTime(txtToDate.Text), calculationMethod, false, false); dcClosingStock = Math.Round(dcClosingStock, inDecimalPlaces); //---------------------Opening Stock--------------------------------------------------------------------------------------------------------------- decimal dcOpeninggStock = SpFinance.StockValueGetOnDate(PublicVariables._dtFromDate, calculationMethod, true, true); decimal dcProfit = 0; DataSet dsetProfitAndLoss = new DataSet(); dsetProfitAndLoss = SpFinance.ProfitAndLossAnalysisUpToaDateForBalansheet(PublicVariables._dtFromDate, DateTime.Parse(txtToDate.Text)); DataTable dtblProfit = new DataTable(); dtblProfit = dsetProfitAndLoss.Tables[0]; for (int i = 0; i < dsetProfitAndLoss.Tables.Count; ++i) { dtbl = dsetProfitAndLoss.Tables[i]; decimal dcSum = 0; if (i == 0 || (i % 2) == 0) { if (dtbl.Rows.Count > 0) { dcSum = decimal.Parse(dtbl.Compute("Sum(Debit)", string.Empty).ToString()); dcProfit = dcProfit - dcSum; } } else { if (dtbl.Rows.Count > 0) { dcSum = decimal.Parse(dtbl.Compute("Sum(Credit)", string.Empty).ToString()); dcProfit = dcProfit + dcSum; } } } decimal decCurrentProfitLoss = 0; decCurrentProfitLoss = dcProfit + (dcClosingStock - dcOpeninggStock); decimal dcProfitOpening = 0; DataSet dsetProfitAndLossOpening = new DataSet(); dsetProfitAndLossOpening = SpFinance.ProfitAndLossAnalysisUpToaDateForPreviousYears(PublicVariables._dtFromDate); DataTable dtblProfitOpening = new DataTable(); dtblProfitOpening = dsetProfitAndLossOpening.Tables[0]; for (int i = 0; i < dsetProfitAndLossOpening.Tables.Count; ++i) { dtbl = dsetProfitAndLossOpening.Tables[i]; decimal dcSum = 0; if (i == 0 || (i % 2) == 0) { if (dtbl.Rows.Count > 0) { dcSum = decimal.Parse(dtbl.Compute("Sum(Debit)", string.Empty).ToString()); dcProfitOpening = dcProfitOpening - dcSum; } } else { if (dtbl.Rows.Count > 0) { dcSum = decimal.Parse(dtbl.Compute("Sum(Credit)", string.Empty).ToString()); dcProfitOpening = dcProfitOpening + dcSum; } } } DataTable dtblProfitLedgerOpening = new DataTable(); dtblProfitLedgerOpening = DsetBalanceSheet.Tables[3]; decimal decProfitLedgerOpening = 0; foreach (DataRow dRow in dtblProfitLedgerOpening.Rows) { decProfitLedgerOpening += decimal.Parse(dRow["Balance"].ToString()); } DataTable dtblProf = new DataTable(); dtblProf = DsetBalanceSheet.Tables[2]; decimal decProfitLedger = 0; if (dtblProf.Rows.Count > 0) { decProfitLedger = decimal.Parse(dtblProf.Compute("Sum(Balance)", string.Empty).ToString()); } decimal decTotalProfitAndLoss = 0; if (dcProfitOpening >= 0) { decTotalProfitAndLoss = decProfitLedger; } else if (dcProfitOpening < 0) { decTotalProfitAndLoss = decProfitLedger; } index = 0; if (dcClosingStock >= 0) { //---------- Asset ----------// dgvReport.Rows.Add(); dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value = "Closing Stock"; dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Value = Math.Round(dcClosingStock, inDecimalPlaces); dcTotalAsset += dcClosingStock; } else { //--------- Liability ---------// dgvReport.Rows.Add(); dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value = "Closing Stock"; dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Value = -(Math.Round(dcClosingStock, inDecimalPlaces)); dcTotalLiability += -dcClosingStock; } dgvReport.Rows.Add(); decimal decOpeningOfProfitAndLoss = decProfitLedgerOpening + dcProfitOpening; decimal decTotalProfitAndLossOverAll = decTotalProfitAndLoss + decOpeningOfProfitAndLoss + decCurrentProfitLoss; if (decTotalProfitAndLossOverAll <= 0) { dgvReport.Rows.Add(); dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value = "----------------------------------------"; dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font = newFont; foreach (DataRow dRow in dtblProf.Rows) { if (dRow["Name"].ToString() == "Profit And Loss Account") { dgvReport.Rows.Add(); dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font = newFont; dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.ForeColor = Color.DarkSlateGray; dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value = dRow["Name"].ToString(); if (decCurrentProfitLoss < 0) { decCurrentProfitLoss = decCurrentProfitLoss * -1; } dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Value = Math.Round(decTotalProfitAndLoss + decCurrentProfitLoss, PublicVariables._inNoOfDecimalPlaces); dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["GroupId1"].Value = dRow["ID"].ToString(); } } //-------------- Asset ---------------// dgvReport.Rows.Add(); dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font = newFont; dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value = "Profit And Loss (Opening)"; dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Value = Math.Round(decTotalProfitAndLoss, PublicVariables._inNoOfDecimalPlaces); dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Style.ForeColor = Color.DarkSlateGray; dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Style.ForeColor = Color.DarkSlateGray; //-------------- Asset ---------------// dgvReport.Rows.Add(); dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font = newFont; dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value = "Current Period"; dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Value = Math.Round(decCurrentProfitLoss, PublicVariables._inNoOfDecimalPlaces); dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Style.ForeColor = Color.DarkSlateGray; dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Style.ForeColor = Color.DarkSlateGray; dcTotalAsset = dcTotalAsset + (decCurrentProfitLoss + decTotalProfitAndLoss); dgvReport.Rows.Add(); dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value = "----------------------------------------"; dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font = newFont; } else if (decTotalProfitAndLossOverAll > 0) { dgvReport.Rows.Add(); dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value = "----------------------------------------"; dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font = newFont; foreach (DataRow dRow in dtblProf.Rows) { if (dRow["Name"].ToString() == "Profit And Loss Account") { dgvReport.Rows.Add(); dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font = newFont; dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.ForeColor = Color.DarkSlateGray; dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value = dRow[1].ToString(); dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Value = Math.Round(decTotalProfitAndLoss + decCurrentProfitLoss, PublicVariables._inNoOfDecimalPlaces); dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["GroupId2"].Value = dRow[0].ToString(); } } //------------ Liability ------------// dgvReport.Rows.Add(); dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font = newFont; dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value = "Profit And Loss (Opening)"; dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Value = Math.Round(decTotalProfitAndLoss, inDecimalPlaces); dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Style.ForeColor = Color.DarkSlateGray; dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Style.ForeColor = Color.DarkSlateGray; dcTotalLiability += decOpeningOfProfitAndLoss; //------------ Liability ------------// dgvReport.Rows.Add(); dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font = newFont; dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value = "Current Period"; dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Value = Math.Round(decCurrentProfitLoss, inDecimalPlaces); dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Style.ForeColor = Color.DarkSlateGray; dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Style.ForeColor = Color.DarkSlateGray; dcTotalLiability = dcTotalLiability + (decCurrentProfitLoss + decTotalProfitAndLoss); //dcProfit; dgvReport.Rows.Add(); dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value = "----------------------------------------"; dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font = newFont; } dgvReport.Rows.Add(); decimal dcDiffAsset = 0; decimal dcDiffLiability = 0; decimal dcTotalValue = dcTotalAsset; if (dcTotalAsset != dcTotalLiability) { if (dcTotalAsset > dcTotalLiability) { //--------------- Liability exceeds so in asset side ----------------// dgvReport.Rows.Add(); dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value = "Difference"; dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Value = Math.Round((dcTotalAsset - dcTotalLiability), inDecimalPlaces); dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font = newFont; dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.ForeColor = Color.DarkRed; dcDiffLiability = dcTotalAsset - dcTotalLiability; } else { //--------------- Asset exceeds so in liability side ----------------// dgvReport.Rows.Add(); dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value = "Difference"; dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Value = Math.Round((dcTotalLiability - dcTotalAsset), inDecimalPlaces);; dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font = newFont; dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.ForeColor = Color.DarkRed; dcDiffAsset = dcTotalLiability - dcTotalAsset; } } dgvReport.Rows.Add(); dgvReport.Rows.Add(); dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Value = "__________________________"; dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Value = "__________________________"; dgvReport.Rows.Add(); dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font = newFont; dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value = "Total"; dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value = "Total"; dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Value = Math.Round((dcTotalAsset + dcDiffAsset), inDecimalPlaces); dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Value = Math.Round((dcTotalLiability + dcDiffLiability), inDecimalPlaces); if (dgvReport.Columns.Count > 0) { dgvReport.Columns["Amount1"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dgvReport.Columns["Amount2"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; } decPrintOrNot = dcTotalAsset + dcDiffAsset; decPrintOrNot1 = dcTotalLiability + dcDiffLiability; if (inCurrenRowIndex >= 0 && dgvReport.Rows.Count > 0 && inCurrenRowIndex < dgvReport.Rows.Count) { if (dgvReport.Rows[inCurrenRowIndex].Cells[inCurentcolIndex].Visible) { dgvReport.CurrentCell = dgvReport.Rows[inCurrenRowIndex].Cells[inCurentcolIndex]; } if (dgvReport.CurrentCell != null && dgvReport.CurrentCell.Visible) { dgvReport.CurrentCell.Selected = true; } } inCurrenRowIndex = 0; } } catch (Exception ex) { MessageBox.Show("BS :1" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }