private void EditButton_Click(object sender, EventArgs e) { try { string title = Convert.ToString(this.тип_ТовараDataGridView.CurrentRow.Cells[1].Value); int id = Convert.ToInt32(this.тип_ТовараDataGridView.CurrentRow.Cells[0].Value); ДобавитьИзменитьТип f = new ДобавитьИзменитьТип(title, id); f.ShowDialog(); this.тип_ТовараTableAdapter.Fill(this.bookWorldDataSet.Тип_Товара); } catch (Exception ex) { StaticHelper.ErrorNotifier(ex); } }
private void SaveButton_Click(object sender, EventArgs e) { try { Properties.Settings.Default.Percentage = Convert.ToDecimal(PercentageTextBox.Text); Properties.Settings.Default.Discount = Convert.ToDouble(DiscountTextBox.Text); Properties.Settings.Default.Save(); MessageBox.Show("Данные успешно изменены"); PercentageCheckBox.Checked = false; DiscountCheckBox.Checked = false; } catch (Exception ex) { StaticHelper.ErrorNotifier(ex); } }
private void EditButton_Click(object sender, EventArgs e) { try { int cardNumber = Convert.ToInt32(постоянные_КлиентыDataGridView.CurrentRow.Cells[0].Value); string fio = Convert.ToString(постоянные_КлиентыDataGridView.CurrentRow.Cells[1].Value); string phoneNumber = Convert.ToString(постоянные_КлиентыDataGridView.CurrentRow.Cells[3].Value); ДобавитьИзменитьКлиента f = new ДобавитьИзменитьКлиента(cardNumber, fio, phoneNumber); f.ShowDialog(); this.постоянные_КлиентыTableAdapter.Fill(this.bookWorldDataSet.Постоянные_Клиенты); } catch (Exception ex) { StaticHelper.ErrorNotifier(ex); } }
private void AddLineToCheque() { try { int codeOfGood = Convert.ToInt32(товарыdataGridView.CurrentRow.Cells[0].Value); string title = Convert.ToString(товарыdataGridView.CurrentRow.Cells[3].Value); decimal price = Convert.ToDecimal(товарыdataGridView.CurrentRow.Cells[4].Value); int amount = Convert.ToInt32(AmountNumericUpDown.Value); cheque.Rows.Add(codeOfGood, title, price, amount, price * amount); чекdataGridView.DataSource = cheque; } catch (Exception ex) { StaticHelper.ErrorNotifier(ex); } }
private void AddButton_Click(object sender, EventArgs e) { if (TitleTextBox.Text.Length < 2) { MessageBox.Show("Слишком короткое название"); } else { DataRow dr = bookWorldDataSet.Tables["Тип_Товара"].NewRow(); dr["Наименование"] = TitleTextBox.Text; if (Status == 0) { try { bookWorldDataSet.Tables["Тип_Товара"].Rows.Add(dr); this.Validate(); this.tableAdapterManager.UpdateAll(this.bookWorldDataSet); MessageBox.Show("Запись успешно добавлена"); this.Dispose(); } catch (Exception ex) { StaticHelper.ErrorNotifier(ex); TitleTextBox.Clear(); TitleTextBox.Focus(); } } else { try { тип_ТовараTableAdapter.Update(TitleTextBox.Text, ID, Title); this.Validate(); this.tableAdapterManager.UpdateAll(bookWorldDataSet); MessageBox.Show("Запись успешно изменена"); this.Dispose(); } catch (Exception ex) { StaticHelper.ErrorNotifier(ex); } } } }
private void EditButton_Click(object sender, EventArgs e) { try { int codeOfWorker = Convert.ToInt32(сотрудникиDataGridView.CurrentRow.Cells[0].Value); string fio = Convert.ToString(сотрудникиDataGridView.CurrentRow.Cells[1].Value); string hired = Convert.ToString(сотрудникиDataGridView.CurrentRow.Cells[2].Value); string dateOfBirth = Convert.ToString(сотрудникиDataGridView.CurrentRow.Cells[4].Value); string phoneNumber = Convert.ToString(сотрудникиDataGridView.CurrentRow.Cells[5].Value); string title = Convert.ToString(сотрудникиDataGridView.CurrentRow.Cells[6].Value); ДобавитьИзменитьСотрудники f = new ДобавитьИзменитьСотрудники(codeOfWorker, fio, hired, dateOfBirth, phoneNumber, title); f.ShowDialog(); сотрудникиTableAdapter.Fill(this.bookWorldDataSet.Сотрудники); } catch (Exception ex) { StaticHelper.ErrorNotifier(ex); } }
private void AddButton_Click(object sender, EventArgs e) { try { int codeOfGood = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value); string title = Convert.ToString(dataGridView1.CurrentRow.Cells[3].Value); double priceOfBuy = Convert.ToDouble(BuyPriceNumericUpDown.Value); double priceOfSell = Convert.ToDouble(dataGridView1.CurrentRow.Cells[4].Value); int amount = Convert.ToInt32(AmountNumericUpDown.Value); AddRow(codeOfGood, title, priceOfBuy, priceOfSell, amount); AmountNumericUpDown.Value = 1; BuyPriceNumericUpDown.Value = 0; } catch (Exception ex) { StaticHelper.ErrorNotifier(ex); } }
private void SearchByFioTextBox_TextChanged(object sender, EventArgs e) { //"Select Код_Товара,Тип_Товара,Жанр,Наименование, Цена, Остаток From Товары Where Наименование LIKE '%"+SearchTextBox.Text+"%'"; try { string FullCommandForSearch; if (SearchByFioTextBox.Text == "" || SearchByFioTextBox.Text == " ") { постоянные_КлиентыDataGridView.DataSource = постоянные_КлиентыBindingSource; } else { FullCommandForSearch = CommandForSearch + SearchByFioTextBox.Text + "%'"; StaticProcesser.FillDataGrid(FullCommandForSearch, постоянные_КлиентыDataGridView); } } catch (Exception ex) { StaticHelper.ErrorNotifier(ex); } }
private void DeleteButton_Click(object sender, EventArgs e) { try { string command = "Select Код_Товара FROM Товары Where Жанр=@id"; SqlParameter p1 = new SqlParameter("id", this.жанрыDataGridView.CurrentRow.Cells[0].Value); int amount = StaticProcesser.GetAmountOfRecords(command, p1); if (amount > 0) { MessageBox.Show("Сначала нужно избавиться от всех товаров с этим жанром"); } else { жанрыBindingSource.RemoveCurrent(); this.Validate(); this.tableAdapterManager.UpdateAll(bookWorldDataSet); MessageBox.Show("Запись успешно удалена"); } } catch (Exception ex) { StaticHelper.ErrorNotifier(ex); } }
private void FormDocButton_Click(object sender, EventArgs e) { try { string place = "beginning"; bool hasCard; string Command = "INSERT INTO Продажа (Дата,Сумма_Чека) VALUES (@date,@chequeSum)"; Data.numberOfCard = 0; var result = MessageBox.Show("Спросите есть ли у клиента карта", "Наличие карты", MessageBoxButtons.YesNo); SqlParameter cardNumber = new SqlParameter(); if (result == DialogResult.No) { hasCard = false; } else { СправочникКлиенты f = new СправочникКлиенты(); f.ShowDialog(); if (Data.numberOfCard > 0) { hasCard = true; ApplyDiscount(); Command = "INSERT INTO Продажа (Дата,Номер_Карты,Сумма_Чека) VALUES (@date,@cardNumber,@chequeSum)"; cardNumber = new SqlParameter("cardNumber", Data.numberOfCard); } else { hasCard = false; } } MessageBox.Show("Итоговая стоимость = " + fullcost + " рублей"); SqlParameter date = new SqlParameter("date", DateTime.Now.ToShortDateString()); SqlParameter chequeSum = new SqlParameter("chequeSum", fullcost); if (hasCard) { StaticProcesser.ExecuteCommand(Command, date, cardNumber, chequeSum); } else { StaticProcesser.ExecuteCommand(Command, date, chequeSum); } place = "added head"; Command = "With SRC AS (Select TOP(1) Чек From Продажа ORDER BY Чек DESC) Select Чек FROM SRC"; SqlDataReader reader = StaticProcesser.GetReader(Command); reader.Read(); int chequeNumber = reader.GetInt32(0); StaticProcesser.CloseConnection(); place = "got chequeNumber"; double codeOfGood; double priceOfSell; int amount; string updCommand = "Update Товары SET Остаток=Остаток-@amount Where Код_Товара = @codeOfGood"; Command = "Insert INTO Состав_Продажи (Чек,Код_Товара,Цена,Количество) VALUES (@chequeNumber,@codeOfGood,@priceOfSell,@amount)"; SqlParameter PchequeNumber = new SqlParameter("chequeNumber", chequeNumber); SqlParameter PcodeOfGood; SqlParameter PpriceOfSell; SqlParameter Pamount; for (int i = 0; i < чекdataGridView.Rows.Count; i++) { codeOfGood = Convert.ToInt32(чекdataGridView.Rows[i].Cells[0].Value); PcodeOfGood = new SqlParameter("codeOfGood", codeOfGood); if (hasCard) { priceOfSell = Convert.ToDouble(чекdataGridView.Rows[i].Cells[2].Value) * Properties.Settings.Default.Discount; } else { priceOfSell = Convert.ToDouble(чекdataGridView.Rows[i].Cells[2].Value); } PpriceOfSell = new SqlParameter("priceOfSell", priceOfSell); amount = Convert.ToInt32(чекdataGridView.Rows[i].Cells[3].Value); Pamount = new SqlParameter("amount", amount); StaticProcesser.ExecuteCommand(updCommand, Pamount, PcodeOfGood); StaticProcesser.ExecuteCommand(Command, PchequeNumber, PcodeOfGood, PpriceOfSell, Pamount); place = "Command executed " + i + " times"; } MessageBox.Show("Документ успешно сформирован"); StaticProcesser.FillDataGrid(comForListOfGoods, товарыdataGridView); cheque.Clear(); чекdataGridView.DataSource = cheque; GetFullCost(); Data.numberOfCard = 0; } catch (Exception ex) { StaticHelper.ErrorNotifier(ex); } }
private void FormDocButton_Click(object sender, EventArgs e) { string place = "beginning"; try { string Command = "Insert Into Приход (Дата,Комментарий) VALUES (@date,@comment)"; SqlParameter p1 = new SqlParameter("date", DateTime.Now.ToShortDateString()); SqlParameter p2 = new SqlParameter("comment", CommentRichTextBox.Text); StaticProcesser.ExecuteCommand(Command, p1, p2); place = "added head"; Command = "With SRC AS (Select TOP(1) Номер_Прихода From Приход ORDER BY Номер_Прихода DESC) Select Номер_Прихода FROM SRC"; SqlDataReader reader = StaticProcesser.GetReader(Command); reader.Read(); int incID = reader.GetInt32(0); StaticProcesser.CloseConnection(); place = "got ID"; int codeOfGood; double priceOfBuy; double priceOfSell; int amount; string updCommand = "Update Товары SET Остаток=Остаток + @amount Where Код_Товара = @codeOfGood"; Command = "Insert Into Состав_Прихода (Номер_Прихода,Код_Товара,Количество,Цена_Закупки,Цена_Продажи) VALUES (@id,@codeOfGood,@amount,@priceOfBuy,@priceOfSell)"; SqlParameter id = new SqlParameter("id", incID); SqlParameter PcodeOfGood; SqlParameter PpriceOfBuy; SqlParameter PpriceOfSell; SqlParameter Pamount; for (int i = 0; i < dataGridView2.Rows.Count; i++) { codeOfGood = Convert.ToInt32(dataGridView2.Rows[i].Cells[0].Value); PcodeOfGood = new SqlParameter("codeOfGood", codeOfGood); priceOfBuy = Convert.ToDouble(dataGridView2.Rows[i].Cells[2].Value); PpriceOfBuy = new SqlParameter("priceOfBuy", priceOfBuy); priceOfSell = Convert.ToDouble(dataGridView2.Rows[i].Cells[3].Value); PpriceOfSell = new SqlParameter("priceOfSell", priceOfSell); amount = Convert.ToInt32(dataGridView2.Rows[i].Cells[4].Value); Pamount = new SqlParameter("amount", amount); StaticProcesser.ExecuteCommand(updCommand, Pamount, PcodeOfGood); StaticProcesser.ExecuteCommand(Command, id, PcodeOfGood, Pamount, PpriceOfBuy, PpriceOfSell); place = "Command executed " + i + " times"; } MessageBox.Show("Документ успешно сформирован"); StaticProcesser.FillDataGrid(GoodsSelectCommand, dataGridView1); IncomingGoodsDataTable.Clear(); dataGridView2.DataSource = IncomingGoodsDataTable; } catch (Exception ex) { MessageBox.Show(place); StaticHelper.ErrorNotifier(ex); } }
private void AddEditButton_Click(object sender, EventArgs e) { try { if (isChange) { if ((PassTextBox.Text == "" || PassTextBox.Text == " ") && (ConfPassTextBox.Text == "" || ConfPassTextBox.Text == " ") && (LoginTextBox.Text != "" || LoginTextBox.Text != " ")) { string Command = "Update Пользователи SET Имя_Пользователя=@login Where Имя_Пользователя=@oldLogin"; SqlParameter newLogin = new SqlParameter("login", LoginTextBox.Text); SqlParameter oldLogin = new SqlParameter("oldLogin", Login); StaticProcesser.ExecuteCommand(Command, newLogin, oldLogin); this.Dispose(); } else { if (PassTextBox.Text == ConfPassTextBox.Text && LoginTextBox.Text != "" && LoginTextBox.Text != " ") { string newhashedPass = StaticProcesser.ComputeHash(PassTextBox.Text, new MD5CryptoServiceProvider()); SqlParameter newLogin = new SqlParameter("login", LoginTextBox.Text); SqlParameter newHashedPass = new SqlParameter("newHashedPass", newhashedPass); SqlParameter oldLogin = new SqlParameter("oldLogin", Login); string Command = "Update Пользователи SET Имя_Пользователя=@login, Пароль=@newHashedPass Where Имя_Пользователя=@oldLogin"; StaticProcesser.ExecuteCommand(Command, newLogin, newHashedPass, oldLogin); this.Dispose(); } } } else { if ((PassTextBox.Text == "" || PassTextBox.Text == " ") && (ConfPassTextBox.Text == "" || ConfPassTextBox.Text == " ") && (LoginTextBox.Text == "" || LoginTextBox.Text == " ")) { MessageBox.Show("Заполните все поля!"); LoginTextBox.Focus(); } else { if (PassTextBox.Text == ConfPassTextBox.Text) { string newhashedPass = StaticProcesser.ComputeHash(PassTextBox.Text, new MD5CryptoServiceProvider()); SqlParameter newLogin = new SqlParameter("login", LoginTextBox.Text); SqlParameter newHashedPass = new SqlParameter("newHashedPass", newhashedPass); string Command = "Insert INTO Пользователи (Имя_Пользователя,Пароль) VALUES (@login,@newHashedPass)"; StaticProcesser.ExecuteCommand(Command, newLogin, newHashedPass); this.Dispose(); } else { PassTextBox.Clear(); ConfPassTextBox.Clear(); PassTextBox.Focus(); MessageBox.Show("Пароли не совпадают!"); } } } } catch (Exception ex) { StaticHelper.ErrorNotifier(ex); } }