Студопедия

КАТЕГОРИИ:


Архитектура-(3434)Астрономия-(809)Биология-(7483)Биотехнологии-(1457)Военное дело-(14632)Высокие технологии-(1363)География-(913)Геология-(1438)Государство-(451)Демография-(1065)Дом-(47672)Журналистика и СМИ-(912)Изобретательство-(14524)Иностранные языки-(4268)Информатика-(17799)Искусство-(1338)История-(13644)Компьютеры-(11121)Косметика-(55)Кулинария-(373)Культура-(8427)Лингвистика-(374)Литература-(1642)Маркетинг-(23702)Математика-(16968)Машиностроение-(1700)Медицина-(12668)Менеджмент-(24684)Механика-(15423)Науковедение-(506)Образование-(11852)Охрана труда-(3308)Педагогика-(5571)Полиграфия-(1312)Политика-(7869)Право-(5454)Приборостроение-(1369)Программирование-(2801)Производство-(97182)Промышленность-(8706)Психология-(18388)Религия-(3217)Связь-(10668)Сельское хозяйство-(299)Социология-(6455)Спорт-(42831)Строительство-(4793)Торговля-(5050)Транспорт-(2929)Туризм-(1568)Физика-(3942)Философия-(17015)Финансы-(26596)Химия-(22929)Экология-(12095)Экономика-(9961)Электроника-(8441)Электротехника-(4623)Энергетика-(12629)Юриспруденция-(1492)Ядерная техника-(1748)

Лістинг коду 2 страница




}

 

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");




Поделиться с друзьями:


Дата добавления: 2015-08-31; Просмотров: 562; Нарушение авторских прав?; Мы поможем в написании вашей работы!


Нам важно ваше мнение! Был ли полезен опубликованный материал? Да | Нет



studopedia.su - Студопедия (2013 - 2024) год. Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав! Последнее добавление




Генерация страницы за: 0.288 сек.