public void Sotr_Edit(int Id_Sotr, string F_Sotr, string I_Sotr, string O_Sotr, string Date_rozd_Sotr, string Num_telef_Sotr, string Foto_Sotr, int Key_Sotr_id, string Email_Sotr, string Login_Sotr, string Password_Sotr, int System_access, int Dolj_Sotr_id, int Dostup_Id)//Процедура изменения { try { _RI = new Reg_Informat(); _RI.Set_Connection(); _RI.Connection.Open(); SqlCommand StrProc = new SqlCommand("Ustroistva_Update", _RI.Connection); StrProc.CommandType = CommandType.StoredProcedure; StrProc.Parameters.AddWithValue("@Id_Sotr", Id_Sotr); StrProc.Parameters.AddWithValue("@F_Sotr", F_Sotr); StrProc.Parameters.AddWithValue("@I_Sotr", I_Sotr); StrProc.Parameters.AddWithValue("@O_Sotr", O_Sotr); StrProc.Parameters.AddWithValue("@Date_rozd_Sotr", Date_rozd_Sotr); StrProc.Parameters.AddWithValue("@Num_telef_Sotr", Num_telef_Sotr); StrProc.Parameters.AddWithValue("@Foto_Sotr", Foto_Sotr); StrProc.Parameters.AddWithValue("@Key_Sotr_id", Key_Sotr_id); StrProc.Parameters.AddWithValue("@Email_Sotr", Email_Sotr); StrProc.Parameters.AddWithValue("@Login_Sotr", Login_Sotr); StrProc.Parameters.AddWithValue("@Password_Sotr", Password_Sotr); StrProc.Parameters.AddWithValue("@System_access", System_access); StrProc.Parameters.AddWithValue("@Dolj_Sotr_id", Dolj_Sotr_id); StrProc.Parameters.AddWithValue("@Dostup_Id", Dostup_Id); StrProc.ExecuteNonQuery(); _RI.Connection.Close(); } catch (System.Exception msg) { logger.Debug(msg.ToString()); System.Windows.Forms.MessageBox.Show(msg.Message); } }
public void Auntentification(string Login_User, string Pass_user)//Аутентификация пользователя { try { _RI = new Reg_Informat(); _RI.Set_Connection(); SqlCommand _CmdSql1 = new SqlCommand("select Id_Sotr from Sotr where Login_Sotr = '" + Login_User + "' and " + "Password_Sotr = '" + Pass_user + "'", _RI.Connection); _RI.Connection.Open(); Program.UID = Convert.ToInt32(_CmdSql1.ExecuteScalar().ToString()); switch (Program.UID) { case (0): MessageBox.Show("Данные введены не верно!"); break; default: _RI = new Reg_Informat(); _CmdSql1 = new SqlCommand(sy_access + Program.UID, _RI.Connection); _RI.Set_Connection(); _RI.Connection.Open(); Program.SYACCSS = Convert.ToInt32(_CmdSql1.ExecuteScalar().ToString()); switch (Program.SYACCSS) { case (0): MessageBox.Show("У вас нет прав доступа к системе!"); break; case (1): _RI = new Reg_Informat(); _RI.Set_Connection(); _RI.Connection.Open(); SqlCommand ADaccess = new SqlCommand(admin_access + Program.UID, _RI.Connection); Program.ADMINACCSS = Convert.ToInt32(ADaccess.ExecuteScalar().ToString()); Program.Value = true; _RI.Connection.Close(); break; } _RI.Connection.Close(); break; } _RI.Connection.Close(); } catch (Exception msg) { logger.Debug(msg.ToString()); } }
public void Sotr_Delete(int Id_Sotr)//Процедура удаления { try { _RI = new Reg_Informat(); _RI.Set_Connection(); _RI.Connection.Open(); SqlCommand StrProc = new SqlCommand("Sotr_Delete", _RI.Connection); StrProc.CommandType = CommandType.StoredProcedure; StrProc.Parameters.AddWithValue("@Id_Sotr", Id_Sotr); StrProc.ExecuteNonQuery(); _RI.Connection.Close(); } catch (System.Exception msg) { logger.Debug(msg.ToString()); System.Windows.Forms.MessageBox.Show(msg.Message); } }
//Хранимые процедуры и представления для таблицы Ustroistva public void Ustroistva_Select()//Представление { try { _RI = new Reg_Informat(); _RI.Set_Connection(); _RI.Connection.Open(); SqlCommand Ustroistva_Select = new SqlCommand("SELECT Id_Ustroistva as [Идентификатор], MAC_Adress as [Строка подключения], Name_ustroistva as [Имя устройства], Prohod_name as [Расположение] FROM Ustroistva", _RI.Connection); SqlDataReader tableReader = Ustroistva_Select.ExecuteReader(); DataTable table = new DataTable(); table = new DataTable(); table.Load(tableReader); Program.Ustroistva_Select = table; _RI.Connection.Close(); } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
//Хранимые процедуры и представления для таблицы Ustroistva public void Sotr_Select()//Представление { try { _RI = new Reg_Informat(); _RI.Set_Connection(); _RI.Connection.Open(); SqlCommand Sotr_Select = new SqlCommand("SELECT Id_Sotr as [Идентификатор], F_Sotr as [Фамилия], I_Sotr as [Илья] , O_Sotr as [Отчество], Date_rozd_Sotr as [Дата рождения], Num_telef_Sotr as [№ телефона], Foto_Sotr as [Фото сотрудника], Key_Sotr_id as [Ключ], Email_Sotr as [Почта сотрудника], Login_Sotr as [Логин сотрудника], Password_Sotr as [Пароль сотрудника], System_access as [Доступ к системе], Dolj_Sotr_id as [№ Должности], Dostup_Id as [№ Доступа] FROM Sotr", _RI.Connection); SqlDataReader tableReader = Sotr_Select.ExecuteReader(); DataTable table = new DataTable(); table = new DataTable(); table.Load(tableReader); Program.Sotr_Select = table; _RI.Connection.Close(); } catch (System.Exception msg) { logger.Debug(msg.ToString()); System.Windows.Forms.MessageBox.Show(msg.Message); } }
public void Ustroistva_Insert(string Mac_Adress, string Name_Ustroistva, string Name_Prohod)//Процедура вставки { try { _RI = new Reg_Informat(); _RI.Set_Connection(); _RI.Connection.Open(); SqlCommand StrProc = new SqlCommand("Ustroistva_Insert", _RI.Connection); StrProc.CommandType = CommandType.StoredProcedure; StrProc.Parameters.AddWithValue("@MAC_Adress", Mac_Adress); StrProc.Parameters.AddWithValue("@Name_ustroistva", Name_Ustroistva); StrProc.Parameters.AddWithValue("@Prohod_name", Name_Prohod); StrProc.ExecuteNonQuery(); _RI.Connection.Close(); } catch (System.Exception msg) { System.Windows.Forms.MessageBox.Show(msg.Message); logger.Debug(msg.ToString()); } }
public void Get_Base_list()//Получение листа БД { P_BD.StartPosition = FormStartPosition.CenterScreen; _RI = new Reg_Informat(); try { _RI.Set_Connection(); GDtBsLstCn = new SqlConnection("Data Source = " + Reg_Informat.DS + "; Initial Catalog = master; Persist Security Info=True; User ID = " + Reg_Informat.UN + "; Password=\"" + Reg_Informat.UP + "\""); GDtBsLstCn.Open(); SqlDataAdapter BsAdpt = new SqlDataAdapter("exec sp_helpdb", GDtBsLstCn); DataSet BDst = new DataSet(); BsAdpt.Fill(BDst, "db"); List_Dbs(BDst); _RI.Connection.Close(); } catch (Exception msg) { MetroFramework.MetroMessageBox.Show(P_BD, "Данные введены неверно! Проверьте правильность ввода логина или пароля.", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Warning); logger.Debug(msg.ToString()); } }