public Lable(Lable lable) { lable_id = lable.lable_id; lable_text = lable.lable_text; background = lable.background; foreground = lable.foreground; room_id = lable.room_id; }
public static List <LableTask> ReturnRelationsOfLable(Lable label) { List <LableTask> tasklables = new List <LableTask>(); using (var connection = DBconnect.Instance.Connection) { string RelationsOfTask = ALL_TASKLABLE + $" WHERE lable_id={label.lable_id}"; SqlCommand command = new SqlCommand(RelationsOfTask, connection); connection.Open(); var reader = command.ExecuteReader(); while (reader.Read()) { tasklables.Add(new LableTask(reader)); } connection.Close(); } return(tasklables); }
public static bool AddLable(Lable lable) { bool succ = false; using (var connection = DBconnect.Instance.Connection) { SqlCommand command = new SqlCommand($"{ADD_LABLE} {lable.ToInsert()}", connection); connection.Open(); var id = command.ExecuteNonQuery(); succ = true; command = new SqlCommand($"SELECT MAX(lable_id) ID FROM LABLE", connection); var reader = command.ExecuteReader(); reader.Read(); lable.lable_id = int.Parse(reader["ID"].ToString()); connection.Close(); } return(succ); }
public static bool DeleteLable(Lable lable) { bool succ = false; using (var connection = DBconnect.Instance.Connection) { string DELETE_LABLE = $"DELETE FROM LABLE" + $" WHERE lable_id={lable.lable_id}"; SqlCommand command = new SqlCommand(DELETE_LABLE, connection); connection.Open(); var n = command.ExecuteNonQuery(); if (n == 1) { succ = true; } connection.Close(); } return(succ); }
public static bool EditLable(Lable lable, int idLable) { bool succ = false; using (var connection = DBconnect.Instance.Connection) { string EDIT_LABLE = $"UPDATE LABLE SET lable_text='{lable.lable_text}', lable_background='{lable.background}', lable_foreground='{lable.foreground}'" + $" WHERE lable_id={idLable}"; SqlCommand command = new SqlCommand(EDIT_LABLE, connection); connection.Open(); var n = command.ExecuteNonQuery(); if (n == 1) { succ = true; } connection.Close(); } return(succ); }
public LableTask(Lable person, Tasks task) { lable_id = person.lable_id; task_id = task.task_id; DataLableTask.AddLableTask(this); }