private void CityTxt_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { StateBox.Focus(); e.Handled = true; e.SuppressKeyPress = true; } }
public MainViewModel() { GoodsPage = new Goods(); StateStoragePage = new StateStorage(); StateRobotPage = new StateRobot(); DocumentPage = new Document(); StateBoxPage = new StateBox(); SelectPage = new DelegetCommand(SelCom); CurrentPage = GoodsPage; }
public CellPosition Move(string[,] field) { var stateBox = BoardStates.Where(x => x.State == field).FirstOrDefault(); if (stateBox == null) { stateBox = new StateBox(field); BoardStates.Add(stateBox); } return(stateBox.GenerateMove()); }
private void Cleared() { FirstNBox.Clear(); LastNBox.Clear(); MiddleNBox.Clear(); PhoneBox.Clear(); EmailBox.Clear(); AddressBox1.Clear(); AddressBox2.Clear(); CityBox.Clear(); StateBox.Clear(); ZipBox.Clear(); CountryBox.Clear(); }
private void btnNew_Click(object sender, EventArgs e) { FirstNBox.Clear(); LastNBox.Clear(); MiddleNBox.Clear(); PhoneBox.Clear(); EmailBox.Clear(); AddressBox1.Clear(); AddressBox2.Clear(); CityBox.Clear(); StateBox.Clear(); ZipBox.Clear(); CountryBox.Clear(); }
public void SetChangeState(string state) { switch (GetTextCountryBox()) { case "United States": StateBox.SelectByText(state); break; case "-": SetChooseCountry("United States"); StateBox.SelectByText(state); break; } }
private void CreateAddress() { Student NewStudent = new Student(); int.TryParse(StreetNumberBox.Text, out int StreetNumber); int.TryParse(ZipCodeBox.Text, out int ZipCode); NewStudent.SetAddress(StreetNumber, StreetNameBox.Text, StateBox.Text, CityBox.Text, ZipCode); StreetNumberBox.Clear(); StreetNameBox.Clear(); StateBox.Clear(); CityBox.Clear(); ZipCodeBox.Clear(); //return NewAddress; }
private void Clear_form() { modify = false; SaveButton.Enabled = false; DeleteButton.Enabled = false; FirstNameBox.Clear(); MiddleNmeBox.Clear(); LastNameBox.Clear(); GenderBox.Clear(); Address1Box.Clear(); Address2Box.Clear(); CityBox.Clear(); StateBox.Clear(); ZipCodeBox.Clear(); EmailBox.Clear(); PhoneNumberBox.Clear(); ResultList.SelectedItems.Clear(); DateReceivedPicker.Value = DateTime.Today; StartTimeBox.Clear(); SaveTimeBox.Clear(); BackNumBox.Clear(); }
/// <summary> /// Clears all fields and sets necessary enables/disables to /// prepare for new customer entry into database. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void NewCustomerButton_Click(object sender, EventArgs e) { FirstNameBox.Clear(); LastNameBox.Clear(); AddressBox.Clear(); CityBox.Clear(); StateBox.Clear(); ZipBox.Clear(); PhoneBox.Clear(); EmailBox.Clear(); CustomerSelectBox.Enabled = false; CancelButton.Enabled = true; SaveButton.Enabled = true; return; /* * // When add customer button is first clicked, display message and disable box. * if (CustomerSelectBox.Enabled == true) * { * MessageBox.Show("To add a customer, fill in the fields and click Add Customer again", "Add Customer"); * CustomerSelectBox.Enabled = false; * return; * } * * // Once form is in "add customer" mode, add customer normally. * else * { * bool valid = true; // Boolean will be set to false if any tests fail, used to check if customer should be saved. * if (FirstNameBox.Text == "" || Regex.IsMatch(FirstNameBox.Text, name)) * { * MessageBox.Show("Please enter your first name", "First name is a required field"); * FirstNameBox.Focus(); * valid = false; * } * if (LastNameBox.Text == "" || Regex.IsMatch(LastNameBox.Text, name)) * { * MessageBox.Show("Please enter your last name", "Last name is a required field"); * LastNameBox.Focus(); * valid = false; * } * if (AddressBox.Text == "" || Regex.IsMatch(AddressBox.Text, address)) * { * MessageBox.Show("Please enter your address", "Address is a required field"); * AddressBox.Focus(); * valid = false; * } * if (CityBox.Text == "" || Regex.IsMatch(CityBox.Text, name)) * { * MessageBox.Show("Please enter your city", "City is a required field"); * CityBox.Focus(); * valid = false; * } * if (StateBox.Text == "" || Regex.IsMatch(StateBox.Text, name)) * { * MessageBox.Show("Please enter your state", "State is a required field"); * StateBox.Focus(); * valid = false; * } * if (ZipBox.Text == "" || Regex.IsMatch(ZipBox.Text, zip)) * { * MessageBox.Show("Please enter your zip code", "Zip Code is a required field"); * ZipBox.Focus(); * valid = false; * } * if (PhoneBox.Text == "" || Regex.IsMatch(PhoneBox.Text, phone)) * { * MessageBox.Show("Please enter your phone number", "Phone number is a required field"); * PhoneBox.Focus(); * valid = false; * } * if (EmailBox.Text == "" || Regex.IsMatch(EmailBox.Text, email)) * { * MessageBox.Show("Please enter your email address", "Email is a required field"); * EmailBox.Focus(); * valid = false; * } * * // If no issues, add customer to text file and ComboBox. * if (valid) * { * Customer tempCustomer = new Customer(FirstNameBox.Text, LastNameBox.Text, AddressBox.Text, CityBox.Text, StateBox.Text, ZipBox.Text, PhoneBox.Text, EmailBox.Text); * customers.Add(tempCustomer); * * // Close reader and inFile even if exception is thrown. * // SRC:https://stackoverflow.com/questions/86766/how-to-properly-handle-exceptions-when-performing-file-io * try * { * using (FileStream outFile = new FileStream("customers.txt", FileMode.Append, FileAccess.Write)) * using (StreamWriter writer = new StreamWriter(outFile)) * { * // Write info to file. * writer.WriteLine($"{FirstNameBox.Text},{LastNameBox.Text},{AddressBox.Text},{CityBox.Text},{StateBox.Text},{ZipBox.Text},{PhoneBox.Text},{EmailBox.Text}"); * // Clear Text Boxes. * FirstNameBox.Clear(); * LastNameBox.Clear(); * AddressBox.Clear(); * CityBox.Clear(); * StateBox.Clear(); * ZipBox.Clear(); * PhoneBox.Clear(); * EmailBox.Clear(); * CustomerSelectBox.Items.Add(tempCustomer); * CustomerSelectBox.Enabled = true; * } * } * catch (FileNotFoundException) * { * MessageBox.Show("File 'customers.txt' not found to write.", "File Write Error"); * } * // Catch generic I/O exceptions. * catch (IOException ex) * { * MessageBox.Show(ex.ToString(), "Error"); * } * * } * } */ }
/// <summary> /// Clicking button checks if all fields have plausible entires (not empty or wrong format). Then /// updates currently selected customer with new information. Uses email as unique identifier, but /// does not check if email already exists. (Not sure how...) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveButton_Click(object sender, EventArgs e) { bool valid = true; // Boolean will be set to false if any tests fail, used to check if customer should be saved. if (FirstNameBox.Text == "" || !Regex.IsMatch(FirstNameBox.Text, name)) { MessageBox.Show("Please enter your first name", "First name is a required field"); FirstNameBox.Focus(); valid = false; } if (LastNameBox.Text == "" || !Regex.IsMatch(LastNameBox.Text, name)) { MessageBox.Show("Please enter your last name", "Last name is a required field"); LastNameBox.Focus(); valid = false; } if (AddressBox.Text == "" || !Regex.IsMatch(AddressBox.Text, address)) { MessageBox.Show("Please enter your address", "Address is a required field"); AddressBox.Focus(); valid = false; } if (CityBox.Text == "" || !Regex.IsMatch(CityBox.Text, city)) { MessageBox.Show("Please enter your city", "City is a required field"); CityBox.Focus(); valid = false; } if (StateBox.Text == "" || !Regex.IsMatch(StateBox.Text, name)) { MessageBox.Show("Please enter your state", "State is a required field"); StateBox.Focus(); valid = false; } if (ZipBox.Text == "" || !Regex.IsMatch(ZipBox.Text, zip)) { MessageBox.Show("Please enter your zip code", "Zip Code is a required field"); ZipBox.Focus(); valid = false; } if (PhoneBox.Text == "" || !Regex.IsMatch(PhoneBox.Text, phone)) { MessageBox.Show("Please enter your phone number", "Phone number is a required field"); PhoneBox.Focus(); valid = false; } if (EmailBox.Text == "" || !Regex.IsMatch(EmailBox.Text, email)) { MessageBox.Show("Please enter your email address", "Email is a required field"); EmailBox.Focus(); valid = false; } // If invalid entry, do not save. if (!valid) { return; } // Else string ConnectionString = "server=localhost;user=root;database=book store;password="******"Insert into customer values" + $"('null','{FirstNameBox.Text}'," + $"'{LastNameBox.Text}'," + $"'{AddressBox.Text}'," + $"'{CityBox.Text}'," + $"'{StateBox.Text}'," + $"'{ZipBox.Text}'," + $"'{PhoneBox.Text}'," + $"'{EmailBox.Text}')"; cmd.Connection = DBConnect; cmd.ExecuteNonQuery(); DBConnect.Close(); FirstNameBox.Clear(); LastNameBox.Clear(); AddressBox.Clear(); CityBox.Clear(); StateBox.Clear(); ZipBox.Clear(); PhoneBox.Clear(); EmailBox.Clear(); // Call function to update the combobox with new customer added. CustomerSelectBox_Click(sender, e); CustomerSelectBox.Enabled = true; SaveButton.Enabled = false; MessageBox.Show("Customer added to database."); return; } // Else update the currently selected customer with textbox info // Extract first and last name into string array. string[] custName = new string[2]; custName = CustomerSelectBox.Text.Split(); cmd.CommandText = $"Update customer set" + $" first='{FirstNameBox.Text}'," + $"last='{LastNameBox.Text}'," + $"address='{AddressBox.Text}'," + $"city='{CityBox.Text}'," + $"state='{StateBox.Text}'," + $"zip='{ZipBox.Text}'," + $"phone='{PhoneBox.Text}'," + $"email='{EmailBox.Text}'" + $" where first='{custName[0]}' AND last ='{custName[1]}'"; cmd.Connection = DBConnect; cmd.ExecuteNonQuery(); DBConnect.Close(); MessageBox.Show("Customer successfully updated."); return; /* * SaveButton.Enabled = false; // Disable the save button again until new customer is selected from the comboBox. * * // Rewrite the entire file, omitting the line with the email of the customer that is being updated, since email is unique. * // SRC: https://stackoverflow.com/questions/10371630/c-sharp-text-file-search-for-specific-word-and-delete-whole-line-of-text-that-co * Customer tempCustomer = (Customer)(CustomerSelectBox.SelectedItem); * var oldLines = File.ReadAllLines("customers.txt"); * var newLines = oldLines.Where(line => !line.Contains(tempCustomer.email)); * File.WriteAllLines("customers.txt", newLines); * * customers.Remove((Customer)CustomerSelectBox.SelectedItem); // Remove old customer info from customer list. * * // Add new info to list. * tempCustomer = new Customer(FirstNameBox.Text, LastNameBox.Text, AddressBox.Text, CityBox.Text, StateBox.Text, ZipBox.Text, PhoneBox.Text, EmailBox.Text); * customers.Add(tempCustomer); * * // Close reader and inFile even if exception is thrown. * // SRC:https://stackoverflow.com/questions/86766/how-to-properly-handle-exceptions-when-performing-file-io * try * { * using (FileStream outFile = new FileStream("customers.txt", FileMode.Append, FileAccess.Write)) * using (StreamWriter writer = new StreamWriter(outFile)) * { * // Write info to file. * writer.WriteLine($"{FirstNameBox.Text},{LastNameBox.Text},{AddressBox.Text},{CityBox.Text},{StateBox.Text},{ZipBox.Text},{PhoneBox.Text},{EmailBox.Text}"); * } * * // Clear Text Boxes. * FirstNameBox.Clear(); * LastNameBox.Clear(); * AddressBox.Clear(); * CityBox.Clear(); * StateBox.Clear(); * ZipBox.Clear(); * PhoneBox.Clear(); * EmailBox.Clear(); * * // Update comboBox with new info. * CustomerSelectBox.Items.Remove(CustomerSelectBox.SelectedItem); * CustomerSelectBox.Items.Add(tempCustomer); * } * catch (FileNotFoundException) * { * MessageBox.Show("File 'customers.txt' not found to write.", "File Write Error"); * } * // Catch generic I/O exceptions. * catch (IOException ex) * { * MessageBox.Show(ex.ToString(), "Error"); * } */ }
void ReleaseDesignerOutlets() { if (AddressBox != null) { AddressBox.Dispose(); AddressBox = null; } if (BPOBox != null) { BPOBox.Dispose(); BPOBox = null; } if (CoBorrowerPopUp != null) { CoBorrowerPopUp.Dispose(); CoBorrowerPopUp = null; } if (CountyBox != null) { CountyBox.Dispose(); CountyBox = null; } if (DefaultRateBox != null) { DefaultRateBox.Dispose(); DefaultRateBox = null; } if (LenderPopUp != null) { LenderPopUp.Dispose(); LenderPopUp = null; } if (LoanRateBox != null) { LoanRateBox.Dispose(); LoanRateBox = null; } if (MonthsToCompletionBox != null) { MonthsToCompletionBox.Dispose(); MonthsToCompletionBox = null; } if (PnLBox != null) { PnLBox.Dispose(); PnLBox = null; } if (PointsBox != null) { PointsBox.Dispose(); PointsBox = null; } if (PurchaseDatePicker != null) { PurchaseDatePicker.Dispose(); PurchaseDatePicker = null; } if (PurchasePriceBox != null) { PurchasePriceBox.Dispose(); PurchasePriceBox = null; } if (RehabCostBox != null) { RehabCostBox.Dispose(); RehabCostBox = null; } if (StateBox != null) { StateBox.Dispose(); StateBox = null; } if (TitleHolderPopUp != null) { TitleHolderPopUp.Dispose(); TitleHolderPopUp = null; } if (TitlePopUp != null) { TitlePopUp.Dispose(); TitlePopUp = null; } if (TownBox != null) { TownBox.Dispose(); TownBox = null; } if (UpdateMessage != null) { UpdateMessage.Dispose(); UpdateMessage = null; } if (ProfitSplit != null) { ProfitSplit.Dispose(); ProfitSplit = null; } if (ProfitSplitBox != null) { ProfitSplitBox.Dispose(); ProfitSplitBox = null; } if (AcquisitionOnlyCheckBox != null) { AcquisitionOnlyCheckBox.Dispose(); AcquisitionOnlyCheckBox = null; } if (InitialLoanPercentBox != null) { InitialLoanPercentBox.Dispose(); InitialLoanPercentBox = null; } if (FullAcquisitionCostCheckBox != null) { FullAcquisitionCostCheckBox.Dispose(); FullAcquisitionCostCheckBox = null; } }
public Box(int xPos, int yPos) { this.xPos = xPos; this.yPos = yPos; this.state = StateBox.empty; }
/// <summary> /// Default constructor. /// </summary> public Box() { this.state = StateBox.empty; }
void ReleaseDesignerOutlets() { if (AddressBox != null) { AddressBox.Dispose(); AddressBox = null; } if (TownBox != null) { TownBox.Dispose(); TownBox = null; } if (CountyBox != null) { CountyBox.Dispose(); CountyBox = null; } if (StateBox != null) { StateBox.Dispose(); StateBox = null; } if (PurchaseDatePicker != null) { PurchaseDatePicker.Dispose(); PurchaseDatePicker = null; } if (TitleHolderPopUp != null) { TitleHolderPopUp.Dispose(); TitleHolderPopUp = null; } if (CoBorrowerPopUp != null) { CoBorrowerPopUp.Dispose(); CoBorrowerPopUp = null; } if (PurchasePriceBox != null) { PurchasePriceBox.Dispose(); PurchasePriceBox = null; } if (RehabCostBox != null) { RehabCostBox.Dispose(); RehabCostBox = null; } if (BPOBox != null) { BPOBox.Dispose(); BPOBox = null; } if (PnLBox != null) { PnLBox.Dispose(); PnLBox = null; } if (MonthsToCompletionBox != null) { MonthsToCompletionBox.Dispose(); MonthsToCompletionBox = null; } if (UpdateMessage != null) { UpdateMessage.Dispose(); UpdateMessage = null; } if (LenderPopUp != null) { LenderPopUp.Dispose(); LenderPopUp = null; } if (TitlePopUp != null) { TitlePopUp.Dispose(); TitlePopUp = null; } }
public async Task <Compilation> RunAsync() { /*Task.Run(() => * { * while (true) * { * if (Console.KeyAvailable) isComposingCommand = true; * Thread.Sleep(50); * } * }).GetAwaiter();*/ //CSharpCompilation previousScriptCompilation = null; //if (script.Previous != null) //{ // previousScriptCompilation = (CSharpCompilation)script.Previous.GetCompilation(); //} //DiagnosticBag instance = DiagnosticBag.GetInstance(); //ImmutableArray<MetadataReference> referencesForCompilation = default(ImmutableArray<MetadataReference>); //= script.GetReferencesForCompilation(MessageProvider.Instance, instance, null); //instance.Free(); // SyntaxTree syntaxTree = SyntaxFactory.ParseSyntaxTree(script.Code, CSharpScriptCompiler.s_defaultOptions, script.Options.FilePath, null, default(CancellationToken)); //string assemblyName; //string scriptClassName; //script.GenerateSubmissionId(out assemblyName, out scriptClassName); //return CSharpCompilation.CreateScriptCompilation(, syntaxTree, referencesForCompilation, new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, false, null, null, scriptClassName, script.Options.Imports, OptimizationLevel.Debug, false, true, null, null, default(ImmutableArray<byte>), null, Platform.AnyCpu, ReportDiagnostic.Default, 4, null, true, false, null, script.Options.SourceResolver, script.Options.MetadataResolver, DesktopAssemblyIdentityComparer.Default, null, false), previousScriptCompilation, script.ReturnType, script.GlobalsType); var cancellationToken = CancellationToken.None; // var compiler = CSharpInteractiveCompilerCtor(null, Directory.GetCurrentDirectory(), Path.GetDirectoryName(typeof(int).GetTypeInfo().Assembly.Location), Array.Empty<string>(), new NotImplementedAnalyzerLoader()); var box = new StateBox(); object prevResult = null; box.options = Options; while (true) { Console.Write("> "); var input = new StringBuilder(); string line; bool cancelSubmission = false; var globalsType = typeof(InteractiveScriptGlobals <>).MakeGenericType(prevResult?.GetType() ?? typeof(object)); var globals = (InteractiveScriptGlobals)Activator.CreateInstance(globalsType, Console.Out, CSharpObjectFormatter.Instance, prevResult); //var globals = new InteractiveScriptGlobals(Console.Out, CSharpObjectFormatter.Instance); while (true) { line = await Task.Run(() => ReadLine()); if (line == null) { if (input.Length == 0) { return(null); } cancelSubmission = true; break; } input.AppendLine(line); var tree = ParseSubmission(SourceText.From(input.ToString()), cancellationToken); if (SyntaxFactory.IsCompleteSubmission(tree)) { break; } Console.Write(". "); } if (cancelSubmission) { continue; } string code = input.ToString(); Script <object> newScript; if (box.state == null) { newScript = ScriptCreateInitialScript(CSharpScriptCompilerGetInstance(), code, box.options, globals.GetType(), null); } else { newScript = box.state.Script.ContinueWith(code, box.options); } if (!await TryBuildAndRun(newScript, globals, box, cancellationToken)) { continue; } if (CompilationHasSubmissionResult(newScript.GetCompilation())) { prevResult = box.state.ReturnValue; globals.Print(box.state.ReturnValue); } } }
private async Task <bool> TryBuildAndRun(Script <object> newScript, InteractiveScriptGlobals globals, StateBox box, CancellationToken cancellationToken) { var diagnostics = newScript.Compile(cancellationToken); DisplayDiagnostics(diagnostics); if (HasAnyErrors(diagnostics)) { return(false); } try { var task = (box.state == null) ? (Task <ScriptState <object> >)newScript.RunAsync(globals, cancellationToken) : (Task <ScriptState <object> >)ScriptContinueAsync(newScript, box.state, cancellationToken); box.state = await task; } catch (FileLoadException e) when(e.InnerException?.GetType().Name == "InteractiveAssemblyLoaderException") { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(e.InnerException.Message); Console.ResetColor(); return(false); } catch (Exception e) { DisplayException(e); return(false); } // options = UpdateOptions(options, globals); return(true); }