コード例 #1
0
        //==============================================================================================
        public string DisplayCourtOwner(string userID)
        {
            string json;
            List <CourtDetails> log = new List <CourtDetails>();

            int user_id1 = int.Parse(userID);

            using (SqlConnection con = new SqlConnection(connString))
            {
                SqlCommand cmd = new SqlCommand("CourtOwner.GetCourtDetailsByUserID", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("user", user_id1);

                con.Open();

                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    CourtDetails p = new CourtDetails();

                    p.CourtID = rdr.SafeGetInt32(0);

                    p.CName     = rdr.SafeGetString(1);
                    p.CProvince = rdr.SafeGetString(2);
                    p.CCity     = rdr.SafeGetString(3);
                    int a = rdr.SafeGetByte(4);
                    p.CCapacity = a.ToString();
                    p.CAddress  = rdr.SafeGetString(5);
                    p.CDesc     = rdr.SafeGetString(6);
                    log.Add(p);
                }

                con.Close();
            }
            json = JsonConvert.SerializeObject(log);

            return(json);
        }
コード例 #2
0
        // GET COURT ID TO CREATE SCHEDULE UPON COURT REGISTRATION
        public string GetCourtID(CourtDetails courtInfo, string userID)
        {
            CourtDetails GetCourtID = new CourtDetails();
            string       resultVal;

            try
            {
                using (var connection = new SqlConnection(connString))
                {
                    connection.Open();

                    SqlCommand command = new SqlCommand("CourtOwner.GetCourtIdForSchedule", connection);
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("UserId", userID);
                    command.Parameters.AddWithValue("Court_Name", courtInfo.CName);
                    command.Parameters.AddWithValue("Court_Desc", courtInfo.CDesc);
                    command.Parameters.AddWithValue("Court_Capacity", courtInfo.CCapacity);
                    command.Parameters.AddWithValue("Court_Address", courtInfo.CAddress);
                    command.Parameters.AddWithValue("Court_Province", courtInfo.CProvince);
                    command.Parameters.AddWithValue("Court_City", courtInfo.CCity);

                    SqlDataReader dr = command.ExecuteReader();
                    while (dr.Read())
                    {
                        GetCourtID.CourtID = int.Parse(dr[0].ToString());
                    }

                    connection.Close();
                }

                resultVal = JsonConvert.SerializeObject(GetCourtID);
            }
            catch (Exception ex)
            {
                resultVal = ex.Message;
            }

            return(resultVal);
        }