private void loadLearningSamplesBtn_Click(object sender, RoutedEventArgs e) { if (network == null) { learningSamplesStatus.Content = "Stwórz najpierw sieć"; return; } OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = Environment.CurrentDirectory; openFileDialog.Filter = "txt files (*.txt)|*.txt"; openFileDialog.RestoreDirectory = true; if (openFileDialog.ShowDialog() != true) { learningSamplesStatus.Content = "Wystąpił problem podczas ładowania wybranego pliku"; return; } string path = openFileDialog.FileName; string[] learningSamples = File.ReadAllLines(path); if (!FormValidation.areLearningSamplesValid(configuration, learningSamples, out string message)) { learningSamplesStatus.Content = message; return; } learning = new Learning(learningSamples); learningSamplesStatus.Content = "Próbki załadowane"; denormalizationBox.Text = "Min = " + learning.min.ToString() + " Max = " + learning.max.ToString(); }
private void loadWeightsBtn_Click(object sender, RoutedEventArgs e) { if (network == null) { weightsStatus.Content = "Stwórz najpierw sieć"; return; } OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = Environment.CurrentDirectory; openFileDialog.Filter = "txt files (*.txt)|*.txt"; openFileDialog.RestoreDirectory = true; if (openFileDialog.ShowDialog() != true) { weightsStatus.Content = "Wystąpił problem z wybranym plikiem"; return; } string path = openFileDialog.FileName; string[] weightsString = File.ReadAllLines(path); if (!FormValidation.areWeightsValid(configuration.networkStructure, weightsString, out string message)) { weightsStatus.Content = message; return; } weights = WeightsHandler.loadWeights(path); network.setWeights(weights); weightsStatus.Content = "Załadowano wagi"; weightsLoaded = true; }
private void SetValidation() { validation = new FormValidation(); validation.AddItem(new ValidationItem { ValidationControl = txtBrandName, Type = ValidationType.IsNullOrEmpty, Message = "Lütfen marka yazınız." }); }
private void SetValidation() { validation = new FormValidation(); validation.AddItem(new ValidationItem { ValidationControl = trvCategory, Type = ValidationType.IsNullOrEmpty, Message = "Lütfen kategori seçiniz." }); validation.AddItem(new ValidationItem { ValidationControl = txtProductName, Type = ValidationType.IsNullOrEmpty, Message = "Lütfen ürün adını yazınız." }); validation.AddItem(new ValidationItem { ValidationControl = txtProductPrice, Type = ValidationType.IsNullOrEmpty, Message = "Lütfen ürün fiyatı yazınız." }); validation.AddItem(new ValidationItem { ValidationControl = txtProductPrice, Type = ValidationType.DecimalControl, Message = "Lütfen ürün fiyatını kontrol ediniz." }); validation.AddItem(new ValidationItem { ValidationControl = txtKdvRatio, Type = ValidationType.IsNullOrEmpty, Message = "Lütfen KDV oranı yazınız." }); validation.AddItem(new ValidationItem { ValidationControl = txtStockCount, Type = ValidationType.IsNullOrEmpty, Message = "Lütfen stok sayısını yazınız." }); validation.AddItem(new ValidationItem { ValidationControl = txtProductExplanation, Type = ValidationType.IsNullOrEmpty, Message = "Lütfen ürün açıklamasını yazınız." }); }
public ApplicationFacade(Applicant applicant) { _applicant = applicant; _backgroundValidation = new BackgroundValidation(applicant); _feeValidation = new FeeValidation(applicant); _formValidation = new FormValidation(applicant); }
private void calculateButton_Click(object sender, EventArgs e) { //Agent newJuniorAgent; try { //Check validation if (FormValidation.IsEmpty(lNameTextBox.Text) && FormValidation.IsEmpty(fNameTextBox.Text) && FormValidation.IsEmpty(emailTextBox.Text) && FormValidation.IsEmpty(salesAmountTextBox.Text)) { MessageBox.Show("Validation failed", "error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //disable textBox control lNameTextBox.Enabled = false; fNameTextBox.Enabled = false; emailTextBox.Enabled = false; juniorRadioButton.Enabled = false; agentRadioButton.Enabled = false; seniorRadioButton.Enabled = false; salesAmountTextBox.Enabled = false; //prepare result for displaying richTextBox1.Visible = true; if (juniorRadioButton.Checked == true) { JuniorAgent newJuniorAgent = new JuniorAgent(lNameTextBox.Text, fNameTextBox.Text, emailTextBox.Text, double.Parse(salesAmountTextBox.Text), true); richTextBox1.Text = ""; richTextBox1.Text = "Junior Agent commission Income Details\n\nTotal commission: " + newJuniorAgent.CalculateCommission(true).ToString("C") + "\nCommission Rate: " + newJuniorAgent.GetCommissionRate() + "\nNote that Junior agent got 0.5% less commission than agent"; } else if (agentRadioButton.Checked == true) { richTextBox1.Text = ""; Agent aAgent = new Agent(lNameTextBox.Text, fNameTextBox.Text, emailTextBox.Text, double.Parse(salesAmountTextBox.Text)); richTextBox1.Text = "Agent commission Income Details\n\nTotal commission: " + aAgent.CalculateCommission(true).ToString("C") + "\nCommission Rate: " + aAgent.GetCommissionRate(); } else { richTextBox1.Text = ""; SeniorAgent aSeniorAgent = new SeniorAgent(lNameTextBox.Text, fNameTextBox.Text, emailTextBox.Text, double.Parse(salesAmountTextBox.Text)); richTextBox1.Text = "Senior Agent commission Income Details\n\nTotal commission: " + aSeniorAgent.CalculateCommission(true).ToString("C") + "\nCommission Rate: " + aSeniorAgent.GetCommissionRate(); } this.Width = 657; } } catch (FormatException) { MessageBox.Show("Validation failed", "error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/*********************** Events **************************************************************************/ private void saveDeviation_Click(object sender, EventArgs e) { FormValidation formValidation = new FormValidation(); bool requestedBy = formValidation.isTextBoxNotNull(this.requestedBy, errorProvider1); bool position = formValidation.isTextBoxNotNull(this.position, errorProvider1); bool standardCondition = formValidation.isTextBoxNotNull(this.standardCondition, errorProvider1); bool detailRequestedDevV = formValidation.isTextBoxNotNull(this.detailRequestedDeviation, errorProvider1); bool deviationType = formValidation.isItemFromComoBoxSelected(this.deviationType, errorProvider1); int compareDeviationPeriod = this.validateDeviationPeriod(); bool deviationTypeDescription = true; if (this.deviationType.SelectedItem.ToString() == "Sonstiges") { if (this.deviationDescription.Text == "") { deviationTypeDescription = formValidation.isTextBoxNotNull(this.deviationDescription, errorProvider1); } } if (requestedBy && position && standardCondition && detailRequestedDevV && deviationType && compareDeviationPeriod != 0 && compareDeviationPeriod < 0) { Deviation deviation = this.getDeviationObject(); if (this.actionType == "newDeviation") { //add a new Deviation //verify if the user is one of the Group //redirect the user to se the email content EmailGUI emailGUI = new EmailGUI(deviation, this); emailGUI.Show(); } else { //update DEVIATION // before updating verify the Autorisation if (this.deviation != null) { deviationModel.updateDeviation(this.getDeviationObjectToUpdate()); MessageBox.Show(this.languageModel.getString("deviationupdated"), "Infos", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } } else { MessageBox.Show(this.languageModel.getString("formInputsNotValid"), "Infos", MessageBoxButtons.OK, MessageBoxIcon.Information); if (compareDeviationPeriod == 0) { MessageBox.Show(this.languageModel.getString("deviationPeriodNull"), "Infos", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (compareDeviationPeriod > 0) { MessageBox.Show(this.languageModel.getString("deviationNegativePeriod"), "Infos", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
protected void SetValidation() { validation = new FormValidation(); validation.AddItem(new ValidationItem { ValidationControl = txtCategoryName, Type = ValidationType.IsNullOrEmpty, Message = "Lütfen kategori adı yazınız" }); validation.AddItem(new ValidationItem { ValidationControl = txtExplanation, Type = ValidationType.IsNullOrEmpty, Message = "Lütfen açıklama yazınız" }); }
protected AbstractForm() { // Avoid putting any custom code within this ctor, otherwise designers stops working InitializeComponent(); _displayMessage = new DisplayMessage(); _formValidation = new FormValidation(_displayMessage); Load += (sender, args) => SetTooltips(); Load += (sender, args) => AddPassiveValidationHandlers(); }
private void createNetworkBtn_Click(object sender, RoutedEventArgs e) { if (!FormValidation.isConfigurationValid(configurationBox, out string configurationError)) { networkStatus.Content = configurationError; return; } configuration = new Configuration(configurationBox.Text); network = new Network(configuration); reset(); networkStatus.Content = "Sieć utworzona"; }
private void learnBtn_Click(object sender, RoutedEventArgs e) { if (network == null) { learningStatus.Content = "Stwórz najpierw sieć"; return; } if (!weightsLoaded) { learningStatus.Content = "Załaduj najpierw wagi"; return; } if (learning == null) { learningStatus.Content = "Załaduj najpierw próbki uczące"; return; } if (!FormValidation.isBetaValid(betaBox, out string betaMessage)) { learningStatus.Content = betaMessage; return; } if (!FormValidation.isLearningFactorValid(learningFactorBox, out string LearningFactorMessage)) { learningStatus.Content = LearningFactorMessage; return; } if (!FormValidation.isEpochAmountValid(epochAmountBox, out string epochMessage)) { learningStatus.Content = epochMessage; return; } epochAmount = int.Parse(epochAmountBox.Text); beta = double.Parse(betaBox.Text); learningFactor = double.Parse(learningFactorBox.Text); BackgroundWorker worker = new BackgroundWorker(); worker.WorkerReportsProgress = true; worker.ProgressChanged += worker_ProgressChanged; worker.DoWork += worker_DoWork; if (worker.IsBusy == true) { learningStatus.Content = "Poczekaj na zakończenie procesu uczenia"; return; } progressBar.Visibility = Visibility.Visible; worker.RunWorkerAsync(); }
private void placeOrderToolStripMenuItem1_Click(object sender, EventArgs e) { //Declare local variables string mealType = "", firstName = "", lastName = ""; int hamQty = 0, subQty = 0, fishQty = 0; firstName = firstNameTextBox.Text; lastName = lastNameTextBox.Text; try { if (hamCheckBox.Checked) { mealType += "Hamburger"; hamQty = int.Parse(hamQTextBox.Text); } if (subCheckBox.Checked) { mealType += " Sub"; subQty = int.Parse(subQTextBox.Text); } if (fishCheckBox.Checked) { mealType += " Fish"; fishQty = int.Parse(fishQTextBox.Text); } int comboOption = mealChoiceComboBox.SelectedIndex; //Check validation if (!FormValidation.IsEmpty(firstName) && !FormValidation.IsEmpty(lastName) && ((hamCheckBox.Checked && hamQty > 0) || (subCheckBox.Checked && subQty > 0) || (fishCheckBox.Checked && fishQty > 0)) && comboOption >= 0) { //If Validation is passed then place the order Order aOrder = new Order(firstName, lastName, comboOption, mealType, hamQty, subQty, fishQty); MessageBox.Show("Your order is placed"); } else { MessageBox.Show("Validation failed"); } } catch (FormatException) { MessageBox.Show("Invalid input"); } }
public void ACTION_REGISTER() { ButtonHelper.Clicked(); string name = register.transform.Find("name").GetComponent <InputField>().text; string email = register.transform.Find("email").GetComponent <InputField>().text; string password = register.transform.Find("password").GetComponent <InputField>().text; string gamerID = register.transform.Find("gamerID").GetComponent <InputField>().text; string validEmail = FormValidation.ValidEmail(email); string validName = FormValidation.ValidName(name); string validPassword = FormValidation.ValidPassword(password); string validGamerID = FormValidation.ValidGamerID(gamerID); if (validName != null) { ErrorPanel.ShowError(validName); ButtonHelper.ResetClick(); } else if (validGamerID != null) { ErrorPanel.ShowError(validGamerID); ButtonHelper.ResetClick(); } else if (validEmail != null) { ErrorPanel.ShowError(validEmail); ButtonHelper.ResetClick(); } else if (validPassword != null) { ErrorPanel.ShowError(validPassword); ButtonHelper.ResetClick(); } else { OnlineManager.UserData.Name = name; OnlineManager.UserData.EmailID = email; OnlineManager.UserData.Password = password; OnlineManager.UserData.GamerID = gamerID; StartCoroutine(onlineManager.Register()); } }
async void SubmitLogin(object sender, EventArgs args) { if (loading.IsRunning == false) { loading.IsRunning = true; Console.WriteLine("login action"); List <ValidationModel> validations = new List <ValidationModel>(); List <ConstraintsModel> constraintsModel = new List <ConstraintsModel>(); constraintsModel.Add(new ConstraintsModel(Constants.NOT_EMPTY_DATA)); validations.Add(new ValidationModel("Usuario:", username.Text, constraintsModel)); validations.Add(new ValidationModel("Contraseña:", password.Text, constraintsModel)); var validationResult = FormValidation.ValidateFields(validations, this); if (validationResult) { if (await App.restServices.login(username.Text, password.Text)) { loading.IsRunning = false; await Navigation.PushAsync(new Menu()); } else { loading.IsRunning = false; } } else { loading.IsRunning = false; } } }
private void outputBtn_Click(object sender, RoutedEventArgs e) { if (network == null) { resultBox.Text = "Najpierw stwórz sieć"; return; } if (!FormValidation.isBetaValid(inputBetaBox, out string message)) { resultBox.Text = message; return; } if (!FormValidation.isInputValid(configuration, inputBox, out string inputMessage)) { resultBox.Text = inputMessage; return; } if (!FormValidation.isMinValid(minBox, out string minMessage)) { resultBox.Text = minMessage; return; } if (!FormValidation.isMaxValid(minBox, out string maxMessage)) { resultBox.Text = maxMessage; return; } double min = double.Parse(minBox.Text); double max = double.Parse(maxBox.Text); double inputBeta = double.Parse(inputBetaBox.Text); var inputs = Tools.convertStringToDoubleList(inputBox.Text); double output = network.calculateOutput(inputs, inputBeta); double denormalizedOutput = Tools.getDenormalizedValue(output, min, max); resultBox.Text = denormalizedOutput.ToString(); }
private void SetupFormValidationRules() { try { Form thisForm = (Form)this; m_formValidation = new FormValidation(ref thisForm, ref btnSubmit); FieldProxy field = null; field = new FieldProxy(); field.Name = "WELLSITE_SITE"; field.Type = esriFieldType.esriFieldTypeDouble; field.Precision = 15; field.Scale = 0; field.IsNullable = false; m_formValidation.AddControlValidationInfo(field, ref txtWellsiteSID,enumTextEntryTypes.intnum); field = new FieldProxy(); field.Name = "UTM_NORTHING"; field.Type = esriFieldType.esriFieldTypeDouble; field.Precision = 13; field.Scale = 4; field.IsNullable = true; m_formValidation.AddControlValidationInfo(field, ref txtUTMnorthing,enumTextEntryTypes.decnum); field = new FieldProxy(); field.Name = "UTM_EASTING"; field.Type = esriFieldType.esriFieldTypeDouble; field.Precision = 12; field.Scale = 4; field.IsNullable = true; m_formValidation.AddControlValidationInfo(field, ref txtUTMeasting,enumTextEntryTypes.decnum); field = new FieldProxy(); field.Name = "UTM_ZONE"; field.Type = esriFieldType.esriFieldTypeInteger; field.Precision = 10; field.IsNullable = true; m_formValidation.AddControlValidationInfo(field, ref txtUTMzone,enumTextEntryTypes.intnum,new CustomTextBoxValidator(CustomUTMZoneValidation)); field = new FieldProxy(); field.Name = "LATITUDE"; field.Type = esriFieldType.esriFieldTypeDouble; field.Precision = 11; field.Scale = 7; field.IsNullable = true; m_formValidation.AddControlValidationInfo(field, ref txtLatitude,enumTextEntryTypes.decnum); field = new FieldProxy(); field.Name = "LONGITUDE"; field.Type = esriFieldType.esriFieldTypeDouble; field.Precision = 11; field.Scale = 7; field.IsNullable = true; m_formValidation.AddControlValidationInfo(field, ref txtLongitude,enumTextEntryTypes.decnum); field = new FieldProxy(); field.Name = "BCGS_MAPSHEET"; field.Type = esriFieldType.esriFieldTypeString; field.Length = 32; field.IsNullable = false; m_formValidation.AddControlValidationInfo(field, ref txtBCGSMap,enumTextEntryTypes.text); } catch(Exception ex) { util.Logger.Write(" Descrip : Setting up form validation rules. " + "\n Message : " + ex.Message + "\n StackTrc : " + ex.StackTrace,util.Logger.LogLevel.Debug); Debug.WriteLine(ex.Message); Debug.WriteLine(ex.StackTrace); } }
public static IForm <Laporan> BuildForm() { OnCompletionAsyncDelegate <Laporan> processReport = async(context, state) => { await Task.Run(() => { state.NoLaporan = $"LP-{DateTime.Now.ToString("dd_MM_yyyy_HH_mm_ss")}"; state.TglLaporan = DateTime.Now; } ); }; var builder = new FormBuilder <Laporan>(false); var form = builder .Field(nameof(Nama), validate: async(state, value) => { var result = new ValidateResult { IsValid = true, Value = value, Feedback = "ok, nama valid" }; bool res = value != null ? !string.IsNullOrEmpty(value.ToString()):false; if (!res) { result.Feedback = "tolong namanya di isi ya"; result.IsValid = false; } return(result); }) .Field(nameof(Telpon), validate: async(state, value) => { var result = new ValidateResult { IsValid = true, Value = value, Feedback = "ok, telpon valid" }; bool res = FormValidation.isValidPhoneNumber(value.ToString()); if (!res) { result.Feedback = "tolong isi dengan nomor telpon yang benar ya, cth : 08171234567"; result.IsValid = false; } return(result); }) .Field(nameof(Email), validate: async(state, value) => { var result = new ValidateResult { IsValid = true, Value = value, Feedback = "ok, email valid" }; bool res = FormValidation.IsValidEmail(value.ToString()); if (!res) { result.Feedback = "tolong isi dengan email yang benar ya"; result.IsValid = false; } return(result); }) .Field(nameof(TipeLaporan)) .Field(nameof(Keterangan), validate: async(state, value) => { var result = new ValidateResult { IsValid = true, Value = value, Feedback = "ok, keterangan valid" }; bool res = value != null ? !string.IsNullOrEmpty(value.ToString()) : false; if (!res) { result.Feedback = "tolong keterangannya di isi ya"; result.IsValid = false; } return(result); }) .Field(nameof(Lokasi), validate: async(state, value) => { var result = new ValidateResult { IsValid = true, Value = value, Feedback = "ok, lokasi valid" }; bool res = value != null ? !string.IsNullOrEmpty(value.ToString()) : false; if (!res) { result.Feedback = "tolong lokasi di isi ya"; result.IsValid = false; } return(result); }) .Field(nameof(Waktu)) .Field(nameof(SkalaPrioritas), validate: async(state, value) => { var result = new ValidateResult { IsValid = true, Value = value, Feedback = "ok, skala valid" }; bool res = int.TryParse(value.ToString(), out int jml); if (res) { if (jml <= 0) { result.Feedback = "input data yang benar ya, minimum di isi 1"; result.IsValid = false; } else if (jml > 10) { result.Feedback = "input data yang benar ya, maximum di isi 10"; result.IsValid = false; } } else { result.Feedback = "tolong isi dengan angka ya"; result.IsValid = false; } return(result); }) .Confirm(async(state) => { var pesan = $"Abang uda terima laporan dari {state.Nama} tentang {state.TipeLaporan.ToString()}, sudah ok ?"; return(new PromptAttribute(pesan)); }) .Message($"Makasih ya atas laporannya.") .OnCompletion(processReport) .Build(); return(form); }
public BrandAdd() { InitializeComponent(); validation = new FormValidation(); SetValidation(); }
private void 用户管理ToolStripMenuItem_Click(object sender, EventArgs e) { FormValidation validation = new FormValidation(); validation.Show(this); }
private void saveBtn_Click(object sender, EventArgs e) { string errorText = ""; bool hasFormInputError = false; if (FormValidation.IsEmpty(accHolderNameTxtBox.Text, "Name")) { errorText += FormValidation.ErrorText + "\n"; hasFormInputError = true; } if (FormValidation.IsEmpty(locationTxtbox.Text, "Location")) { errorText += FormValidation.ErrorText + "\n"; hasFormInputError = true; } if (FormValidation.IsEmpty(checkingAccNoTxtBox.Text, "Checkin Account No")) { errorText += FormValidation.ErrorText + "\n"; hasFormInputError = true; } if (!FormValidation.IsPositiveValue(checkingAccNoTxtBox.Text)) { errorText += FormValidation.ErrorText + " for checking acc no!\n"; hasFormInputError = true; } if (!FormValidation.IsDouble(checkingAccBalanceTxtBox.Text)) { errorText += FormValidation.ErrorText + " for chekcing balance\n"; hasFormInputError = true; } if (FormValidation.IsEmpty(savingsAccNoTxtBox.Text, "Savings Account No")) { errorText += FormValidation.ErrorText + "\n"; hasFormInputError = true; } if (!FormValidation.IsPositiveValue(savingsAccNoTxtBox.Text)) { errorText += FormValidation.ErrorText + " for savings acc no!\n"; hasFormInputError = true; } if (!FormValidation.IsDouble(savingAccBalanceTxtBox.Text)) { errorText += FormValidation.ErrorText + " for savings balance\n"; hasFormInputError = true; } if (hasFormInputError) { showBtn.Visible = false; MessageBox.Show("Please fix the following error\n\n" + errorText, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { CheckingAcc aCheckingAcc = new CheckingAcc(Double.Parse(checkingAccBalanceTxtBox.Text), accHolderNameTxtBox.Text, locationTxtbox.Text, Int32.Parse(checkingAccNoTxtBox.Text)); SavingsAcc aSavingsAcc = new SavingsAcc(Double.Parse(savingAccBalanceTxtBox.Text), accHolderNameTxtBox.Text, locationTxtbox.Text, Int32.Parse(savingsAccNoTxtBox.Text)); accountSummary = aCheckingAcc.ToString() + aSavingsAcc.ToString(); showBtn.Visible = true; MessageBox.Show("Information saved successfully!", "", MessageBoxButtons.OK); } }