Example #1
0
        public List<turoperator> GetAllTurOperator()
        {
            SqlConnection con = new SqlConnection(connectionString);
            SqlCommand cmd = new SqlCommand("SELECT turoperatorid, name, director, position, orgface,address1, orgemail,orgphone,address2,contactname,contactposition,contactphone,bikbang,bank,rschet,orgschet,inn,kpp,ogrn,okpo FROM turoperator", con);
            cmd.CommandType = CommandType.Text;

            // Создать коллекцию для всех записей
            List<turoperator> list = new List<turoperator>();
            try
            {
                con.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    turoperator emp = new turoperator(
                    (int)reader["id"],
                    (string)reader["name"],
                    (string)reader["director"],
                    (string)reader["position"],
                    (string)reader["orgface"],
                    (string)reader["address1"],
                    (string)reader["orgemail"],
                    (string)reader["orgphone"],
                    (string)reader["address2"],
                    (string)reader["contactname"],
                    (string)reader["contactposition"],
                    (string)reader["contactphone"],
                    (string)reader["bikbank"],
                    (string)reader["bank"],
                    (string)reader["rschet"],
                    (string)reader["orgschet"],
                    (string)reader["inn"],
                    (string)reader["kpp"],
                    (string)reader["ogrn"],
                    (string)reader["okpo"]);

                    list.Add(emp);
                }
                reader.Close();
                return list;
            }
            catch
            {
                throw new ApplicationException("Ошибка данныx. Вывод всех туроператоров");
            }
            finally
            {
                con.Close();
            }
        }
Example #2
0
        public int InsertOrganization(turoperator emp1)
        {
            SqlConnection con = new SqlConnection(connectionString);
            SqlCommand cmd = new SqlCommand("InsertTuroperator", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@Director", SqlDbType.NVarChar, 200));
            cmd.Parameters["@Director"].Value = emp1.Director;
            cmd.Parameters.Add(new SqlParameter("@Name", SqlDbType.NVarChar, 50));
            cmd.Parameters["@Name"].Value = emp1.Name;
            cmd.Parameters.Add(new SqlParameter("@Position", SqlDbType.NVarChar, 50));
            cmd.Parameters["@Position"].Value = emp1.Position;
            cmd.Parameters.Add(new SqlParameter("@Orgface", SqlDbType.NVarChar, 200));
            cmd.Parameters["@Orgface"].Value = emp1.Orgface;
            cmd.Parameters.Add(new SqlParameter("@Address1", SqlDbType.NVarChar, 200));
            cmd.Parameters["@Address1"].Value = emp1.Address1;
            cmd.Parameters.Add(new SqlParameter("@Orgemail", SqlDbType.NVarChar, 50));
            cmd.Parameters["@Orgemail"].Value = emp1.Orgemail;
            cmd.Parameters.Add(new SqlParameter("@Orgphone", SqlDbType.NVarChar, 20));
            cmd.Parameters["@Orgphone"].Value = emp1.Orgphone;
            cmd.Parameters.Add(new SqlParameter("@Address2", SqlDbType.NVarChar, 200));
            cmd.Parameters["@Address2"].Value = emp1.Address2;
            cmd.Parameters.Add(new SqlParameter("@Contactname", SqlDbType.NVarChar, 150));
            cmd.Parameters["@Contactname"].Value = emp1.Contactname;
            cmd.Parameters.Add(new SqlParameter("@Bank", SqlDbType.NVarChar, 50));
            cmd.Parameters["@Bank"].Value = emp1.Bank;
            cmd.Parameters.Add(new SqlParameter("@Contactposition", SqlDbType.NVarChar, 50));
            cmd.Parameters["@Contactposition"].Value = emp1.Contactposition;
            cmd.Parameters.Add(new SqlParameter("@Rschet", SqlDbType.NVarChar, 50));
            cmd.Parameters["@Rschet"].Value = emp1.Rschet;
            cmd.Parameters.Add(new SqlParameter("@Contactphone", SqlDbType.NVarChar, 20));
            cmd.Parameters["@Contactphone"].Value = emp1.Contactphone;
            cmd.Parameters.Add(new SqlParameter("@Orgschet", SqlDbType.NVarChar, 100));
            cmd.Parameters["@Orgschet"].Value = emp1.Orgschet;
            cmd.Parameters.Add(new SqlParameter("@Bikbank", SqlDbType.NVarChar, 50));
            cmd.Parameters["@Bikbank"].Value = emp1.Bikbank;
            cmd.Parameters.Add(new SqlParameter("@Inn", SqlDbType.NVarChar, 50));
            cmd.Parameters["@Inn"].Value = emp1.Inn;
            cmd.Parameters.Add(new SqlParameter("@Kpp", SqlDbType.NVarChar, 50));
            cmd.Parameters["@Kpp"].Value = emp1.Kpp;
            cmd.Parameters.Add(new SqlParameter("@Ogrn", SqlDbType.NVarChar, 50));
            cmd.Parameters["@Ogrn"].Value = emp1.Ogrn;
            cmd.Parameters.Add(new SqlParameter("@Okpo", SqlDbType.NVarChar, 50));
            cmd.Parameters["@Okpo"].Value = emp1.Okpo;
            cmd.Parameters.Add(new SqlParameter("@turoperatorID", SqlDbType.Int, 4));
            cmd.Parameters["@TuroperatorID"].Direction = ParameterDirection.Output;

            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
                return (int)cmd.Parameters["@TuroperatorID"].Value;
            }
            catch
            {
                throw new ApplicationException("Ошибка данныx.");
            }
            finally
            {
                con.Close();
            }
        }
Example #3
0
        public int AddTurOperator(turoperator  emp1)
        {
            SqlConnection con = new SqlConnection(connectionString);
            SqlCommand cmd = new SqlCommand("Insert into turoperator (name, director,position,orgface,address1,orgemail,orgphone,address2,contactname,contactposition,contactphone,bikbank,bank,rschet,orgschet,inn,kpp,ogrn,okpo) values (@name, @director,@position,@orgface,@address1,@orgemail,@orgphone,@address2,@contactname,@contactposition,@contactphone,@bikbank,@bank,@rschet,@orgschet,@inn,@kpp,@ogrn,@okpo) SET @turoperatorid = @@IDENTITY", con);
            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add(new SqlParameter("@Director", SqlDbType.NVarChar, 200));
            cmd.Parameters["@Director"].Value = emp1.Director;
            cmd.Parameters.Add(new SqlParameter("@Name", SqlDbType.NVarChar, 50));
            cmd.Parameters["@Name"].Value = emp1.Name;
            cmd.Parameters.Add(new SqlParameter("@Position", SqlDbType.NVarChar, 50));
            cmd.Parameters["@Position"].Value = emp1.Position;
            cmd.Parameters.Add(new SqlParameter("@Orgface", SqlDbType.NVarChar, 200));
            cmd.Parameters["@Orgface"].Value = emp1.Orgface;
            cmd.Parameters.Add(new SqlParameter("@Address1", SqlDbType.NVarChar, 200));
            cmd.Parameters["@Address1"].Value = emp1.Address1;
            cmd.Parameters.Add(new SqlParameter("@Orgemail", SqlDbType.NVarChar, 50));
            cmd.Parameters["@Orgemail"].Value = emp1.Orgemail;
            cmd.Parameters.Add(new SqlParameter("@Orgphone", SqlDbType.NVarChar, 20));
            cmd.Parameters["@Orgphone"].Value = emp1.Orgphone;
            cmd.Parameters.Add(new SqlParameter("@Address2", SqlDbType.NVarChar, 200));
            cmd.Parameters["@Address2"].Value = emp1.Address2;
            cmd.Parameters.Add(new SqlParameter("@Contactname", SqlDbType.NVarChar, 150));
            cmd.Parameters["@Contactname"].Value = emp1.Contactname;
            cmd.Parameters.Add(new SqlParameter("@Bank", SqlDbType.NVarChar, 50));
            cmd.Parameters["@Bank"].Value = emp1.Bank;
            cmd.Parameters.Add(new SqlParameter("@Contactposition", SqlDbType.NVarChar, 50));
            cmd.Parameters["@Contactposition"].Value = emp1.Contactposition;
            cmd.Parameters.Add(new SqlParameter("@Rschet", SqlDbType.NVarChar, 50));
            cmd.Parameters["@Rschet"].Value = emp1.Rschet;
            cmd.Parameters.Add(new SqlParameter("@Contactphone", SqlDbType.NVarChar, 20));
            cmd.Parameters["@Contactphone"].Value = emp1.Contactphone;
            cmd.Parameters.Add(new SqlParameter("@Orgschet", SqlDbType.NVarChar, 100));
            cmd.Parameters["@Orgschet"].Value = emp1.Orgschet;
            cmd.Parameters.Add(new SqlParameter("@Bikbank", SqlDbType.NVarChar, 50));
            cmd.Parameters["@Bikbank"].Value = emp1.Bikbank;
            cmd.Parameters.Add(new SqlParameter("@Inn", SqlDbType.NVarChar, 50));
            cmd.Parameters["@Inn"].Value = emp1.Inn;
            cmd.Parameters.Add(new SqlParameter("@Kpp", SqlDbType.NVarChar, 50));
            cmd.Parameters["@Kpp"].Value = emp1.Kpp;
            cmd.Parameters.Add(new SqlParameter("@Ogrn", SqlDbType.NVarChar, 50));
            cmd.Parameters["@Ogrn"].Value = emp1.Ogrn;
            cmd.Parameters.Add(new SqlParameter("@Okpo", SqlDbType.NVarChar, 50));
            cmd.Parameters["@Okpo"].Value = emp1.Okpo;
            cmd.Parameters.Add(new SqlParameter("@turoperatorID", SqlDbType.Int, 4));
            cmd.Parameters["@turoperatorID"].Direction = ParameterDirection.Output;

            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
                return (int)cmd.Parameters["@turoperatorID"].Value;
            }
            catch
            {
                return 0;
                throw new ApplicationException("Ошибка данныx. Добавление тур оператора");

            }
            finally
            {
                con.Close();
            }
        }