Пример #1
0
        public static string GetDonationInfo()
        {
            try
            {
                string     status     = "Active";
                DBConnect  objDB      = new DBConnect(connectionStr);
                SqlCommand objCommand = new SqlCommand();
                ArrayList  Donations  = new ArrayList();

                objCommand.CommandType = CommandType.StoredProcedure;
                objCommand.CommandText = "GetDonationData";     // identify the name of the stored procedure to execute
                objCommand.Parameters.AddWithValue("@Status", status);

                //Execute the stored procedure using the DBConnect object and the SQLCommand object
                DataSet myDS  = objDB.GetDataSetUsingCmdObj(objCommand);
                int     count = 0;

                foreach (DataRow row in myDS.Tables[0].Rows)
                {
                    count++;
                }
                for (int i = 0; i < count; i++)
                {
                    DonationData donation = new DonationData();
                    donation.DonationID   = Convert.ToInt32(objDB.GetField("DonationID", i));
                    donation.DonorID      = Convert.ToInt32(objDB.GetField("DonorID", i));
                    donation.DonorOrgs    = objDB.GetField("Organization", i).ToString();
                    donation.DonorLN      = objDB.GetField("LastName", i).ToString();
                    donation.DonorFN      = objDB.GetField("FirstName", i).ToString();
                    donation.DonorEmail   = objDB.GetField("Email", i).ToString();
                    donation.DonorType    = objDB.GetField("DonorType", i).ToString();
                    donation.DonationType = objDB.GetField("DonationType", i).ToString();
                    DateTime date = DateTime.Parse(objDB.GetField("DonationDate", i).ToString());
                    donation.DonationDate   = date.ToShortDateString();
                    donation.DonationDetail = objDB.GetField("DonationDetail", i).ToString();

                    Donations.Add(donation);
                }

                JavaScriptSerializer js = new JavaScriptSerializer();
                string json             = js.Serialize(Donations);
                return(json);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Пример #2
0
        public static string GetDonationDetail(string DonationID)
        {
            try
            {
                DBConnect  objDB      = new DBConnect(ConfigurationManager.ConnectionStrings["appString"].ConnectionString);
                SqlCommand objCommand = new SqlCommand();
                ArrayList  Ddetails   = new ArrayList();
                objCommand.CommandType = CommandType.StoredProcedure;
                objCommand.CommandText = "GetDonationDetails";     // identify the name of the stored procedure to execute

                objCommand.Parameters.AddWithValue("@donationID", DonationID);
                DataSet myDS  = objDB.GetDataSetUsingCmdObj(objCommand);
                int     count = 0;

                foreach (DataRow row in myDS.Tables[0].Rows)
                {
                    count++;
                }
                for (int i = 0; i < count; i++)
                {
                    DonationData donation = new DonationData();


                    donation.DonationDetail = objDB.GetField("DonationDetail", i).ToString();

                    Ddetails.Add(donation);
                }
                JavaScriptSerializer js = new JavaScriptSerializer();

                string json = js.Serialize(Ddetails);
                return(json);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }