Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
курсак.docx
Скачиваний:
1
Добавлен:
01.07.2025
Размер:
356 Кб
Скачать
☆

Висновок

В даній курсовій роботі було створено систему, яка дозволяє спростити роботу служби доставки їжі в ресторанах. Для даного прикладу була взята модель функціонування піцерії. Були реалізовані функції, які дозволяють створювати і опрацьовувати замовлення, обраховувати суму, адмініструвати користувачів системи та кур’єрів, переглядати журнал опрацьованих замовлень, редагувати меню, враховуючи різні додаткові елементи, які впливають на ціну.

Проект було створено з використанням каскадної моделі створення програмних продуктів. На етапі формулювання вимог було поставлено мету , і цілі розробки даного проекту. Також було сформовано , і поставлено вимоги , які на етапі реалізації були виконані.

Отже, даний програмний продукт показав що завдяки поширення нових технологій в різні галузі людської діяльності можна суттєво полегшити роботу, добитися більшого контролю та відповідно більших доходів. На прикладі роботи системи доставки піци можна побачити як поступово інформаційні технології стають все доступнішими.

Перелік використаних джерел

  1. Работа с базами даннях на языке C#. технология АDO.NET: учебное пособие / сост. О. Н. Евсеева, А. Б. Шамшев. – Ульяновск: УлГТУ, 2009. – 170 с.

  2. Базы данных: учеб. пособие для студ. высш. учеб. заведений / А. В.Кузин, С.В.Левонисова. — 5-е изд., испр. — М. центр ≪Академия≫, 2012. — 320 с.

  3. Базы данных : учеб. пособие дли студ. учреждений сред, проф. образования / Э. В.Фуфаев, Д. Э.Фуфаев. — 7-е изд., стер. — М .: Издательский центр «Академия», 2012. — 320 с.

  4. Microsoft SQL Server 2005. Справочник администратора / Пер. с англ. — М.: Издательство «Русская Редакция», 2008. — 544 с.: ил.

  5. Microsoft Visual C# в задачах и примерах. – СПб.: БХВ-Петербург, 2009. – 320с.: ил.

  6. Стаття "Об'єктно-орієнтоване програмування" на сайті вікіпедії.

Додатки

Лістинг коду

using System;

using System.Collections.Generic;

using System.Linq;

using System.Windows.Forms;

namespace Pizzeria

{

static class Program

{

[STAThread]

static void Main()

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

Application.Run(new LoginForm());

}

}

}

using System;

using System.Windows.Forms;

namespace Pizzeria

{

public partial class LoginForm : Form

{

database.login lg = new database.login();

public LoginForm()

{

InitializeComponent();

}

private void login_confirm_Click(object sender, EventArgs e)

{

int user_id = 0;

string user_name = string.Empty;

int user_access_lvl = 0;

string res = string.Empty;

bool is_verified = false;

string pass = tbx_pass.Text;

lg.hash_pass(ref pass);

lg.verify_User(tbx_login.Text.ToLower(), pass, ref user_access_lvl, ref user_id, ref is_verified, ref res);

if (is_verified)

{

MainForm mainForm = new MainForm(user_id, user_access_lvl);

this.Visible = false;

DialogResult main_res = mainForm.ShowDialog();

if (main_res == DialogResult.Retry)

{

tbx_login.Text = string.Empty;

tbx_login.Select();

tbx_pass.Text = string.Empty;

this.Visible = true;

}

else

this.Close();

}

else

{

tbx_pass.Text = String.Empty;

if (res == "Successful")

MessageBox.Show("Cannot find this pair user-password");

else

MessageBox.Show(res);

tbx_pass.Select();

}

}

private void AuthorizationWindow_KeyPress(object sender, KeyPressEventArgs e)

{

if (e.KeyChar == 13) login_confirm_Click(sender, e);

}

private void AuthorizationWindow_Load(object sender, EventArgs e)

{

tbx_login.Select();

}

}

}

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Data.SqlClient;

namespace Pizzeria

{

public partial class MainForm : Form

{

public MainForm(int id, int access_lvl)

{

InitializeComponent();

current_user_id = id;

if (access_lvl < 3)

{

tabControl1.TabPages.Remove(tabControl1.TabPages["tab_menu"]);

tabControl1.TabPages.Remove(tabControl1.TabPages["tab_users"]);

tabControl1.TabPages.Remove(tabControl1.TabPages["tab_couriers"]);

}

else

{

FoodsGridUpdate();

UsersGridUpdate();

CouriersGridUpdate();

}

StateGridUpdate();

HistoryGridUpdate();

}

int current_user_id;

#region State

database.state st = new database.state();

private void StateGridUpdate()

{

t_state.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

string res = string.Empty;

DataTable dt = st.grd_State(ref res);

t_state.DataSource = dt;

t_state.Columns["id"].Visible = false;

t_state.Columns["date"].HeaderText = "Date";

t_state.Columns["name"].HeaderText = "Client name";

t_state.Columns["phone"].HeaderText = "Client phone";

t_state.Columns["address"].HeaderText = "Client address";

t_state.Columns["name1"].HeaderText = "Courier";

t_state.Columns["login"].HeaderText = "Operator";

}

private void HistoryGridUpdate()

{

t_state.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

string res = string.Empty;

DataTable dt = st.grd_History(ref res);

t_history.DataSource = dt;

t_history.Columns["id"].Visible = false;

t_history.Columns["date"].HeaderText = "Date";

t_history.Columns["name"].HeaderText = "Client name";

t_history.Columns["phone"].HeaderText = "Client phone";

t_history.Columns["address"].HeaderText = "Client address";

t_history.Columns["name1"].HeaderText = "Courier";

t_history.Columns["login"].HeaderText = "Operator";

}

private void btn_new_order_Click(object sender, EventArgs e)

{

NewOrderForm neworderForm = new NewOrderForm(current_user_id);

neworderForm.ShowDialog();

StateGridUpdate();

}

private void btn_complete_order_Click(object sender, EventArgs e)

{

string res = string.Empty;

int cur_id = Convert.ToInt32(t_state.CurrentRow.Cells["id"].Value.ToString());

st.finish_transaction(cur_id, 2, ref res);

if (res != "Successful") MessageBox.Show(res);

else MessageBox.Show("Finished");

StateGridUpdate();

HistoryGridUpdate();

}

private void btn_ff_order_Click(object sender, EventArgs e)

{

string res = string.Empty;

int cur_id = Convert.ToInt32(t_state.CurrentRow.Cells["id"].Value.ToString());

st.finish_transaction(cur_id, 3, ref res);

if (res != "Successful") MessageBox.Show(res);

else MessageBox.Show("Finished");

StateGridUpdate();

HistoryGridUpdate();

}

#endregion

#region Menu

database.menu m = new database.menu();

int current_food_id;

private void FoodsGridUpdate()

{

t_menu.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

string res = string.Empty;

DataTable dt = m.grd_Foods(ref res);

t_menu.DataSource = dt;

t_menu.Columns["id"].Visible = false;

t_menu.Columns["name"].HeaderText = "name";

t_menu.Columns["price"].HeaderText = "price";

tbx_food_id.Text = "";

tbx_food_name.Text = "";

tbx_food_price.Text = "";

btn_new_food.Visible = true;

btn_edit_food.Visible = true;

btn_del_food.Visible = true;

btn_confirm_new_food.Visible = false;

btn_confirm_edit_food.Visible = false;

btn_confirm_del_food.Visible = false;

btn_cancel_change_food.Visible = false;

tbx_food_name.ReadOnly = true;

tbx_food_price.ReadOnly = true;

t_menu.Enabled = true;

}

private void t_menu_CellClick(object sender, DataGridViewCellEventArgs e)

{

tbx_food_id.Text = t_menu.CurrentRow.Cells["id"].Value.ToString();

tbx_food_name.Text = t_menu.CurrentRow.Cells["name"].Value.ToString();

tbx_food_price.Text = t_menu.CurrentRow.Cells["price"].Value.ToString();

if (tbx_food_id.Text != "")

{

current_food_id = Int32.Parse(tbx_food_id.Text);

}

AddonsGridUpdate();

}

private void btn_new_food_Click(object sender, EventArgs e)

{

FoodsGridUpdate();

t_menu.Enabled = false;

btn_confirm_new_food.Visible = true;

btn_cancel_change_food.Visible = true;

btn_edit_food.Visible = false;

btn_del_food.Visible = false;

tbx_food_name.ReadOnly = false;

tbx_food_price.ReadOnly = false;

}

private void btn_edit_food_Click(object sender, EventArgs e)

{

if (tbx_food_id.Text == "") return;

t_menu.Enabled = false;

btn_confirm_edit_food.Visible = true;

btn_cancel_change_food.Visible = true;

btn_new_food.Visible = false;

btn_del_food.Visible = false;

tbx_food_name.ReadOnly = false;

tbx_food_price.ReadOnly = false;

}

private void btn_del_food_Click(object sender, EventArgs e)

{

if (tbx_food_id.Text == "") return;

t_menu.Enabled = false;

btn_confirm_del_food.Visible = true;

btn_cancel_change_food.Visible = true;

btn_new_food.Visible = false;

btn_edit_food.Visible = false;

}

private void btn_confirm_new_food_Click(object sender, EventArgs e)

{

string res = string.Empty;

if (tbx_food_name.Text == "" || tbx_food_price.Text == "")

MessageBox.Show("Wrong input");

else

{

m.new_Food(tbx_food_name.Text.ToString(), Double.Parse(tbx_food_price.Text), ref res);

if (res != "Successful") MessageBox.Show(res);

else MessageBox.Show("Added");

}

FoodsGridUpdate();

}

private void btn_confirm_edit_food_Click(object sender, EventArgs e)

{

string res = string.Empty;

if (tbx_food_name.Text == "" || tbx_food_price.Text == "")

MessageBox.Show("Wrong input");

else

m.edit_Food(Int32.Parse(tbx_food_id.Text), tbx_food_name.Text, Double.Parse(tbx_food_price.Text), ref res);

if (res != "Successful") MessageBox.Show(res);

else MessageBox.Show("Edited");

FoodsGridUpdate();

}

private void btn_confirm_del_food_Click(object sender, EventArgs e)

{

string res = string.Empty;

m.del_Food(Int32.Parse(tbx_food_id.Text), ref res);

if (res != "Successful") MessageBox.Show(res);

else MessageBox.Show("Deleted");

FoodsGridUpdate();

}

private void btn_cancel_change_food_Click(object sender, EventArgs e)

{

FoodsGridUpdate();

}

#endregion

#region Addons

private void AddonsGridUpdate()

{

t_addons.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

string res = string.Empty;

DataTable dt = m.grd_Addons(current_food_id ,ref res);

t_addons.DataSource = dt;

t_addons.Columns["id"].Visible = false;

t_addons.Columns["name"].HeaderText = "name";

t_addons.Columns["price"].HeaderText = "price";

tbx_addon_id.Text = "";

tbx_addon_name.Text = "";

tbx_addon_price.Text = "";

btn_new_addon.Visible = true;

btn_edit_addon.Visible = true;

btn_del_addon.Visible = true;

btn_confirm_new_addon.Visible = false;

btn_confirm_edit_addon.Visible = false;

btn_confirm_del_addon.Visible = false;

btn_cancel_change_addon.Visible = false;

tbx_addon_name.ReadOnly = true;

tbx_addon_price.ReadOnly = true;

t_addons.Enabled = true;

t_menu.Enabled = true;

}

private void t_addons_CellClick(object sender, DataGridViewCellEventArgs e)

{

tbx_addon_id.Text = t_addons.CurrentRow.Cells["id"].Value.ToString();

tbx_addon_name.Text = t_addons.CurrentRow.Cells["name"].Value.ToString();

tbx_addon_price.Text = t_addons.CurrentRow.Cells["price"].Value.ToString();

}

private void btn_new_addon_Click(object sender, EventArgs e)

{

AddonsGridUpdate();

t_addons.Enabled = false;

t_menu.Enabled = false;

btn_confirm_new_addon.Visible = true;

btn_cancel_change_addon.Visible = true;

btn_edit_addon.Visible = false;

btn_del_addon.Visible = false;

tbx_addon_name.ReadOnly = false;

tbx_addon_price.ReadOnly = false;

}

private void btn_edit_addon_Click(object sender, EventArgs e)

{

if (tbx_addon_id.Text == "") return;

t_addons.Enabled = false;

t_menu.Enabled = false;

btn_confirm_edit_addon.Visible = true;

btn_cancel_change_addon.Visible = true;

btn_new_addon.Visible = false;

btn_del_addon.Visible = false;

tbx_addon_name.ReadOnly = false;

tbx_addon_price.ReadOnly = false;

}

private void btn_del_addon_Click(object sender, EventArgs e)

{

if (tbx_addon_id.Text == "") return;

t_addons.Enabled = false;

t_menu.Enabled = false;

btn_confirm_del_addon.Visible = true;

btn_cancel_change_addon.Visible = true;

btn_new_addon.Visible = false;

btn_edit_addon.Visible = false;

}

private void btn_confirm_new_addon_Click(object sender, EventArgs e)

{

string res = string.Empty;

if (tbx_addon_name.Text == "" || tbx_addon_price.Text == "")

MessageBox.Show("Wrong input");

else

{

m.new_Addon(current_food_id, tbx_addon_name.Text.ToString(), Double.Parse(tbx_addon_price.Text), ref res);

if (res != "Successful") MessageBox.Show(res);

else MessageBox.Show("Added");

}

AddonsGridUpdate();

}

private void btn_confirm_edit_addon_Click(object sender, EventArgs e)

{

string res = string.Empty;

if (tbx_addon_name.Text == "" || tbx_addon_price.Text == "")

MessageBox.Show("Wrong input");

else

m.edit_Addon(Int32.Parse(tbx_addon_id.Text), tbx_addon_name.Text, Double.Parse(tbx_addon_price.Text), ref res);

if (res != "Successful") MessageBox.Show(res);

else MessageBox.Show("Edited");

AddonsGridUpdate();

}

private void btn_confirm_del_addon_Click(object sender, EventArgs e)

{

string res = string.Empty;

m.del_Addon(Int32.Parse(tbx_addon_id.Text), ref res);

if (res != "Successful") MessageBox.Show(res);

else MessageBox.Show("Deleted");

AddonsGridUpdate();

}

private void btn_cancel_change_addon_Click(object sender, EventArgs e)

{

AddonsGridUpdate();

}

#endregion

#region Users

database.users us = new database.users();

private void UsersGridUpdate()

{

t_users.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

string res = string.Empty;

DataTable dt = us.grd_Users(ref res);

t_users.DataSource = dt;

t_users.Columns["id"].Visible = false;

t_users.Columns["login"].HeaderText = "login";

t_users.Columns["access_lvl"].HeaderText = "access level";

tbx_user_id.Text = "";

tbx_user_login.Text = "";

tbx_user_pass.Text = "";

tbx_user_pass1.Text = "";

cbx_user_access_lvl.Text = "";

tbx_user_id.Visible = false;

tbx_user_pass.Visible = false;

tbx_user_pass1.Visible = false;

lbl_pass.Visible = false;

lbl_pass1.Visible = false;

btn_confirm_new_user.Visible = false;

btn_confirm_edit_user.Visible = false;

btn_confirm_del_user.Visible = false;

btn_abort_change.Visible = false;

btn_new_user.Visible = true;

btn_edit_user.Visible = true;

btn_delete_user.Visible = true;

tbx_user_login.Enabled = true;

cbx_user_access_lvl.Enabled = true;

t_users.Enabled = true;

}

private void t_users_CellClick(object sender, DataGridViewCellEventArgs e)

{

tbx_user_id.Text = t_users.CurrentRow.Cells["id"].Value.ToString();

tbx_user_login.Text = t_users.CurrentRow.Cells["login"].Value.ToString();

cbx_user_access_lvl.Text = t_users.CurrentRow.Cells["access_lvl"].Value.ToString();

}

private void btn_new_user_Click(object sender, EventArgs e)

{

tbx_user_pass.Visible = true;

tbx_user_pass1.Visible = true;

lbl_pass.Visible = true;

lbl_pass1.Visible = true;

btn_confirm_new_user.Visible = true;

btn_abort_change.Visible = true;

btn_new_user.Visible = false;

btn_edit_user.Visible = false;

btn_delete_user.Visible = false;

tbx_user_id.Text = "";

tbx_user_login.Text = "";

tbx_user_pass.Text = "";

tbx_user_pass1.Text = "";

cbx_user_access_lvl.Text = "";

t_users.Enabled = false;

}

private void btn_edit_user_Click(object sender, EventArgs e)

{

if (tbx_user_id.Text == "") return;

tbx_user_pass.Visible = true;

tbx_user_pass1.Visible = true;

lbl_pass.Visible = true;

lbl_pass1.Visible = true;

btn_confirm_edit_user.Visible = true;

btn_abort_change.Visible = true;

btn_new_user.Visible = false;

btn_edit_user.Visible = false;

btn_delete_user.Visible = false;

tbx_user_login.Enabled = false;

t_users.Enabled = false;

}

private void btn_delete_user_Click(object sender, EventArgs e)

{

if (tbx_user_id.Text == "") return;

tbx_user_login.ReadOnly = true;

cbx_user_access_lvl.Enabled = false;

btn_confirm_del_user.Visible = true;

btn_new_user.Visible = false;

btn_edit_user.Visible = false;

btn_delete_user.Visible = false;

btn_abort_change.Visible = true;

t_users.Enabled = false;

}

private void btn_confirm_new_user_Click(object sender, EventArgs e)

{

string res = string.Empty;

if(cbx_user_access_lvl.Text == "")

MessageBox.Show("Wrong input");

else

if (tbx_user_pass.Text == tbx_user_pass1.Text && tbx_user_pass.Text != "")

{

us.new_User(tbx_user_login.Text, tbx_user_pass.Text, cbx_user_access_lvl.Text, ref res);

if (res != "Successful") MessageBox.Show(res);

else MessageBox.Show("Added");

}

else MessageBox.Show("Wrong password");

UsersGridUpdate();

}

private void btn_confirm_edit_user_Click(object sender, EventArgs e)

{

string res = string.Empty;

if (tbx_user_login.Text == "" || cbx_user_access_lvl.Text == "")

MessageBox.Show("Wrong input");

else

us.edit_User(tbx_user_id.Text, tbx_user_pass.Text, cbx_user_access_lvl.Text, ref res);

if (res != "Successful") MessageBox.Show(res);

else MessageBox.Show("Edited");

UsersGridUpdate();

}

private void btn_confirm_del_user_Click(object sender, EventArgs e)

{

string res = string.Empty;

us.del_User(tbx_user_id.Text, ref res);

if (res != "Successful") MessageBox.Show(res);

else MessageBox.Show("Deleted");

UsersGridUpdate();

}

private void btn_abort_change_Click(object sender, EventArgs e)

{

UsersGridUpdate();

}

#endregion

#region Couriers

database.couriers cr = new database.couriers();

private void CouriersGridUpdate()

{

t_couriers.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

string res = string.Empty;

DataTable dt = cr.grd_Couriers(ref res);

t_couriers.DataSource = dt;

t_couriers.Columns["id"].HeaderText = "id";

t_couriers.Columns["name"].HeaderText = "name";

t_couriers.Columns["Available"].HeaderText = "available";

tbx_cour_id.Text = "";

tbx_cour_name.Text = "";

}

private void btn_new_cour_Click(object sender, EventArgs e)

{

string res = string.Empty;

if (tbx_cour_name.Text != "")

{

cr.new_Courier(tbx_cour_name.Text, ref res);

if (res != "Successful") MessageBox.Show(res);

else MessageBox.Show("Added");

}

else MessageBox.Show("Wrong input");

CouriersGridUpdate();

}

private void btn_del_cour_Click(object sender, EventArgs e)

{

string res = string.Empty;

cr.del_Courier(tbx_cour_id.Text, ref res);

if (res != "Successful") MessageBox.Show(res);

else MessageBox.Show("Deleted");

CouriersGridUpdate();

}

#endregion

}

}

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

namespace Pizzeria

{

public partial class NewOrderForm : Form

{

database.newOrder order = new database.newOrder();

int transaction_id;

int user_id;

public NewOrderForm(int current_user_id)

{

InitializeComponent();

user_id = current_user_id;

pck_exist_couriers();

new_transaction();

FoodsGridUpdate();

}

private void new_transaction()

{

string res = String.Empty;

order.new_transaction(ref transaction_id, user_id, ref res);

if (res != "Successful") MessageBox.Show(res);

}

private void pck_exist_couriers()

{

string res = string.Empty;

cbx_cr_name.DataSource = order.pck_exist_couriers(ref res);

cbx_cr_name.ValueMember = "id";

cbx_cr_name.DisplayMember = "name";

if (res != "Successful") MessageBox.Show(res);

}

private void btn_order_Click(object sender, EventArgs e)

{

string res = string.Empty;

if (tbx_cl_address.Text != "") // + >=1 food

{

order.new_transaction_compl(transaction_id, tbx_cl_name.Text, tbx_cl_phone.Text, tbx_cl_address.Text, cbx_cr_name.SelectedValue.ToString(), ref res);

if (res != "Successful") MessageBox.Show(res);

else

{

this.Close();

}

}

else MessageBox.Show("Wrong input");

}

#region Menu

database.menu m = new database.menu();

int current_food_id, food_id;

private void FoodsGridUpdate()

{

t_menu_order.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

string res = string.Empty;

DataTable dt = m.grd_Foods(ref res);

t_menu_order.DataSource = dt;

t_menu_order.Columns["id"].Visible = false;

//t_menu.Columns["id"].HeaderText = "id";

t_menu_order.Columns["name"].HeaderText = "name";

t_menu_order.Columns["price"].HeaderText = "price";

try

{

t_menu_order.Columns["Count"].HeaderText = "Count";

}

catch (Exception e)

{

DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn();

col.Name = "Count";

col.HeaderText = "Count";

t_menu_order.Columns.Insert(1, col);

}

}

private void AddonsGridUpdate()

{

t_addons_order.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

string res = string.Empty;

DataTable dt = m.grd_Addons(current_food_id, ref res);

t_addons_order.DataSource = dt;

t_addons_order.Columns["id"].Visible = false;

t_addons_order.Columns["name"].HeaderText = "name";

t_addons_order.Columns["price"].HeaderText = "price";

try

{

t_addons_order.Columns["Count"].HeaderText = "Count";

}

catch(Exception e)

{

DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn();

col.Name = "Count";

col.HeaderText = "Count";

t_addons_order.Columns.Insert(1, col);

}

}

private void OrderGridUpdate()

{

t_order.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

string res = string.Empty;

DataTable dt = m.grd_Order(transaction_id, food_id, ref res);

t_order.DataSource = dt;

t_order.Columns["id"].Visible = false;

t_order.Columns["MealName"].HeaderText = "MealName";

t_order.Columns["count"].HeaderText = "count";

t_order.Columns["MealPrice"].HeaderText = "MealPrice";

t_order.Columns["price_t"].HeaderText = "price_t";

try

{

t_menu_order.Columns["Count"].HeaderText = "Count";

}

catch (Exception e)

{

DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn();

col.Name = "Count";

col.HeaderText = "Count";

t_menu_order.Columns.Insert(1, col);

}

tbx_order_sum.Text = dt.Compute("Sum(price_t)", "True").ToString();

m.write_Total_sum(transaction_id, Double.Parse(tbx_order_sum.Text), ref res);

if (res != "Successful") MessageBox.Show(res);

}

private void t_menu_order_CellClick(object sender, DataGridViewCellEventArgs e)

{

current_food_id = Int32.Parse(t_menu_order.CurrentRow.Cells["id"].Value.ToString());

AddonsGridUpdate();

}

#endregion

private void btn_add_Click(object sender, EventArgs e)

{

string res = string.Empty;

m.add_Food(transaction_id, Int32.Parse(t_menu_order.CurrentRow.Cells["id"].Value.ToString()), Int32.Parse(t_menu_order.CurrentRow.Cells["Count"].Value.ToString()), ref food_id, ref res);

if (res != "Successful") MessageBox.Show(res);

foreach (DataGridViewRow row in t_addons_order.Rows)

{

try

{

if (row.Cells["Count"].Value.ToString() != null)

{

m.add_Addon(food_id, Int32.Parse(row.Cells["id"].Value.ToString()), Int32.Parse(row.Cells["Count"].Value.ToString()), ref res);

if (res != "Successful") MessageBox.Show(res);

}

}

catch (Exception ex)

{

}

}

OrderGridUpdate();

}

private void btn_del_Click(object sender, EventArgs e)

{

string res = string.Empty;

int cur_order_id = Convert.ToInt32(t_order.CurrentRow.Cells["id"].Value.ToString());

m.del_Order(cur_order_id, ref res);

if (res != "Successful") MessageBox.Show(res);

else MessageBox.Show("Deleted");

OrderGridUpdate();

}

}

}

namespace Pizzeria.database

{

static class CS

{

public const string CONNECT_SQL = @"user id=sa;

password=sa;

Persist Security Info=True;

Data Source=BILOVUS-HOME\SQLEXPRESS;

Initial Catalog=pizzeria;

Connection Timeout=60000;

Pooling=true";

}

}

using System;

using System.Collections.Generic;

using System.Linq;

using System.Security.Cryptography;

using System.Data.SqlClient;

using System.Data;

namespace Pizzeria.database

{

class login

{

public void hash_pass(ref string hash)

{

MD5 md5 = new MD5CryptoServiceProvider();

byte[] bs = System.Text.Encoding.UTF8.GetBytes(hash);

bs = md5.ComputeHash(bs);

hash = BitConverter.ToString(bs).Replace("-", String.Empty);//.ToLower();

}

public void verify_User(string user_login, string user_pass, ref int user_access_lvl, ref int user_id, ref bool is_verified, ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

conn.Open();

SqlCommand command = new SqlCommand("dbo.sp_verify_User", conn) { CommandType = CommandType.StoredProcedure };

command.Parameters.Add("@user_login", SqlDbType.NVarChar, 20).Value = user_login;

command.Parameters.Add("@user_pass", SqlDbType.NVarChar, 35).Value = user_pass;

command.Parameters.Add("@user_access_lvl", SqlDbType.Int).Direction = ParameterDirection.Output;

command.Parameters.Add("@user_id", SqlDbType.Int).Direction = ParameterDirection.Output;

command.Parameters.Add("@is_verified", SqlDbType.Bit).Direction = ParameterDirection.Output;

command.Parameters.Add("@res", SqlDbType.VarChar, 50).Direction = ParameterDirection.Output;

command.ExecuteNonQuery();

is_verified = (bool)command.Parameters["@is_verified"].Value;

if (is_verified)

{

user_access_lvl = (int)command.Parameters["@user_access_lvl"].Value;

user_id = (int)(command.Parameters["@user_id"].Value);

}

res = command.Parameters["@res"].Value.ToString();

conn.Close();

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_verify_User {0}", user_login);

}

}

}

}

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Data;

using System.Data.SqlClient;

namespace Pizzeria.database

{

class state

{

public DataTable grd_State(ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

SqlCommand command = new SqlCommand("dbo.sp_grd_State", conn) { CommandType = CommandType.StoredProcedure };

command.Parameters.Add("@res", SqlDbType.VarChar, 50).Direction = ParameterDirection.Output;

SqlDataAdapter adp = new SqlDataAdapter(command);

DataSet ds = new DataSet();

adp.Fill(ds);

res = command.Parameters["@res"].Value.ToString();

conn.Close();

return ds.Tables[0];

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_grd_State {0}", ex);

return null;

}

}

public DataTable grd_History(ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

SqlCommand command = new SqlCommand("dbo.sp_grd_History", conn) { CommandType = CommandType.StoredProcedure };

command.Parameters.Add("@res", SqlDbType.VarChar, 50).Direction = ParameterDirection.Output;

SqlDataAdapter adp = new SqlDataAdapter(command);

DataSet ds = new DataSet();

adp.Fill(ds);

res = command.Parameters["@res"].Value.ToString();

conn.Close();

return ds.Tables[0];

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_grd_History {0}", ex);

return null;

}

}

public void finish_transaction(int order_id, int state, ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

conn.Open();

SqlCommand command = new SqlCommand("dbo.sp_finish_order", conn) { CommandType = CommandType.StoredProcedure };

command.Parameters.Add("@order_id", SqlDbType.Int).Value = order_id;

command.Parameters.Add("@state", SqlDbType.Int).Value = state;

command.Parameters.Add("@res", SqlDbType.NVarChar, 50).Direction = ParameterDirection.Output;

command.ExecuteNonQuery();

res = command.Parameters["@res"].Value.ToString();

conn.Close();

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_finish_order {0}", ex);

}

}

}

}

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Data.SqlClient;

using System.Data;

namespace Pizzeria.database

{

class users

{

public DataTable grd_Users(ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

SqlCommand command = new SqlCommand("dbo.sp_grd_Users", conn) { CommandType = CommandType.StoredProcedure };

command.Parameters.Add("@res", SqlDbType.VarChar, 50).Direction = ParameterDirection.Output;

SqlDataAdapter adp = new SqlDataAdapter(command);

DataSet ds = new DataSet();

adp.Fill(ds);

res = command.Parameters["@res"].Value.ToString();

conn.Close();

return ds.Tables[0];

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_grd_Users {0}", ex);

return null;

}

}

public void del_User(string user_id, ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

conn.Open();

SqlCommand command = new SqlCommand("dbo.sp_del_User", conn) { CommandType = CommandType.StoredProcedure };

command.Parameters.Add("@id", SqlDbType.NVarChar, 50).Value = user_id;

command.Parameters.Add("@res", SqlDbType.NVarChar, 50).Direction = ParameterDirection.Output;

command.ExecuteNonQuery();

res = command.Parameters["@res"].Value.ToString();

conn.Close();

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_del_User {0}", ex);

}

}

public void new_User(string login, string password, string access_lvl, ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

conn.Open();

SqlCommand command = new SqlCommand("dbo.sp_new_User", conn) { CommandType = CommandType.StoredProcedure };

command.Parameters.Add("@login", SqlDbType.NVarChar, 20).Value = login;

command.Parameters.Add("@password", SqlDbType.NVarChar, 35).Value = password;

command.Parameters.Add("@access_lvl", SqlDbType.NVarChar, 1).Value = access_lvl;

command.Parameters.Add("@res", SqlDbType.NVarChar, 50).Direction = ParameterDirection.Output;

command.ExecuteNonQuery();

res = command.Parameters["@res"].Value.ToString();

conn.Close();

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_new_User {0}", ex);

}

}

public void edit_User(string id, string password, string access_lvl, ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

conn.Open();

SqlCommand command = new SqlCommand("dbo.sp_edit_User", conn) { CommandType = CommandType.StoredProcedure };

command.Parameters.Add("@id", SqlDbType.NVarChar, 50).Value = id;

command.Parameters.Add("@password", SqlDbType.NVarChar, 35).Value = password;

command.Parameters.Add("@access_lvl", SqlDbType.NVarChar, 1).Value = access_lvl;

command.Parameters.Add("@res", SqlDbType.NVarChar, 50).Direction = ParameterDirection.Output;

command.ExecuteNonQuery();

res = command.Parameters["@res"].Value.ToString();

conn.Close();

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_edit_User {0}", ex);

}

}

}

}

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Data;

using System.Data.SqlClient;

namespace Pizzeria.database

{

class couriers

{

public DataTable grd_Couriers(ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

SqlCommand command = new SqlCommand("dbo.sp_grd_Couriers", conn) { CommandType = CommandType.StoredProcedure };

command.Parameters.Add("@res", SqlDbType.VarChar, 50).Direction = ParameterDirection.Output;

SqlDataAdapter adp = new SqlDataAdapter(command);

DataSet ds = new DataSet();

adp.Fill(ds);

res = command.Parameters["@res"].Value.ToString();

conn.Close();

return ds.Tables[0];

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_grd_Couriers {0}", ex);

return null;

}

}

public void del_Courier(string cour_id, ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

conn.Open();

SqlCommand command = new SqlCommand("dbo.sp_del_Courier", conn) { CommandType = CommandType.StoredProcedure };

command.Parameters.Add("@id", SqlDbType.NVarChar, 50).Value = cour_id;

command.Parameters.Add("@res", SqlDbType.NVarChar, 50).Direction = ParameterDirection.Output;

command.ExecuteNonQuery();

res = command.Parameters["@res"].Value.ToString();

conn.Close();

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_del_Courier {0}", ex);

}

}

public void new_Courier(string name, ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

conn.Open();

SqlCommand command = new SqlCommand("dbo.sp_new_Courier", conn) { CommandType = CommandType.StoredProcedure };

command.Parameters.Add("@name", SqlDbType.NVarChar, 20).Value = name;

command.Parameters.Add("@res", SqlDbType.NVarChar, 50).Direction = ParameterDirection.Output;

command.ExecuteNonQuery();

res = command.Parameters["@res"].Value.ToString();

conn.Close();

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_new_Courier {0}", ex);

}

}

}

}

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Data;

using System.Data.SqlClient;

namespace Pizzeria.database

{

class menu

{

public DataTable grd_Foods(ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

SqlCommand command = new SqlCommand("dbo.sp_grd_Foods", conn) { CommandType = CommandType.StoredProcedure };

command.Parameters.Add("@res", SqlDbType.VarChar, 50).Direction = ParameterDirection.Output;

SqlDataAdapter adp = new SqlDataAdapter(command);

DataSet ds = new DataSet();

adp.Fill(ds);

res = command.Parameters["@res"].Value.ToString();

conn.Close();

return ds.Tables[0];

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_grd_Foods {0}", ex);

return null;

}

}

public void new_Food(string name, double price, ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

conn.Open();

SqlCommand command = new SqlCommand("dbo.sp_new_Food", conn) { CommandType = CommandType.StoredProcedure };

//command.Parameters.Add("@id", SqlDbType.Int).Value = id;

command.Parameters.Add("@name", SqlDbType.NVarChar, 50).Value = name;

command.Parameters.Add("@price", SqlDbType.Decimal).Value = price;

command.Parameters.Add("@res", SqlDbType.NVarChar, 50).Direction = ParameterDirection.Output;

command.ExecuteNonQuery();

res = command.Parameters["@res"].Value.ToString();

conn.Close();

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_new_Food {0}", ex);

}

}

public void edit_Food(int id, string name, double price, ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

conn.Open();

SqlCommand command = new SqlCommand("dbo.sp_edit_Food", conn) { CommandType = CommandType.StoredProcedure };

command.Parameters.Add("@id", SqlDbType.Int).Value = id;

command.Parameters.Add("@name", SqlDbType.NVarChar, 50).Value = name;

command.Parameters.Add("@price", SqlDbType.Decimal).Value = price;

command.Parameters.Add("@res", SqlDbType.NVarChar, 50).Direction = ParameterDirection.Output;

command.ExecuteNonQuery();

res = command.Parameters["@res"].Value.ToString();

conn.Close();

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_edit_Food {0}", ex);

}

}

public void del_Food(int id, ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

conn.Open();

SqlCommand command = new SqlCommand("dbo.sp_del_Food", conn) { CommandType = CommandType.StoredProcedure };

command.Parameters.Add("@id", SqlDbType.Int).Value = id;

command.Parameters.Add("@res", SqlDbType.NVarChar, 50).Direction = ParameterDirection.Output;

command.ExecuteNonQuery();

res = command.Parameters["@res"].Value.ToString();

conn.Close();

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_del_Food {0}", ex);

}

}

public DataTable grd_Addons(int current_food_id,ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

SqlCommand command = new SqlCommand("dbo.sp_grd_Addons", conn) { CommandType = CommandType.StoredProcedure };

command.Parameters.Add("@current_food_id", SqlDbType.Int).Value = current_food_id;

command.Parameters.Add("@res", SqlDbType.VarChar, 50).Direction = ParameterDirection.Output;

SqlDataAdapter adp = new SqlDataAdapter(command);

DataSet ds = new DataSet();

adp.Fill(ds);

res = command.Parameters["@res"].Value.ToString();

conn.Close();

return ds.Tables[0];

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_grd_Addons {0}", ex);

return null;

}

}

public void new_Addon(int current_food_id, string name, double price, ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

conn.Open();

SqlCommand command = new SqlCommand("dbo.sp_new_Addon", conn) { CommandType = CommandType.StoredProcedure };

command.Parameters.Add("@current_food_id", SqlDbType.Int).Value = current_food_id;

command.Parameters.Add("@name", SqlDbType.NVarChar, 50).Value = name;

command.Parameters.Add("@price", SqlDbType.Decimal).Value = price;

command.Parameters.Add("@res", SqlDbType.NVarChar, 50).Direction = ParameterDirection.Output;

command.ExecuteNonQuery();

res = command.Parameters["@res"].Value.ToString();

conn.Close();

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_new_Addon {0}", ex);

}

}

public void edit_Addon(int id, string name, double price, ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

conn.Open();

SqlCommand command = new SqlCommand("dbo.sp_edit_Addon", conn) { CommandType = CommandType.StoredProcedure };

command.Parameters.Add("@id", SqlDbType.Int).Value = id;

command.Parameters.Add("@name", SqlDbType.NVarChar, 50).Value = name;

command.Parameters.Add("@price", SqlDbType.Decimal).Value = price;

command.Parameters.Add("@res", SqlDbType.NVarChar, 50).Direction = ParameterDirection.Output;

command.ExecuteNonQuery();

res = command.Parameters["@res"].Value.ToString();

conn.Close();

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_edit_Addon {0}", ex);

}

}

public void del_Addon(int id, ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

conn.Open();

SqlCommand command = new SqlCommand("dbo.sp_del_Addon", conn) { CommandType = CommandType.StoredProcedure };

command.Parameters.Add("@id", SqlDbType.Int).Value = id;

command.Parameters.Add("@res", SqlDbType.NVarChar, 50).Direction = ParameterDirection.Output;

command.ExecuteNonQuery();

res = command.Parameters["@res"].Value.ToString();

conn.Close();

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_del_Addon {0}", ex);

}

}

public void add_Food(int transaction_id, int parentId, int count, ref int food_id, ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

conn.Open();

SqlCommand command = new SqlCommand("dbo.sp_add_Food", conn) { CommandType = CommandType.StoredProcedure };

command.Parameters.Add("@transaction_id", SqlDbType.Int).Value = transaction_id;

command.Parameters.Add("@parentId", SqlDbType.Int).Value = parentId;

command.Parameters.Add("@count", SqlDbType.Int).Value = count;

command.Parameters.Add("@food_id", SqlDbType.Int).Direction = ParameterDirection.Output;

command.Parameters.Add("@res", SqlDbType.NVarChar, 50).Direction = ParameterDirection.Output;

command.ExecuteNonQuery();

food_id = Int32.Parse(command.Parameters["@food_id"].Value.ToString());

res = command.Parameters["@res"].Value.ToString();

conn.Close();

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_add_Food {0}", ex);

}

}

public void add_Addon(int food_id, int addon_id, int count, ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

conn.Open();

SqlCommand command = new SqlCommand("dbo.sp_add_Addon", conn) { CommandType = CommandType.StoredProcedure };

command.Parameters.Add("@food_id", SqlDbType.Int).Value = food_id;

command.Parameters.Add("@addon_id", SqlDbType.Int).Value = addon_id;

command.Parameters.Add("@count", SqlDbType.Int).Value = count;

command.Parameters.Add("@res", SqlDbType.NVarChar, 50).Direction = ParameterDirection.Output;

command.ExecuteNonQuery();

res = command.Parameters["@res"].Value.ToString();

conn.Close();

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_add_Addon {0}", ex);

}

}

public DataTable grd_Order(int transaction_id, int food_id, ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

SqlCommand command = new SqlCommand("dbo.sp_grd_Order", conn) { CommandType = CommandType.StoredProcedure };

command.Parameters.Add("@transaction_id", SqlDbType.Int).Value = transaction_id;

command.Parameters.Add("@food_id", SqlDbType.Int).Value = food_id;

command.Parameters.Add("@res", SqlDbType.VarChar, 50).Direction = ParameterDirection.Output;

SqlDataAdapter adp = new SqlDataAdapter(command);

DataSet ds = new DataSet();

adp.Fill(ds);

res = command.Parameters["@res"].Value.ToString();

conn.Close();

return ds.Tables[0];

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_grd_Order {0}", ex);

return null;

}

}

public void del_Order(int order_id, ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

conn.Open();

SqlCommand command = new SqlCommand("dbo.sp_del_Order", conn) { CommandType = CommandType.StoredProcedure };

command.Parameters.Add("@order_id", SqlDbType.Int).Value = order_id;

command.Parameters.Add("@res", SqlDbType.NVarChar, 50).Direction = ParameterDirection.Output;

command.ExecuteNonQuery();

res = command.Parameters["@res"].Value.ToString();

conn.Close();

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_del_Order {0}", ex);

}

}

public void write_Total_sum(int transaction_id, double sum, ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

conn.Open();

SqlCommand command = new SqlCommand("dbo.sp_write_Total_sum", conn) { CommandType = CommandType.StoredProcedure };

command.Parameters.Add("@transaction_id", SqlDbType.Int).Value = transaction_id;

command.Parameters.Add("@sum", SqlDbType.Decimal).Value = sum;

command.Parameters.Add("@res", SqlDbType.NVarChar, 50).Direction = ParameterDirection.Output;

command.ExecuteNonQuery();

res = command.Parameters["@res"].Value.ToString();

conn.Close();

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_write_Total_sum {0}", ex);

}

}

}

}

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Data.SqlClient;

using System.Data;

namespace Pizzeria.database

{

class newOrder

{

public DataTable pck_exist_couriers(ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

SqlCommand command = new SqlCommand("dbo.sp_exist_couriers", conn) { CommandType = CommandType.StoredProcedure };

command.Parameters.Add("@res", SqlDbType.VarChar, 50).Direction = ParameterDirection.Output;

SqlDataAdapter adp = new SqlDataAdapter(command);

DataSet ds = new DataSet();

adp.Fill(ds);

res = command.Parameters["@res"].Value.ToString();

conn.Close();

return ds.Tables[0];

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_exist_couriers {0}", ex);

return null;

}

}

public void new_transaction(ref int transaction_id, int user_id, ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

conn.Open();

SqlCommand command = new SqlCommand("dbo.sp_new_transaction", conn) { CommandType = CommandType.StoredProcedure };

command.Parameters.Add("@user_id", SqlDbType.Int).Value = user_id;

command.Parameters.Add("@transaction_id", SqlDbType.Int).Direction = ParameterDirection.Output;

command.Parameters.Add("@res", SqlDbType.VarChar, 50).Direction = ParameterDirection.Output;

command.ExecuteNonQuery();

transaction_id = (int)command.Parameters["@transaction_id"].Value;

res = command.Parameters["@res"].Value.ToString();

conn.Close();

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_new_transaction");

}

}

public void new_transaction_compl(int transaction_id, string cl_name, string cl_phone, string cl_address, string cr_id, ref string res)

{

try

{

using (SqlConnection conn = new SqlConnection(CS.CONNECT_SQL))

{

conn.Open();

SqlCommand command = new SqlCommand("dbo.sp_new_transaction_compl", conn) { CommandType = CommandType.StoredProcedure };

command.Parameters.Add("@transaction_id", SqlDbType.Int).Value = transaction_id;

command.Parameters.Add("@cl_name", SqlDbType.VarChar, 20).Value = cl_name;

command.Parameters.Add("@cl_phone", SqlDbType.VarChar, 20).Value = cl_phone;

command.Parameters.Add("@cl_address", SqlDbType.VarChar, 20).Value = cl_address;

command.Parameters.Add("@cr_id", SqlDbType.Int).Value = cr_id;

command.Parameters.Add("@res", SqlDbType.VarChar, 50).Direction = ParameterDirection.Output;

command.ExecuteNonQuery();

res = command.Parameters["@res"].Value.ToString();

conn.Close();

}

}

catch (Exception ex)

{

res = String.Format("Помилка виклику процедури dbo.sp_new_transaction_compl");

}

}

}

}

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]