public static string Remove_From_Shopping_Cart(MySqlConnection dbconn, int pProductId, double pMeasurementUnit, int pQuantity, double pAmount) { if (HttpContext.Current.Session["SHOPPING_CART_ID"] != null) { CommonClass.ExecuteQuery("REMOVE_FROM_SHOPPING_CART", new string[] { "P_SHOPPING_CART_ID", "P_PRODUCT_ID", "P_MEASUREMENT_UNIT" }, new string[] { HttpContext.Current.Session["SHOPPING_CART_ID"].ToString(), pProductId.ToString(), pMeasurementUnit.ToString() }, dbconn); HttpContext.Current.Session["SHOPPING_ITEMS"] = (int.Parse(HttpContext.Current.Session["SHOPPING_ITEMS"].ToString()) - pQuantity).ToString(); HttpContext.Current.Session["SHOPPING_ITEMS_VALUE"] = (double.Parse(HttpContext.Current.Session["SHOPPING_ITEMS_VALUE"].ToString()) - (pAmount)).ToString(); } return(Get_Shopping_Cart_Item_Count()); }
public static string Update_Shopping_Cart(MySqlConnection dbconn, int pProductId, double pMeasurementUnit, int pOldQuantity, int pQuantity, double pPrice) { if (HttpContext.Current.Session["SHOPPING_CART_ID"] != null) { CommonClass.ExecuteQuery("UPDATE_SHOPPING_CART", new string[] { "P_SHOPPING_CART_ID", "P_PRODUCT_ID", "P_MEASUREMENT_UNIT", "P_QUANTITY" }, new string[] { HttpContext.Current.Session["SHOPPING_CART_ID"].ToString(), pProductId.ToString(), pMeasurementUnit.ToString(), pQuantity.ToString() }, dbconn); HttpContext.Current.Session["SHOPPING_ITEMS"] = (int.Parse(HttpContext.Current.Session["SHOPPING_ITEMS"].ToString()) - pOldQuantity + pQuantity).ToString(); HttpContext.Current.Session["SHOPPING_ITEMS_VALUE"] = (double.Parse(HttpContext.Current.Session["SHOPPING_ITEMS_VALUE"].ToString()) - (pOldQuantity * pPrice) + (pQuantity * pPrice)).ToString(); } return(Get_Shopping_Cart_Item_Count()); }
public static void Generate_GUID(string pEmail, string pUserName, Label pLabel, MySqlConnection dbconn) { MySqlTransaction Transaction = dbconn.BeginTransaction(); // Repeater lEmailRepeater = User_FormView.FindControl("Email_Repeater") as Repeater; //Label lEmailMessageLabel = User_FormView.FindControl("Email_Validation_Message") as Label; //lEmailMessageLabel.Visible = true; try { Guid g = Guid.NewGuid(); Guid lUserGuid = Guid.NewGuid(); CommonClass.ExecuteQuery("ADD_GUID", new string[] { "P_EXTERNAL_USER_ID", "P_EMAIL", "P_GUID", "P_USER_GUID" }, new string[] { ClaimsPrincipal.Current.FindFirst("user_id").Value, pEmail, g.ToString(), lUserGuid.ToString() }, dbconn); Messages.Send_Welcome_Email_Validate_Message(pEmail, pUserName, g.ToString(), lUserGuid.ToString(), dbconn); // Bind_Contacts("2", dbconn, lEmailRepeater); Transaction.Commit(); pLabel.Text = "Validation Email Sent"; //User_FormView.FindControl("Email_PlaceHolder").Visible = true; pLabel.ForeColor = Color.Green; } catch (Exception ex) { Transaction.Rollback(); pLabel.Text = ex.Message; pLabel.Visible = true; pLabel.ForeColor = Color.Red; } }
public static string Add_To_Shopping_Cart(MySqlConnection dbconn, int pProductId, double pMeasurementUnit, int pQuantity, double pPrice) { Create_Shopping_Cart(dbconn); CommonClass.ExecuteQuery("ADD_TO_SHOPPING_CART", new string[] { "P_SHOPPING_CART_ID", "P_PRODUCT_ID", "P_MEASUREMENT_UNIT", "P_QUANTITY" }, new string[] { HttpContext.Current.Session["SHOPPING_CART_ID"].ToString(), pProductId.ToString(), pMeasurementUnit.ToString(), pQuantity.ToString() }, dbconn); string message = pQuantity + " item"; if (pQuantity > 1) { message += "s"; } message += " added to shopping cart"; System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<script type = 'text/javascript'>"); sb.Append("window.onload=function(){"); sb.Append("alert('"); sb.Append(message); sb.Append("')};"); sb.Append("</script>"); HttpContext.Current.Response.Write(sb.ToString()); //Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString()); HttpContext.Current.Session["SHOPPING_ITEMS"] = (int.Parse(HttpContext.Current.Session["SHOPPING_ITEMS"].ToString()) + pQuantity).ToString(); HttpContext.Current.Session["SHOPPING_ITEMS_VALUE"] = (double.Parse(HttpContext.Current.Session["SHOPPING_ITEMS_VALUE"].ToString()) + (pQuantity * pPrice)).ToString(); return(Get_Shopping_Cart_Item_Count()); }
public static void Ship_Order(MySqlConnection dbconn, string pOrderId, string pOrderNumber, string pCustomerId, string pCourierAgencyId, string pCourierAgencyName, string pShippingDate, string pReferenceNumber) { CommonClass.ExecuteQuery("ADD_SHIPPING_INFO", new string[] { "P_ORDER_ID", "P_AGENCY_ID", "P_SHIPPING_DATE", "P_SHIPPING_REFERENCE", "P_EXTERNAL_USER_ID" }, new string[] { pOrderId, pCourierAgencyId, pShippingDate, pReferenceNumber, ClaimsPrincipal.Current.FindFirst("user_id").Value }, dbconn); string lShippingDetails = ""; if (pCourierAgencyName != "") { lShippingDetails = "through " + pCourierAgencyName + ", Ref No : " + pReferenceNumber; } Messages.Send_Shipping_Confirmation(pOrderNumber, pCustomerId, lShippingDetails, pCourierAgencyId, pReferenceNumber, dbconn); }
public static void Allocate_Order( MySqlConnection dbconn, string p_UserId) { MySqlConnection dbconn1 = new MySqlConnection(CommonClass.connectionstring); MySqlConnection dbconn2 = new MySqlConnection(CommonClass.connectionstring); dbconn1.Open(); dbconn2.Open(); MySqlDataReader lMySqlDataReader1 = CommonClass.FetchRecords("GET_UNALLOCATED_PAYMENT_BY_USER_ID", new string[] { "P_USER_ID" }, new string[] { p_UserId }, dbconn1); MySqlDataReader lMySqlDataReader = CommonClass.FetchRecords("GET_DUE_ORDER_LIST_BY_USER_ID", new string[] { "P_USER_ID" }, new string[] { p_UserId }, dbconn); double lUnallocated_Amount = 0; string lPaymentId = null; while (lMySqlDataReader.Read()) { string lOrderId = lMySqlDataReader["ORDER_ID"].ToString(); double lOrderDue = double.Parse(lMySqlDataReader["ORDER_DUE"].ToString()); while (lOrderDue != 0) { double lAllocatedAmount = 0; if (lUnallocated_Amount == 0) { if (lMySqlDataReader1.Read()) { lUnallocated_Amount = double.Parse(lMySqlDataReader1["UNALLOCATED_AMOUNT"].ToString()); lPaymentId = lMySqlDataReader1["PAYMENT_ID"].ToString(); } else { break; } } if (lOrderDue >= lUnallocated_Amount) { lAllocatedAmount = lUnallocated_Amount; lOrderDue -= lUnallocated_Amount; lUnallocated_Amount = 0; } else { lUnallocated_Amount -= lOrderDue; lAllocatedAmount = lOrderDue; lOrderDue = 0; } CommonClass.ExecuteQuery("ADD_PAYMENT_ORDER", new string[] { "P_PAYMENT_ID", "P_ORDER_ID", "P_AMOUNT" }, new string[] { lPaymentId, lOrderId, lAllocatedAmount.ToString() }, dbconn2); } } lMySqlDataReader.Close(); lMySqlDataReader1.Close(); dbconn1.Close(); dbconn2.Close(); }
public static void Create_Order(MySqlConnection dbconn, string CustomerId, string GrandTotal, string ShippingCharges, string Discounts, string AddressId, string PromotionId, string PaymentType, string Status, string DeliveryMethod) { string[] lRecords = CommonClass.ExecuteQuery("ADD_ORDER", new string[] { "P_USER_ID", "P_EXTERNAL_USER_ID", "P_ORDER_TOTAL", "P_SHIPPING_CHARGE", "P_DISCOUNTS", "P_ADDRESS_ID", "P_PROMOTION_ID", "P_PAYMENT_TYPE", "P_ORDER_STATUS", "P_DELIVERY_METHOD", "P_SHOPPING_CART_ID" }, new string[] { CustomerId, ClaimsPrincipal.Current.FindFirst("user_id").Value, GrandTotal, ShippingCharges, Discounts, AddressId, PromotionId, PaymentType, Status, DeliveryMethod, HttpContext.Current.Session["SHOPPING_CART_ID"].ToString() }, new string[] { "P_ORDER_ID" }, dbconn); string lOrderid = lRecords[0]; if (PaymentType == "Others") { UserModel lUserModel = CommonClass.Get_External_User_Profile(dbconn); PaymentClass.Initiate_CCAvenue_Order(lOrderid, GrandTotal, lUserModel.Email_Address, lUserModel.Mobile_Number, AddressId, dbconn); dbconn.Close(); } else { Confirm_Order(dbconn, lOrderid); dbconn.Close(); HttpContext.Current.Session.Abandon(); HttpContext.Current.Session.Clear(); HttpContext.Current.Response.Redirect("~/OrderSummary.aspx?Order_Id=" + lOrderid); } }
public static void MigrateUser(MySqlConnection dbconn, string pUserid, string pFullName, string pEmail, string pEmailValidated) { Guid lGuid = Guid.NewGuid(); Guid lUserGuid = Guid.NewGuid(); string[] lRecords = CommonClass.ExecuteQuery("MIGRATE_USER", new string[] { "P_EXTERNAL_USER_ID", "P_USER_NAME", "P_EMAIL_ADDRESS", "P_GUID", "P_USERID_GUID", "P_EMAIL_VALIDATED_BY_PROVIDER" }, new string[] { pUserid, pFullName, pEmail, lGuid.ToString(), lUserGuid.ToString(), pEmailValidated }, new string[] { "P_USER_ID", "P_NEW_USER", "P_EMAIL_ADDRESS_VALIDATED", "P_USER_TYPE_ID" }, dbconn); if (lRecords[1] == "1") { if (pEmailValidated == "0") { Messages.Send_Welcome_Email_Validate_Message(pEmail, pFullName, lGuid.ToString(), lUserGuid.ToString(), dbconn); } else { Add_To_MailChimp(pEmail, pFullName); Messages.Send_Welcome_Message(pEmail, pFullName, dbconn); } // Messages.Send_Mobile_Validate_Message("9980075754", "Karpaga Kumar", "12345", dbconn); Messages.send_sms("9980075754", "Dear Karpaga Kumar," + pEmail + " - " + "New User has been registered-Thanks"); } }