コード例 #1
0
        public static TourLead GetTourLeaderById(int id)
        {
            TourLead tourlead = null;

            using (SqlConnection conn = new SqlConnection(Data.connectionString))
            {
                conn.Open();

                string     sql = @"SELECT * from TourLeaderDTOes
                             WHERE Id = '" + id + "'";
                SqlCommand cmd = new SqlCommand(sql, conn);

                SqlDataReader reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    tourlead = new TourLead()
                    {
                        Id   = (int)reader["Id"],
                        Name = (string)reader["Name"],
                        Rank = (string)reader["Rank"]
                    };
                }

                conn.Close();
            }
            return(tourlead);
        }
コード例 #2
0
        public ActionResult Calculate(int Id, int Day)
        {
            TourLead lead = TourLeaderData.GetTourLeaderById(Id);

            string name = lead.Name;
            string Rank = lead.Rank;

            int DailyRate = 0;
            int cost      = 0;

            //if (Id == null)
            //{
            //    return View();
            //}
            //else
            //{

            if (Rank == "M1")
            {
                DailyRate = 500;
            }
            else if (Rank == "M2")
            {
                DailyRate = 400;
            }
            else if (Rank == "M3")
            {
                DailyRate = 300;
            }
            //}
            cost             = DailyRate * Day;
            ViewData["cost"] = cost;
            ViewData["Id"]   = Id;
            ViewData["Name"] = name;
            ViewData["Rank"] = Rank;
            return(View());
        }