Пример #1
0
        public static void InsertOrder(int UserID, int ItemID, string Address, double Cost, int Quantity)
        {
            int random        = 0;
            int deliverymanID = 1;
            var deliverymen   = ManagerViewModel.GetDeliverymen();

            while (random == 0)
            {
                System.Random r = new System.Random(System.DateTime.Now.Second);
                deliverymanID = r.Next(deliverymen.Count + 1);
                for (int i = 0; i < deliverymen.Count; i++)
                {
                    if (deliverymanID == deliverymen[i].ID)
                    {
                        random = 1;
                    }
                }
            }

            using (MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["DB"].ConnectionString))
            {
                DataTable dt = new DataTable();
                using (MySqlCommand cmd = new MySqlCommand("InsertOrder", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("UserID", UserID);
                    cmd.Parameters.AddWithValue("ItemID", ItemID);
                    cmd.Parameters.AddWithValue("Address", Address);
                    cmd.Parameters.AddWithValue("Cost", Cost);
                    cmd.Parameters.AddWithValue("Quantity", Quantity);
                    cmd.Parameters.AddWithValue("DeliverymanID", deliverymanID);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                }
            }
        }
Пример #2
0
 public ActionResult Deliverymen()
 {
     return(View(ManagerViewModel.GetDeliverymen()));
 }
Пример #3
0
        public static void UserSubmitReview(int UserID, int isVVIP, int ItemID, int ChefID, int DeliverymanID, int Rating, int DeliveryRating, int Approval, string Comment)
        {
            int Delivery_Approval = 0;

            if (DeliveryRating >= 3)
            {
                Delivery_Approval = 1;
            }
            else
            {
                Delivery_Approval = -1;
            }

            Deliveryman deliveryman = new Deliveryman();

            var deliverymen = ManagerViewModel.GetDeliverymen();

            for (int j = 0; j < deliverymen.Count; j++)
            {
                if (deliverymen[j].ID == DeliverymanID)
                {
                    deliveryman = deliverymen[j];
                }
            }


            if (Rating >= 3)
            {
                Approval = 1;
            }
            else
            {
                Approval = -1;
            }

            Chef chef = new Chef();

            var ChefList = ManagerViewModel.GetChefs();

            for (int i = 0; i < ChefList.Count; i++)
            {
                if (ChefList[i].ID == ChefID)
                {
                    chef = ChefList[i];
                }
            }

            if (isVVIP == 1)
            {
                Approval          *= 2;
                Delivery_Approval *= 2;
            }

            chef.Approval        += Approval;
            deliveryman.Approval += Delivery_Approval;
            using (MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["DB"].ConnectionString))
            {
                DataTable dt = new DataTable();
                using (MySqlCommand cmd = new MySqlCommand("UpdateChefApproval", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("ChefID", ChefID);
                    cmd.Parameters.AddWithValue("Approval", chef.Approval);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                }
            }

            using (MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["DB"].ConnectionString))
            {
                DataTable dt = new DataTable();
                using (MySqlCommand cmd = new MySqlCommand("UpdateDeliverymanApproval", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("DeliverymanID", DeliverymanID);
                    cmd.Parameters.AddWithValue("Approval", deliveryman.Approval);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                }
            }

            using (MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["DB"].ConnectionString))
            {
                DataTable dt = new DataTable();
                using (MySqlCommand cmd = new MySqlCommand("UserSubmitReview", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("UserID", UserID);
                    cmd.Parameters.AddWithValue("ItemID", ItemID);
                    cmd.Parameters.AddWithValue("ChefID", ChefID);
                    cmd.Parameters.AddWithValue("Rating", Rating);
                    cmd.Parameters.AddWithValue("Approval", Approval);
                    cmd.Parameters.AddWithValue("Comment", Comment);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                }
            }
        }