Exemplo n.º 1
0
        public int InsertMenedger(menedger emp1)
        {
            SqlConnection con = new SqlConnection(connectionString);
            SqlCommand cmd = new SqlCommand("Insert into turmenedger(fio,idturoperator,email,phone) values (@fio,@idturoperator,@email,@phone) SET @memberID = @@IDENTITY ", con);
            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add(new SqlParameter("@fio", SqlDbType.NVarChar, 150));
            cmd.Parameters["@fio"].Value = emp1.Fio;
            cmd.Parameters.Add(new SqlParameter("@idturoperator", SqlDbType.Int, 6));
            cmd.Parameters["@idturoperator"].Value = emp1.Idturoperator;
            cmd.Parameters.Add(new SqlParameter("@email", SqlDbType.NVarChar, 50));
            cmd.Parameters["@email"].Value = emp1.Email;
            cmd.Parameters.Add(new SqlParameter("@phone", SqlDbType.NVarChar, 20));
            cmd.Parameters["@phone"].Value = emp1.Phone;
            cmd.Parameters.Add(new SqlParameter("@memberID", SqlDbType.Int, 6));
            cmd.Parameters["@memberID"].Direction = ParameterDirection.Output;

            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
                return (int)cmd.Parameters["@memberID"].Value;
            }
            catch
            {
                throw new ApplicationException("Ошибка данныx. Добавление сотрудника туроператора");
            }
            finally
            {
                con.Close();
            }
        }
Exemplo n.º 2
0
        public menedger GetMenedger(int id)
        {
            SqlConnection con = new SqlConnection(connectionString);
            SqlCommand cmd = new SqlCommand("Select fio, idturoperator, email, phone from menedger where menedger.id = @id", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@id", SqlDbType.Int, 6));
            cmd.Parameters["@id"].Value = id;

            menedger menedger = new menedger();

            try
            {
                con.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                menedger.Fio = (string)reader["fio"];
                menedger.Idturoperator = (int)reader["idturoperator"];
                menedger.Email = (string)reader["email"];
                menedger.Phone = (string)reader["phone"];

                reader.Close();
                return menedger;
            }
            catch
            {
                throw new ApplicationException("Ошибка данныx. Вывод сотрудника");
            }
            finally
            {
                con.Close();
            }
        }