Exemplo n.º 1
0
        public int InsertOrder(Order emp1)
        {
            SqlConnection con = new SqlConnection(connectionString);
                SqlCommand cmd = new SqlCommand("InsertOrder", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@numbdogov", SqlDbType.NVarChar, 50));
                cmd.Parameters["@numbdogov"].Value = emp1.Numbdogov;
                cmd.Parameters.Add(new SqlParameter("@t_bazaID", SqlDbType.Int, 6));
                cmd.Parameters["@t_bazaID"].Value = emp1.T_bazaID;

                cmd.Parameters.Add(new SqlParameter("@clientIDppl", SqlDbType.Int, 6));
                cmd.Parameters["@clientIDppl"].Value = emp1.ClientIDppl;

                cmd.Parameters.Add(new SqlParameter("@datein", SqlDbType.NVarChar, 20));
                cmd.Parameters["@datein"].Value = emp1.Datein;
                cmd.Parameters.Add(new SqlParameter("@dateout", SqlDbType.NVarChar, 20));
                cmd.Parameters["@dateout"].Value = emp1.Dateout;
                cmd.Parameters.Add(new SqlParameter("@orderID", SqlDbType.Int, 6));
                cmd.Parameters["@orderID"].Direction = ParameterDirection.Output;

                try
                {
                    con.Open();
                    cmd.ExecuteNonQuery();
                    return (int)cmd.Parameters["@orderID"].Value;
                }
                catch
                {
                    throw new ApplicationException("Ошибка данныx.");
                }
                finally
                {
                    con.Close();
                }
        }
Exemplo n.º 2
0
        public List<Order> GetAllOrders()
        {
            SqlConnection con = new SqlConnection(connectionString);
                SqlCommand cmd = new SqlCommand("GetAllOrders", con);
                cmd.CommandType = CommandType.StoredProcedure;

                List<Order> Orders = new List<Order>();

                try
                {
                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {

                        Order emp = new Order(
                        (int)reader["orderID"],
                        (string)reader["numbdogov"],
                        (int)reader["t_bazaID"],

                        (int)reader["clientIDppl"],

                       // turists,
                        (string)reader["datein"],
                        (string)reader["dateout"]
                        );

                        Orders.Add(emp);
                    }
                    reader.Close();
                    return Orders;
                }
                catch
                {
                    throw new ApplicationException("Ошибка данныx.");
                }
                finally
                {
                    con.Close();
                }
        }
Exemplo n.º 3
0
        public Order GetOrdere(int orderid)
        {
            SqlConnection con = new SqlConnection(connectionString);
                SqlCommand cmd = new SqlCommand("GetOrder", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@orderID", SqlDbType.Int, 6));
                cmd.Parameters["@orderID"].Value = orderid;

                Order Or = new Order();
                try
                {
                    con.Open();

                    SqlDataReader reader = cmd.ExecuteReader();
                        Or.OrderID = orderid;
                        Or.Numbdogov = (string)reader["numbdogov"];
                        Or.T_bazaID = (int)reader["t_bazaID"];

                        Or.ClientIDppl = (int)reader["clientIDppl"];
                        Or.Datein = (string)reader["datein"];
                        Or.Dateout = (string)reader["dateout"];

                        reader.Close();
                        return Or;

                }
                catch
                {
                    throw new ApplicationException("Ошибка данныx.");
                }
                finally
                {
                    con.Close();
                }
        }