База данных для хранения и обработки информации, которая требуется типичной психиатрической больнице, страница 26

                                                           {

                                                                               cmd.CommandType = CommandType.StoredProcedure;

                                                                               cmd.Parameters.AddWithValue("pID", id);

                                                                               cmd.ExecuteNonQuery();

                                                           }

                                       }

                                       internal static int AddNewPost(string name, decimal pay)

                                       {

                                                           using (OracleConnection connection = GetConnection())

                                                           using (OracleCommand cmd = new OracleCommand("CreateNewPost", connection))

                                                           {

                                                                               cmd.CommandType = CommandType.StoredProcedure;

                                                                               cmd.Parameters.AddWithValue("pНАЗВАНИЕ", name);

                                                                               cmd.Parameters.AddWithValue("pЗАРПЛАТА", pay);

                                                                               cmd.Parameters.Add("pID", OracleType.Int32).Direction = ParameterDirection.Output;

                                                                               cmd.ExecuteNonQuery();

                                                                               return (int)cmd.Parameters["pID"].Value;

                                                           }

                                       }

                                       internal static string getHashString(string password)

                                       {

                                                           return Convert.ToBase64String(new MD5CryptoServiceProvider().ComputeHash(Encoding.Unicode.GetBytes(password)));

                                       }

                                       public static void ChangeAccount(int id, string newLogin, string newPassword)

                                       {

                                                           using (OracleConnection connection = GetConnection())

                                                           using (OracleCommand cmd = new OracleCommand("ChangeAccount", connection))

                                                           {

                                                                               cmd.CommandType = CommandType.StoredProcedure;

                                                                               cmd.Parameters.AddWithValue("pID", id);

                                                                               cmd.Parameters.AddWithValue("pLOGIN", newLogin);

                                                                               cmd.Parameters.AddWithValue("pPASSWORD", getHashString(newPassword));

                                                                               cmd.ExecuteNonQuery();

                                                           }

                                       }

                                       public static void UpdatePost(int id, string name, decimal pay)

                                       {

                                                           using (OracleConnection connection = GetConnection())

                                                           using (OracleCommand cmd = new OracleCommand("UPDATE ДОЛЖНОСТЬ SET НАЗВАНИЕ = :НАЗВАНИЕ, ЗАРПЛАТА = :ЗАРПЛАТА WHERE ID = :ID", connection))

                                                           {

                                                                               cmd.Parameters.AddWithValue(":ID", id);

                                                                               cmd.Parameters.AddWithValue(":НАЗВАНИЕ", name);

                                                                               cmd.Parameters.AddWithValue(":ЗАРПЛАТА", pay);

                                                                               cmd.ExecuteNonQuery();

                                                           }

                                       }

                    }

}

#region данные для теста

private void setSampleData()

{

        DbEmployee petrovi4;

        List<DbEmployee> employs = new List<DbEmployee>();

        employs.Add(new DbEmployee("Гришуль", "Евгений", "Сергеевич", "40 00 739929", "3708198", new DateTime(1986, 1, 5), new DateTime(2001, 1, 30), null, 4, "jack", "ahtung", Sample.JackWithCaptainBlack));

        employs.Add(new DbEmployee("Шарипо", "Анна", "Андреевна", "11 22 33", "5161988", new DateTime(1986, 3, 6), new DateTime(2000, 1, 30), null, 3, "ann", "qwerty", Sample.Анютка));

        employs.Add(new DbEmployee("Шакола", "Игорь", "Александрович", ".", "7644504", new DateTime(1986, 2, 14), new DateTime(1996, 8, 11), null, 5, "igor", "love14", Sample.Чуваг));

        employs.Add(new DbEmployee("Сидорук", "Александр", "Александрович", "..", "3222409", new DateTime(1986, 1, 9), new DateTime(2000, 1, 30), null, 5, "sanek", "gomopassword", Sample.Санек));

        employs.Add(petrovi4 = new DbEmployee("Пошломыслов", "Александр", "Петрович", "XXX", "7763466", new DateTime(1986, 4, 8), new DateTime(2000, 1, 30), new DateTime(2000, 2, 14), 5, "alex", "yoniggaz", Sample.Петрович));