private int ValidationImplementing() { List <string> formText = new List <string>(); formText.Add(number.Text); formText.Add(serialBefore.Text); formText.Add(name.Text); formText.Add(birthDate.Text); List <TextBox> boxes = new List <TextBox>(); boxes.Add(number); boxes.Add(serialBefore); boxes.Add(name); boxes.Add(birthDate); int count = 0; for (int i = 0; i < formText.Count; i++) { if (string.IsNullOrEmpty(formText[i])) { boxes[i].Background = Brushes.Red; InfoBox.Clear(); InfoBox.Text = "Заполните отмеченное поле ввода."; count++; } } return(count); }
private void UpdateInfoBox() { InfoBox.Clear(); InfoBox.AppendText(" A: 0x" + Program.Emulator.Processor.A.ToString("X2") + " "); InfoBox.AppendText(" F: 0x" + Program.Emulator.Processor.F.ToString("X2") + " (" + Program.Emulator.Processor.ZeroFlag.ToString() + Program.Emulator.Processor.SubtractFlag.ToString() + Program.Emulator.Processor.HalfCarryFlag.ToString() + Program.Emulator.Processor.CarryFlag.ToString() + ")" + "\n"); InfoBox.AppendText(" B: 0x" + Program.Emulator.Processor.B.ToString("X2") + " "); InfoBox.AppendText(" C: 0x" + Program.Emulator.Processor.C.ToString("X2") + "\n"); InfoBox.AppendText(" D: 0x" + Program.Emulator.Processor.D.ToString("X2") + " "); InfoBox.AppendText(" E: 0x" + Program.Emulator.Processor.E.ToString("X2") + "\n"); InfoBox.AppendText(" H: 0x" + Program.Emulator.Processor.H.ToString("X2") + " "); InfoBox.AppendText(" L: 0x" + Program.Emulator.Processor.L.ToString("X2") + "\n"); InfoBox.AppendText("-----------------------------\n"); InfoBox.AppendText("PC: 0x" + Program.Emulator.Processor.PC.ToString("X4") + " "); InfoBox.AppendText("SP: 0x" + Program.Emulator.Processor.SP.ToString("X4") + "\n"); InfoBox.AppendText("OP: " + Program.Emulator.CurrentOPcode.ToString("X2") + " " + Program.Emulator.Disassembler.DisassembleMemoryAddress( ref Program.Emulator.Memory, Program.Emulator.Processor.PC) + "\n"); InfoBox.AppendText("-----------------------------\n"); InfoBox.AppendText("IE: " + ByteToBits(Program.Emulator.Memory.Data[0xFFFF]) + " "); InfoBox.AppendText("IF: " + ByteToBits(Program.Emulator.Memory.Data[0xFF0F]) + "\n"); InfoBox.AppendText("IME: " + Program.Emulator.Processor.IME + "\n"); }
/// <summary> /// Prints the information from the specfic list into the richtextbox(infobox) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SelectableTaskList_SelectedIndexChanged(object sender, EventArgs e) { InfoBox.Clear(); int selectedIndex = SelectableTaskList.SelectedIndex; if (selectedIndex != -1) { switch (taskDisplayDropdown.SelectedIndex) { //Current case 0: InfoBox.Text = currentTasks[selectedIndex].ToString(); break; //Previous case 1: InfoBox.Text = previousTasks[selectedIndex].ToString(); break; //Upcoming case 2: InfoBox.Text = upcomingTasks[selectedIndex].ToString(); break; } } }
private void OperationPlus_Click(object sender, EventArgs e) { Increase(); InfoBox.Clear(); InfoBox.Text = "RgA: "; RgCBox.Clear(); for (int i = 0; i < RgABox.Text.Length; i++) { InfoBox.Text = InfoBox.Text + RgABox.Text[i]; if (i == 0) { InfoBox.Text = InfoBox.Text + ','; } } InfoBox.Text = InfoBox.Text + "\r\n"; InfoBox.Text = InfoBox.Text + "RgB: "; for (int i = 0; i < RgBBox.Text.Length; i++) { InfoBox.Text = InfoBox.Text + RgBBox.Text[i]; if (i == 0) { InfoBox.Text = InfoBox.Text + ','; } } InfoBox.Text = InfoBox.Text + "\r\n"; InfoBox.Text = InfoBox.Text + "Operation +" + "\r\n" + "\r\n"; Calculations.Copy(RgABox.Text); Calculations.Copy(RgBBox.Text); int[] check = new int[16] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; if ((Calculations.rg_a[0] == 1) && (!Equals(Calculations.rg_a, check))) { Calculations.Inverse(Calculations.rg_a); } if ((Calculations.rg_b[0] == 1) && (!Equals(Calculations.rg_b, check))) { Calculations.Inverse(Calculations.rg_b); } Plus(); if (!Calculations.overflow) { for (int i = 0; i < 16; i++) { RgCBox.Text = RgCBox.Text + Convert.ToString(Calculations.rg_c[i]); if (i == 0) { RgCBox.Text = RgCBox.Text + ','; } } } else { InfoBox.Text = InfoBox.Text + "Возникло переполнение!"; } }
/// <summary> /// Moves task from either current Task list or upcoming Task list into previous Task list and /// Prints "Good Job!" when user completes. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void CompleteTask_Click(object sender, EventArgs e) { //Takes task from either upcoming task or current task and deletes from those lists //Then adds it to previous switch (taskDisplayDropdown.SelectedIndex) { //Current case 0: if (SelectableTaskList.SelectedItem == null) { InfoBox.Text = "Removed!"; } else if (SelectableTaskList.SelectedItem != null && currentTasks.Any()) { int selectedIndex = SelectableTaskList.SelectedIndex; previousTasks.Add(currentTasks[selectedIndex]); currentTasks.RemoveAt(selectedIndex); SelectableTaskList.Items.RemoveAt(selectedIndex); InfoBox.Text = "Great Job!"; } else { InfoBox.Clear(); } break; //Previous case 1: break; //Upcoming case 2: if (SelectableTaskList.SelectedItem == null) { InfoBox.Text = "Removed!"; } else if (SelectableTaskList.SelectedItem != null && upcomingTasks.Any()) { int selectedIndex = SelectableTaskList.SelectedIndex; previousTasks.Add(upcomingTasks[selectedIndex]); upcomingTasks.RemoveAt(selectedIndex); SelectableTaskList.Items.RemoveAt(selectedIndex); InfoBox.Text = "Great Job!"; } else { InfoBox.Clear(); } break; } }
private void On_SerialChanging(object sender, RoutedEventArgs e) { bool error = false; try { int count = ValidationImplementing(); if (count > 0) { throw new ArgumentException("Заполните отмеченное поле ввода."); } } catch (ArgumentException ex) { InfoBox.Clear(); InfoBox.Text = ex.Message; error = true; } if (!error) { string NUMBER = number.Text; string SERIAL = serialAfetr.Text; string SerialBefore = serialBefore.Text; bool resultFromPolicyRegistry = false; bool resultFromPolicyBodyChanging = false; Guid policyID = VirtuDB.PolicyIDGetter(NUMBER, SerialBefore); bool resultFromDocumentDataDB = VirtuDB.SERIALInDocumentDataUpdating(policyID, SERIAL); if (resultFromDocumentDataDB) { resultFromPolicyRegistry = VirtuDB.SERIALInPolicyRegistryUpdating(policyID, SERIAL); } if (resultFromPolicyRegistry) { resultFromPolicyBodyChanging = VirtuDB.SERIALInPolicyBodyChanging(NUMBER, SERIAL, policyID); } if (resultFromPolicyRegistry && resultFromPolicyBodyChanging && resultFromDocumentDataDB) { InfoBox.Clear(); InfoBox.Text = "Серия полиса была успешна изменена"; } else { InfoBox.Clear(); InfoBox.Text = "Попытка изменения серии завершилась неудачей."; } } }
private void On_VipVerification(object sender, RoutedEventArgs e) { bool error = false; try { int count = ValidationImplementing(); if (count > 0) { throw new ArgumentException("Заполните отмеченное поле ввода."); } } catch (ArgumentException ex) { InfoBox.Clear(); InfoBox.Text = ex.Message; error = true; } if (!error) { string Name = name.Text; Guid vipID = default(Guid); if (string.IsNullOrEmpty(Name)) { InfoBox.Clear(); InfoBox.Text = "Основное поле Фамилия Имя Застрахованного не должно быть пустым"; } else { vipID = VirtuDB.VipIDGetter(Name); } if (vipID != null && vipID != default(Guid)) { InfoBox.Clear(); InfoBox.Text = "Застрахованный значится как ВИП"; } else { InfoBox.Clear(); InfoBox.Text = "Застрахованный не значится как ВИП"; } } }
private void On_BirthDateChanging(object sender, RoutedEventArgs e) { bool error = false; try { int count = ValidationImplementing(); if (count > 0) { throw new ArgumentException("Заполните отмеченное поле ввода."); } } catch (ArgumentException ex) { InfoBox.Clear(); InfoBox.Text = ex.Message; error = true; } if (!error) { bool result = false; string NUMBER = number.Text; string SerialBefore = serialBefore.Text; string newBirthDate = birthDateAfter.Text; string oldBirthDate = birthDate.Text; string Name = name.Text; Guid policyID = VirtuDB.PolicyIDGetter(NUMBER, SerialBefore); result = VirtuDB.BirthDateChanging(policyID, newBirthDate, Name, oldBirthDate); if (result) { InfoBox.Clear(); InfoBox.Text = "Изменение Даты Рождения прошло успешно."; } else { InfoBox.Clear(); InfoBox.Text = "Попытка изменения Даты Рождения завершилась неудачей."; } } }
private void On_VipDBAdd(object sender, RoutedEventArgs e) { bool error = false; try { int count = ValidationImplementing(); if (count > 0) { throw new ArgumentException("Заполните отмеченное поле ввода."); } } catch (ArgumentException ex) { InfoBox.Clear(); InfoBox.Text = ex.Message; error = true; } if (!error) { bool result = false; string Name = name.Text; string BirthDate = birthDate.Text; result = VirtuDB.AddToRGS_Travel_Vip(Name, BirthDate); if (result) { InfoBox.Clear(); InfoBox.Text = "Застрахованный был успешно добавлен в RGS_Travel_VIP"; } else { InfoBox.Clear(); InfoBox.Text = "Попытка добавления в RGS_Travel_VIP завершилась неудачей. Новая запись не добавлена." + "Проверьте формат ввода поля < Дата рождения >."; } } }
private void On_FromInsuredListDelete(object sender, RoutedEventArgs e) { bool error = false; try { int count = ValidationImplementing(); if (count > 0) { throw new ArgumentException("Заполните отмеченное поле ввода."); } } catch (ArgumentException ex) { InfoBox.Clear(); InfoBox.Text = ex.Message; error = true; } if (!error) { string NUMBER = number.Text; string SerialBefore = serialBefore.Text; string NameToDelete = personToDelete.Text; Guid policyID = VirtuDB.PolicyIDGetter(NUMBER, SerialBefore); bool result = VirtuDB.FromInsuredListDelete(policyID, NameToDelete); if (result) { InfoBox.Clear(); InfoBox.Text = "Застрахованный был удален из списка."; } else { InfoBox.Clear(); InfoBox.Text = "Попытка удаления Застрахованного из списка завершилась неудачей."; } } }
private void On_VIPPropertyAdd(object sender, RoutedEventArgs e) { bool error = false; try { int count = ValidationImplementing(); if (count > 0) { throw new ArgumentException("Заполните отмеченное поле ввода."); } } catch (ArgumentException ex) { InfoBox.Clear(); InfoBox.Text = ex.Message; error = true; } if (!error) { string NUMBER = number.Text; string SerialBefore = serialBefore.Text; string Name = name.Text; string BirthDate = birthDate.Text; Guid policyID = VirtuDB.PolicyIDGetter(NUMBER, SerialBefore); bool result = VirtuDB.AddSingleVipProperty(policyID, Name, BirthDate); if (result) { InfoBox.Clear(); InfoBox.Text = "Добавление признака прошло успешно"; } else { InfoBox.Clear(); InfoBox.Text = "Попытка добавления признака закончилась неудачей."; } } }
private void On_VIPPropertyDelete(object sender, RoutedEventArgs e) { bool error = false; try { int count = ValidationImplementing(); if (count > 0) { throw new ArgumentException("Заполните отмеченное поле ввода."); } } catch (ArgumentException ex) { InfoBox.Clear(); InfoBox.Text = ex.Message; error = true; } if (!error) { string NUMBER = number.Text; string SerialBefore = serialBefore.Text; string Name = personToDelete.Text; Guid policyID = VirtuDB.PolicyIDGetter(NUMBER, SerialBefore); bool result = VirtuDB.DeleteVipPropertyInPolicyBody(policyID); if (result) { InfoBox.Clear(); InfoBox.Text = "Удаление признака прошло успешно"; } else { InfoBox.Clear(); InfoBox.Text = "Попытка удаления признака закончилась неудачей. Одна из возможных причин: признак в теле полиса не существует."; } } }
private void On_VipBDDelete(object sender, RoutedEventArgs e) { bool error = false; try { int count = ValidationImplementing(); if (count > 0) { throw new ArgumentException("Заполните отмеченное поле ввода."); } } catch (ArgumentException ex) { InfoBox.Clear(); InfoBox.Text = ex.Message; error = true; } if (!error) { bool result = false; string Name = name.Text; string BirthDate = birthDate.Text; result = VirtuDB.DeleteFromRGS_Travel_VIP(Name, BirthDate); if (result) { InfoBox.Clear(); InfoBox.Text = "Удаление записи прошло успешно"; } else { InfoBox.Clear(); InfoBox.Text = "Удаление записи завершилось неудачно. Запись не удалена."; } } }
private void OperationPlus_Click(object sender, EventArgs e) { Increase(); InfoBox.Clear(); InfoBox.Text = "RgA: "; RgCBox.Clear(); for (int i = 0; i < RgABox.Text.Length; i++) { InfoBox.Text = InfoBox.Text + RgABox.Text[i]; if (i == 0) { InfoBox.Text = InfoBox.Text + ','; } } InfoBox.Text = InfoBox.Text + "\r\n"; InfoBox.Text = InfoBox.Text + "RgB: "; for (int i = 0; i < RgBBox.Text.Length; i++) { InfoBox.Text = InfoBox.Text + RgBBox.Text[i]; if (i == 0) { InfoBox.Text = InfoBox.Text + ','; } } InfoBox.Text = InfoBox.Text + "\r\n"; InfoBox.Text = InfoBox.Text + "Operation +" + "\r\n" + "\r\n"; Calculations.Copy(RgABox.Text); Calculations.Copy(RgBBox.Text); //Для модифицированного кода if (Calculations.rg_a[1] == 1) { Calculations.rg_a[0] = 1; } else { Calculations.rg_a[0] = 0; } if (Calculations.rg_b[1] == 1) { Calculations.rg_b[0] = 1; } else { Calculations.rg_b[0] = 0; } InfoBox.Text = InfoBox.Text + "Обратный модифицированный код:" + "\r\n"; for (int i = 0; i < Calculations.rg_a.Length; i++) { InfoBox.Text = InfoBox.Text + Convert.ToString(Calculations.rg_a[i]); if (i == 1) { InfoBox.Text = InfoBox.Text + ','; } } InfoBox.Text = InfoBox.Text + "\r\n"; for (int i = 0; i < Calculations.rg_b.Length; i++) { InfoBox.Text = InfoBox.Text + Convert.ToString(Calculations.rg_b[i]); if (i == 1) { InfoBox.Text = InfoBox.Text + ','; } } InfoBox.Text = InfoBox.Text + "\r\n" + "\r\n"; //Концовка модифицированного кода int[] check = new int[17] { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; if ((Calculations.rg_a[0] == 1) && (!Equals(Calculations.rg_a, check))) { Calculations.Inverse(Calculations.rg_a); } if ((Calculations.rg_b[0] == 1) && (!Equals(Calculations.rg_b, check))) { Calculations.Inverse(Calculations.rg_b); } Plus(); if (!Calculations.not_right) { for (int i = 1; i < 17; i++) { RgCBox.Text = RgCBox.Text + Convert.ToString(Calculations.rg_c[i]); if (i == 1) { RgCBox.Text = RgCBox.Text + ','; } } } else { InfoBox.Text = InfoBox.Text + "Возникло переполнение!"; } }
/// <summary> /// Event Handler For btn_"Получить название Родительского продукта" /// </summary> /// <param name="sender">btn5</param> /// <param name="e"></param> private void On_ParentIDReceiving(object sender, RoutedEventArgs e) { bool error = false; try { int count = ValidationImplementing(); if (count > 0) { throw new ArgumentException("Заполните отмеченное поле ввода."); } } catch (ArgumentException ex) { InfoBox.Clear(); InfoBox.Text = ex.Message; error = true; } if (!error) { string Number = number.Text; Guid ProductID = VirtuDB.ProductIDGetter(Number); List <ObjectTreeItem> parentList = new List <ObjectTreeItem>(); parentList = VirtuDB.ParentProductIDGetter(ProductID); if (ProductID != null) { productID.Clear(); productID.Text = ProductID.ToString(); } else { InfoBox.Clear(); InfoBox.Text = "Неудалось извлечь значение ID продукта."; } if (parentList == null) { InfoBox.Clear(); InfoBox.Text = "Операция завершилась неудачей"; } else { int count = parentList.Count <ObjectTreeItem>(); switch (count) { case 0: parentProductName.Clear(); parentProductName.Text = "Операция завершилась неудачей"; break; case 1: parentProductName.Clear(); parentProductName.Text = "Родительский продукт: " + parentList[0].Name; break; default: parentProductName.Clear(); parentProductName.Text = "Родительский продукт: " + parentList[1].Name; break; } InfoBox.Clear(); InfoBox.AppendText("Иерархия продукта:\r\n"); foreach (ObjectTreeItem item in parentList) { InfoBox.AppendText(item.DisplayName + "\r\n"); } } } }
/// <summary> /// Sees what index on the combobox is selected to determine which listbox we are viewing. /// Adding the specific text files based on comobox. /// Populating the listboxes with our textfile and sorting it based on date and then priority. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void TaskListDropdown_SelectedIndexChanged(object sender, EventArgs e) { int selectedIndex = taskDisplayDropdown.SelectedIndex; //Clear box InfoBox.Clear(); SelectableTaskList.Items.Clear(); //Current Tasks if (selectedIndex == 0) { //Allow complete task button CompleteTaskButton.Enabled = true; //Sort current tasks currentTasks.Sort(); //Print current tasks to box List <string> cnames = new List(); foreach (Task t in currentTasks) { cnames.Add(t.Name); } SelectableTaskList.Items.AddRange(cnames.ToArray()); } //Previous Tasks if (selectedIndex == 1) { //Disallow complete task button CompleteTaskButton.Enabled = false; //Sort tasks previousTasks.Sort(); //Print items to box List <string> pnames = new List(); foreach (Task t in previousTasks) { pnames.Add(t.Name); } SelectableTaskList.Items.AddRange(pnames.ToArray()); } //Upcoming Tasks if (selectedIndex == 2) { //Allow complete task button CompleteTaskButton.Enabled = true; //Sort upcoming tasks upcomingTasks.Sort(); //Print tasks to info box List <string> unames = new List(); foreach (Task t in upcomingTasks) { unames.Add(t.Name + " : " + t.dt.ToShortDateString()); } SelectableTaskList.Items.AddRange(unames.ToArray()); } }
private void txtClear_Click(object sender, EventArgs e) { InfoBox.Clear(); }