private void ClearTextBoxes() { TextBoxGameName.Clear(); TextBoxRating.Clear(); TextBoxPrice.Clear(); TextBoxGenre.Clear(); TextBoxConsole.Clear(); }
private void SearchInventoryBtn_Click(object sender, EventArgs e) { string searchId = textBoxSearch.Text.Trim(); Book book = dbEntities.Books.Find(searchId); if (book != null) { comboBoxISBN.Text = book.ISBN; textBoxTitle.Text = book.Title; TextBoxPrice.Text = book.Price.ToString(); textBoxQOH.Text = book.QoH.ToString(); textBoxYear.Text = book.Year.ToString(); comboBoxPublisher.Text = book.PId.ToString(); comboBoxSupplier.Text = book.SId.ToString(); comboBoxAuthorID.Text = book.AuthorId.ToString(); } else { var listBook = dbEntities.Books.Where(tl => tl.Title == textBoxSearch.Text).ToList <Book>(); // if (listEmp != null) :Problem if (listBook.Count != 0) { foreach (var bk in listBook) { //MessageBox.Show( bk.ISBN.ToString()+ ", " + bk.Title.ToString() // + ", " + bk.Price.ToString()); ListViewProduct.Items.Clear(); comboBoxISBN.ResetText(); textBoxTitle.Clear(); TextBoxPrice.Clear(); textBoxQOH.Clear(); textBoxYear.Clear(); comboBoxPublisher.ResetText(); comboBoxSupplier.ResetText(); comboBoxAuthorID.ResetText(); ListViewItem item = new ListViewItem(bk.ISBN); item.SubItems.Add(bk.Title); item.SubItems.Add(bk.Price.ToString()); item.SubItems.Add(bk.QoH.ToString()); item.SubItems.Add(bk.Year.ToString()); item.SubItems.Add(bk.PId.ToString()); item.SubItems.Add(bk.SId.ToString()); item.SubItems.Add(bk.AuthorId.ToString()); ListViewProduct.Items.Add(item); } } else { MessageBox.Show("ISBN or Title not exist in the DB", "Warning"); } } }
private void ButtonReset_Click(object sender, EventArgs e) { TextBoxName.ResetText(); TextBoxPrice.ResetText(); TextBoxQuantity.ResetText(); TextBoxVolume.ResetText(); ComboBoxMedType.SelectedIndex = -1; ComboBoxUsesType.SelectedIndex = -1; ComboBoxManufType.SelectedIndex = -1; CheckBoxFilterTime.Checked = false; CheckBoxPrepTime.Checked = false; TextBoxPrepTime.ResetText(); TextBoxFiltrationTime.ResetText(); TextBoxMixableList.ResetText(); this.Refresh(); }
private void ButtonOK_Click(object sender, EventArgs e) { if (MessageBox.Show("确认修改?", "消息", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { try { if (GlobalClass.Connection.State == ConnectionState.Open) { GlobalClass.Connection.Close(); } GlobalClass.Connection.Open(); if (Regex.IsMatch(TextBoxPrice.Text, @"\d+")) { SqlCommand SalaryRiseCmd = new SqlCommand("SalaryRise", GlobalClass.Connection); SalaryRiseCmd.CommandType = CommandType.StoredProcedure; SalaryRiseCmd.Parameters.Add("@Class", SqlDbType.NChar, 6); SalaryRiseCmd.Parameters.Add("@Salary", SqlDbType.Int); SalaryRiseCmd.Parameters[0].Value = LabelClass.Text; SalaryRiseCmd.Parameters[1].Value = Convert.ToInt32(TextBoxPrice.Text); if (SalaryRiseCmd.ExecuteNonQuery() == 1) { MessageBox.Show("涨薪成功!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("涨薪失败!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("输入不合法!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Error); TextBoxPrice.Text = String.Empty; TextBoxPrice.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "消息", MessageBoxButtons.OK, MessageBoxIcon.Error); GlobalClass.Connection.Close(); } } }
private void ButtonAcceptId_Click(object sender, EventArgs e) { //if (connectionType == ConnectionTypes.Connected) //{ //} int id = Convert.ToInt32(NumericId.Value); string query = Commands.SelectMedicationsWhereId(id); string[] data = new string[11]; ConnectedData.SetCommand(query); bool status = ConnectedData.CheckExist(); if (status == true) { TextBoxStatusId.Text = "Выбрано"; TextBoxStatusId.ForeColor = Color.Green; ButtonUpdate.Enabled = true; TextBoxName.Enabled = true; TextBoxPrice.Enabled = true; TextBoxQuantity.Enabled = true; TextBoxVolume.Enabled = true; ComboBoxMedType.Enabled = true; ComboBoxUsesType.Enabled = true; ComboBoxManufType.Enabled = true; CheckBoxPrepTime.Enabled = true; CheckBoxFilterTime.Enabled = true; ConnectedData.SetCommand(query); data = ConnectedData.GetRowFromTable(); TextBoxName.Text = data[1]; double price = Convert.ToDouble(data[2]); TextBoxPrice.Text = Math.Round(price, 2).ToString(); TextBoxQuantity.Text = data[3]; TextBoxVolume.Text = data[4]; if (data[5] == "1") { ComboBoxUsesType.SelectedIndex = 0; } else if (data[5] == "2") { ComboBoxUsesType.SelectedIndex = 1; } if (data[6] == "1") { ComboBoxManufType.SelectedIndex = 0; } else if (data[6] == "2") { ComboBoxManufType.SelectedIndex = 1; } else if (data[6] == "4") { ComboBoxManufType.SelectedIndex = 2; } if (data[7] == "1") { ComboBoxMedType.SelectedIndex = 0; } else if (data[7] == "2") { ComboBoxMedType.SelectedIndex = 1; } else if (data[7] == "3") { ComboBoxMedType.SelectedIndex = 2; } else if (data[7] == "4") { ComboBoxMedType.SelectedIndex = 3; } else if (data[7] == "5") { ComboBoxMedType.SelectedIndex = 4; } else if (data[7] == "1002") { ComboBoxMedType.SelectedIndex = 5; } else if (data[7] == "1003") { ComboBoxMedType.SelectedIndex = 6; } TextBoxMixableList.Text = data[8]; TextBoxPrepTime.Text = data[9]; TextBoxFiltrationTime.Text = data[10]; if (ComboBoxManufType.SelectedIndex == 2) { TextBoxMixableList.Enabled = true; } else { TextBoxMixableList.ResetText(); TextBoxMixableList.Enabled = false; } if (TextBoxPrepTime.Text == "-") { CheckBoxPrepTime.Checked = false; TextBoxPrepTime.ResetText(); TextBoxPrepTime.Enabled = false; } else { CheckBoxPrepTime.Checked = true; TextBoxPrepTime.Enabled = true; } if (TextBoxFiltrationTime.Text == "-") { CheckBoxFilterTime.Checked = false; TextBoxFiltrationTime.ResetText(); TextBoxFiltrationTime.Enabled = false; } else { CheckBoxFilterTime.Checked = true; TextBoxFiltrationTime.Enabled = true; } this.Refresh(); } else { TextBoxStatusId.Text = "Не выбрано"; TextBoxStatusId.ForeColor = Color.Red; TextBoxName.ResetText(); TextBoxPrice.ResetText(); TextBoxQuantity.ResetText(); TextBoxVolume.ResetText(); ComboBoxMedType.SelectedIndex = -1; ComboBoxUsesType.SelectedIndex = -1; ComboBoxManufType.SelectedIndex = -1; CheckBoxFilterTime.Checked = false; CheckBoxPrepTime.Checked = false; TextBoxPrepTime.ResetText(); TextBoxFiltrationTime.ResetText(); TextBoxMixableList.ResetText(); ButtonUpdate.Enabled = false; TextBoxName.Enabled = false; TextBoxPrice.Enabled = false; TextBoxQuantity.Enabled = false; TextBoxVolume.Enabled = false; ComboBoxMedType.Enabled = false; ComboBoxUsesType.Enabled = false; ComboBoxManufType.Enabled = false; CheckBoxPrepTime.Enabled = false; CheckBoxFilterTime.Enabled = false; TextBoxPrepTime.Enabled = false; TextBoxFiltrationTime.Enabled = false; TextBoxMixableList.Enabled = false; this.Refresh(); MessageBox.Show("Лекарства с таким id не существует!"); } }