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); } }
public static string GetPackaging() { DBConnect objDB = new DBConnect(ConnectionString); SqlCommand objCommand = new SqlCommand(); ArrayList categories = new ArrayList(); objCommand.CommandType = CommandType.StoredProcedure; objCommand.CommandText = "getPackages"; // identify the name of the stored procedure to execute DataSet myDS = objDB.GetDataSetUsingCmdObj(objCommand); int count = 0; foreach (DataRow row in myDS.Tables[0].Rows) { count++; } for (int i = 0; i < count; i++) { Category category = new Category(); category.Packaging = objDB.GetField("Packaging", i).ToString(); categories.Add(category); } JavaScriptSerializer js = new JavaScriptSerializer(); string json = js.Serialize(categories); return(json); }
public static string GetReceipt(string orderNumber) { try { DBConnect objDB = new DBConnect(connectionString); SqlCommand objCommand = new SqlCommand(); objCommand.CommandType = CommandType.StoredProcedure; objCommand.CommandText = "GetUpcForOrder"; objCommand.Parameters.AddWithValue("@ReceiptID", orderNumber); DataSet ds = objDB.GetDataSetUsingCmdObj(objCommand); Item s = new Item(); int count = 0; ArrayList myItemList = new ArrayList(); string SwalText = " <style> table,th,td {border:1px solid black;} </style> <table> <caption align='top'> Order Details </caption> <tr> <th> Category </th> <th> UPC </th> </tr>"; foreach (DataRow row in ds.Tables[0].Rows) { count++; } if (ds.Tables[0].Rows.Count != 0) { for (int i = 0; i < count; i++) { Item myItem = new Item(); myItem.Category = objDB.GetField("Type", i).ToString(); myItem.Packaging = objDB.GetField("Packaging", i).ToString(); myItem.Quantity = Convert.ToInt32(objDB.GetField("Quantity", i)); myItem.Point = Convert.ToInt32(objDB.GetField("Point", i)); myItem.CategoryID = Convert.ToInt32(objDB.GetField("CategoryID", i)); myItemList.Add(myItem); } } SwalText += "</table"; JavaScriptSerializer jss = new JavaScriptSerializer(); string output = jss.Serialize(myItemList); return(output); } catch (Exception ex) { return("ex: " + ex.ToString()); } }
public static string GetAvailableItems() { DBConnect objDB = new DBConnect(ConnectionString); SqlCommand objCommand = new SqlCommand(); ArrayList items = new ArrayList(); objCommand.CommandType = CommandType.StoredProcedure; objCommand.CommandText = "Inventory-GetAvailableItems"; // identify the name of the stored procedure to execute // 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++) { Item item = new Item(); item.Upc = objDB.GetField("UPC", i).ToString(); item.Category = objDB.GetField("Type", i).ToString(); item.Packaging = objDB.GetField("Packaging", i).ToString(); item.Quantity = Convert.ToInt32(objDB.GetField("Quantity", i)); item.Weight = objDB.GetField("Weight", i).ToString(); item.Point = Convert.ToInt32(objDB.GetField("Point", i)); items.Add(item); } JavaScriptSerializer js = new JavaScriptSerializer(); string json = js.Serialize(items); return(json); }
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); } }
public static string GetAllReceipts() { try { DBConnect objDB = new DBConnect(connectionString); SqlCommand objCommand = new SqlCommand(); objCommand.CommandType = CommandType.StoredProcedure; objCommand.CommandText = "GetAllReceipts"; DataSet ds = objDB.GetDataSetUsingCmdObj(objCommand); ArrayList receiptList = new ArrayList(); int count = 0; foreach (DataRow row in ds.Tables[0].Rows) { count++; } if (ds.Tables[0].Rows.Count != 0) { for (int i = 0; i < count; i++) { string order_Number = objDB.GetField("ReceiptID", i).ToString(); int personID = Convert.ToInt32(objDB.GetField("PersonID", i)); string FirstName = objDB.GetField("FirstName", i).ToString(); string LastName = objDB.GetField("LastName", i).ToString(); string checkoutDate = objDB.GetField("CheckoutDate", i).ToString(); string lastUpdateDate = objDB.GetField("LastUpdateDate", i).ToString(); int point = Convert.ToInt32(objDB.GetField("TotalPoints", i).ToString()); int totQty = Convert.ToInt32(objDB.GetField("TotalQuantity", i).ToString()); string lastUpdateUser = objDB.GetField("LastUpdateUser", i).ToString(); DateTime date = DateTime.Parse(checkoutDate); Receipt1 receipt = new Receipt1(); receipt.CheckoutDate = date.ToLongDateString(); receipt.ReceiptID = order_Number; receipt.PersonID = personID; receipt.TotalPoints = point; receipt.TotalQuantity = totQty; receipt.LastUpdateDate = lastUpdateDate; receipt.LastUpdateUser = lastUpdateUser; receipt.FirstName = FirstName; receipt.LastName = LastName; receiptList.Add(receipt); } } JavaScriptSerializer js = new JavaScriptSerializer(); for (int i = 0; i < receiptList.Count; i++) { } string jsonObj = js.Serialize(receiptList); return(jsonObj); } catch (Exception ex) { ArrayList receiptList = new ArrayList(); Receipt1 receipt = new Receipt1(); receipt.CheckoutDate = DateTime.Now.ToString(); receipt.ReceiptID = "0"; receipt.PersonID = 0; receipt.TotalPoints = 0; receipt.TotalQuantity = 0; receipt.LastUpdateDate = "test"; receipt.LastUpdateUser = HttpContext.Current.Session["Access_Net"].ToString(); receipt.FirstName = "Exception"; receipt.LastName = "Exception"; receiptList.Add(receipt); JavaScriptSerializer js = new JavaScriptSerializer(); string jsonObj = js.Serialize(receiptList); return(jsonObj); } }
protected void ddlDonorList_SelectedIndexChanged1(object sender, EventArgs e) { if (ddlDonorList.Text == "Select If Applicable") { txtFirst.Text = ""; txtLast.Text = ""; txtEmail.Text = ""; txtDonorOrganization.Text = ""; ddlDonorType.SelectedIndex = 0; ddlTempleAffil.SelectedIndex = 0; txtTUID.Text = ""; } else { string name = ddlDonorList.SelectedValue; string[] fullname = name.Split(' '); string firstName = fullname[0]; string lastName = fullname[1]; //Get Donor ID DBConnect objDB = new DBConnect(ConfigurationManager.ConnectionStrings["appString"].ConnectionString); SqlCommand objCommand = new SqlCommand(); objCommand.Parameters.Clear(); objCommand.CommandType = CommandType.StoredProcedure; objCommand.CommandText = "FindDonor"; SqlParameter inputParameter3 = new SqlParameter("@FirstName", firstName); inputParameter3.Direction = ParameterDirection.Input; inputParameter3.SqlDbType = SqlDbType.VarChar; objCommand.Parameters.Add(inputParameter3); inputParameter3 = new SqlParameter("@LastName", lastName); inputParameter3.Direction = ParameterDirection.Input; inputParameter3.SqlDbType = SqlDbType.VarChar; objCommand.Parameters.Add(inputParameter3); inputParameter3 = new SqlParameter("@DonorID", SqlDbType.Int); inputParameter3.Direction = ParameterDirection.Output; objCommand.Parameters.Add(inputParameter3); objDB.GetDataSetUsingCmdObj(objCommand); string id = objCommand.Parameters["@DonorID"].Value.ToString(); int theDonorID = int.Parse(id); //Get Donor Details SqlCommand objCommand1 = new SqlCommand(); objCommand1.CommandType = CommandType.StoredProcedure; objCommand1.CommandText = "GetDonorDetails"; objCommand1.Parameters.AddWithValue("@donorID", theDonorID); DataSet ds = objDB.GetDataSetUsingCmdObj(objCommand1); int count = 0; foreach (DataRow row in ds.Tables[0].Rows) { count++; } if (ds.Tables[0].Rows.Count != 0) { for (int i = 0; i < count; i++) { //myItem.Category = objDB.GetField("Category", i).ToString(); txtFirst.Text = objDB.GetField("FirstName", i).ToString(); txtLast.Text = objDB.GetField("LastName", i).ToString(); txtEmail.Text = objDB.GetField("Email", i).ToString(); txtTUID.Text = objDB.GetField("TUID", i).ToString(); if (objDB.GetField("Organization", i).ToString() != "") { txtDonorOrganization.Text = objDB.GetField("Organization", i).ToString(); } else { txtDonorOrganization.Text = "N/A"; } if (objDB.GetField("TempleAffiliation", i).ToString() == "Yes") { ddlTempleAffil.SelectedValue = "Yes"; } else { ddlTempleAffil.SelectedValue = "No"; } if (objDB.GetField("DonorType", i).ToString() == "Individual") { ddlDonorType.SelectedValue = "Individual"; } else if (objDB.GetField("DonorType", i).ToString() == "Organization") { ddlDonorType.SelectedValue = "Organization"; } else { ddlDonorType.SelectedValue = "Anonymous"; } } } } }