private void button1_Click(object sender, EventArgs e) { var buf_p = SQL_Helper.getInstance().ProcedureParameters("Login_Function"); buf_p[1].value = tb_login.Text; buf_p[2].value = tb_password.Text; SQL_Helper.Parameter dt = SQL_Helper.getInstance().SQL_Scalarfunction("[dbo].[Login_Function]", buf_p); MainWidow.Access?acs = null; if (!(dt.value is DBNull)) { int val = Convert.ToInt32(dt.value); DataTable d = SQL_Helper.getInstance().SQL_ExecuteQuery("SELECT Role FROM users WHERE userID = " + val); if (d.Rows.Count > 0) { val = (int)d.Rows[0][0]; if (val == (int)MainWidow.Access.Admin) { acs = MainWidow.Access.Admin; } else if (val == (int)MainWidow.Access.Accountant) { acs = MainWidow.Access.Accountant; } else if (val == (int)MainWidow.Access.Emploee) { acs = MainWidow.Access.Emploee; } else if (val == (int)MainWidow.Access.Dirrector) { acs = MainWidow.Access.Dirrector; } } } if (acs == null) { MessageBox.Show("Ошибка! Пользователя с такими данными не существует!"); return; } this.Hide(); MainWidow mw = new MainWidow((MainWidow.Access)acs); mw.ShowDialog(); this.Close(); }
private void GetMessage() { var p = pc.parameters; if (pc.Function_Type == ProcedureControll.FncType.Scalar) { SQL_Helper.Parameter res = new SQL_Helper.Parameter(); try { res = SQL_Helper.getInstance().SQL_Scalarfunction(pc.ProcedureName, p); } catch (Exception e) { MessageBox.Show(e.Message); } Type t = res.type; pc_scalar_res = new SQL_Helper.Parameter(); pc_scalar_res.value = res; pc_scalar_res.type = t; } else if (pc.Function_Type == ProcedureControll.FncType.Table) { DataTable dt = new DataTable(); try { dt = SQL_Helper.getInstance().SQL_Tablefunction(pc.ProcedureName, p); } catch (Exception e) { MessageBox.Show(e.Message); } dgv_Data.DataSource = dt; } else if (pc.Function_Type == ProcedureControll.FncType.StoredProcedure) { SQL_Helper.getInstance().SQL_StoredProcedure(pc.ProcedureName, p); } fnc_Type = pc.Function_Type; ResetWindow(); }