public static void FindAllRoles() { SystemSingleton.CurrentSession.UserRoles.Clear(); try { using (var con = new SqlConnection(SystemSingleton.Configuration.ConnectionString)) { SystemSingleton.Configuration.SqlConnections.Add(con); using (var command = new SqlCommand(SqlCommands.FindAllRolesCommand, con)) { command.Parameters.Add("@UserID", SqlDbType.UniqueIdentifier); command.Parameters["@UserID"].Value = SystemSingleton.CurrentSession.ID; EnvironmentHelper.SendLogSQL(command.CommandText); con.Open(); using (var reader = command.ExecuteReader()) { while (reader.Read()) { var temp = new Role(); temp.ID = reader.GetGuid(0); temp.Name = reader.GetString(1); temp.Caption = reader.GetString(2); SystemSingleton.CurrentSession.UserRoles.Add(temp); } } con.Close(); } } } catch (Exception ex) { EnvironmentHelper.SendErrorDialogBox(ex.Message, "SQL Error", ex.StackTrace); } }
public static void SetInfoToGridOther(ref STabItem tabitem) { try { SqlConnection con = new SqlConnection(SystemSingleton.Configuration.ConnectionString); SqlCommand cmd = new SqlCommand(SqlCommands.SetInfoToGridOtherCommand, con); cmd.Parameters.Add("@RoleID", SqlDbType.UniqueIdentifier); cmd.Parameters["@RoleID"].Value = tabitem.ToRole; EnvironmentHelper.SendLogSQL(cmd.CommandText); SqlDataAdapter sda = new SqlDataAdapter(cmd); DataTable dt = new DataTable("Tasks"); sda.Fill(dt); tabitem.DataGrid.ItemsSource = dt.DefaultView; } catch (Exception ex) { EnvironmentHelper.SendErrorDialogBox(ex.Message, "SQL Error", ex.StackTrace); } }
public static void SetInfoToGridEndWork(ref DataGrid dataGrid) { try { SqlConnection con = new SqlConnection(SystemSingleton.Configuration.ConnectionString); SqlCommand cmd = new SqlCommand(SqlCommands.SetInfoToGridEndWorkCommand, con); cmd.Parameters.Add("@UserID", SqlDbType.UniqueIdentifier); cmd.Parameters["@UserID"].Value = SystemSingleton.CurrentSession.ID; EnvironmentHelper.SendLogSQL(cmd.CommandText); SqlDataAdapter sda = new SqlDataAdapter(cmd); DataTable dt = new DataTable("Tasks"); sda.Fill(dt); for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i][6] = (string)SystemSingleton.Configuration.mainWindow.FindResource((string)dt.Rows[i][6]); } dataGrid.ItemsSource = dt.DefaultView; } catch (Exception ex) { EnvironmentHelper.SendErrorDialogBox(ex.Message, "SQL Error", ex.StackTrace); } }
public static void Row_DoubleClick(object sender, MouseButtonEventArgs e) { if (sender is DataGridRow row) { var temp = CardFactory.CreateTab(Guid.Parse(((DataRowView)row.Item).Row.ItemArray[0].ToString())); if (temp != null) { if (SystemSingleton.CurrentSession.TabCards.ContainsKey(temp.Card.Task.Number)) { EnvironmentHelper.SendDialogBox( (string)SystemSingleton.Configuration.mainWindow.FindResource("m_AlreadyOpened"), "Attention" ); } else { if (temp.Card.Task.StateID == new Guid("6a52791d-7e42-42d6-a521-4252f276bb6c")) { if (temp.Card.Task.isEditingNow) { EnvironmentHelper.SendDialogBox( (string)SystemSingleton.Configuration.mainWindow.FindResource("m_AlreadyEditing"), "Attention" ); } else { try { using (var con = new SqlConnection(SystemSingleton.Configuration.ConnectionString)) { SystemSingleton.Configuration.SqlConnections.Add(con); using (var command = new SqlCommand(SqlCommands.SetEditingToTask, con)) { command.Parameters.Add("@TaskID", SqlDbType.UniqueIdentifier); command.Parameters["@TaskID"].Value = temp.Card.Task.ID.Value; EnvironmentHelper.SendLogSQL(command.CommandText); con.Open(); int colms = command.ExecuteNonQuery(); con.Close(); if (colms == 0) { EnvironmentHelper.SendDialogBox( (string)SystemSingleton.Configuration.mainWindow.FindResource( "m_CantSetEditing") + "\n\n" + temp.Card.Task.ID.Value.ToString(), "SQL Error" ); } } } } catch (Exception ex) { EnvironmentHelper.SendErrorDialogBox(ex.Message, "SQL Error", ex.StackTrace); } } } SystemSingleton.CurrentSession.TabCards.Add(temp.Card.Task.Number, temp); SystemSingleton.Configuration.tabControl.Items.Add(temp.TabItem); } } } }