コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string stringID = Request.QueryString["@"];
                int    userID   = Convert.ToInt32(stringID);

                int    recoveryCode     = retrieveCode(userID);
                string recoveryCodeSend = recoveryCode.ToString();

                string registeredEmail = retrieveEmail(userID);

                GmailSMTP smtp = new GmailSMTP();
                smtp.Send(registeredEmail, "MarketStory Activation Code", "Email Code: " + recoveryCodeSend, true);

                int    otp     = retrieveOtp(userID);
                string otpSend = otp.ToString();

                int registeredMobile = retrieveMobile(userID);
                Response.Write(otp);
                string url = "http://gateway.onewaysms.sg:10002/api.aspx?apiusername=APIRBRI6I1ZYE&apipassword=APIRBRI6I1ZYERBRI6&mobileno=65" + registeredMobile + "&senderid=MarketStory&languagetype=1&message=OTP: " + otpSend;

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Method      = "GET";
                request.ContentType = "application/x-www-form-urlencoded";
                request.Accept      = "Accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";

                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "ThanksPopScript", "alert('Successfully Registered\\n\\An email has been sent to your registered email address\\n\\Enter the code found in the email in the box provided');", true);

                string stringID = Request.QueryString["@"];
                int    userID   = Convert.ToInt32(stringID);

                int    activationCode     = retrieveCode(userID);
                string activationCodeSend = activationCode.ToString();

                string registeredEmail = retrieveEmail(userID);

                GmailSMTP smtp = new GmailSMTP();
                smtp.Send(registeredEmail, "MarketStory Activation Code", "Activation Code: " + activationCodeSend, true);
            }
        }
コード例 #3
0
        private void confirmDelivery(int orderedProductsID, ListViewCommandEventArgs e)
        {
            OrderedProduct op     = new OrderedProduct();
            User           seller = new User();

            if (HiddenField1.Value == "Yes")
            {
                if (op.checkDeliveryStatusConfirmed(orderedProductsID) == false)
                {
                    if (op.checkDeliveryStatusPending(orderedProductsID) == true)
                    {
                        ScriptManager.RegisterStartupScript(this, typeof(string), "confirmDeliveryFailedScript", "alert('This item is still pending!');", true);
                    }
                    else
                    {
                        op.updateDeliveryStatus(orderedProductsID, "Delivery Confirmed");

                        int sellerID = Convert.ToInt32(((HiddenField)e.Item.FindControl("HiddenField1")).Value);
                        sellerID = 1;
                        int totalPrice = Convert.ToInt32(((Label)e.Item.FindControl("displayPrice")).Text) * Convert.ToInt32(((Label)e.Item.FindControl("displayOrderedQuantity")).Text);
                        seller.updateUserAccountBalance(sellerID, totalPrice);
                        seller.updateUserMSPoints(sellerID, 5);

                        seller = seller.retrieveUser(sellerID);
                        GmailSMTP smtp                  = new GmailSMTP();
                        string    itemName              = ((Label)e.Item.FindControl("displayProductName")).Text;
                        string    itemOrderedQuantity   = ((Label)e.Item.FindControl("displayOrderedQuantity")).Text;
                        string    itemDeliveryConfirmed = "Item: " + itemName + "\nQuantity ordered from Buyer: " + itemOrderedQuantity + "\nDelivery confirmed on: " + DateTime.Now.ToString() + "\n\nYour earnings of $" + totalPrice + " has been credited to your account\n\nThank you for using MarketStory";
                        smtp.Send(seller.getEmail(), "MarketStory Item Delivery Confirmed", "The following item has been confirmed to be sent to the buyer: \n\n" + itemDeliveryConfirmed, true);

                        ScriptManager.RegisterStartupScript(this, typeof(string), "confirmDeliverySuccessScript", "alert('Delivery confirmed!');", true);
                        orderedContentList.DataBind();
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, typeof(string), "confirmDeliveryFailedScript", "alert('This item has already been confirmed of delivery!');", true);
                }
            }
            else if (HiddenField1.Value == "No")
            {
            }
        }
コード例 #4
0
        protected void ButtonResend_Click(object sender, EventArgs e)
        {
            string stringID = Request.QueryString["@"];
            int    userID   = Convert.ToInt32(stringID);

            Random rand = new Random((int)DateTime.Now.Ticks);
            int    RandomNumber;

            RandomNumber = rand.Next(100000, 999999);
            updateCode(userID, RandomNumber);
            string newCode = RandomNumber.ToString();

            string registeredEmail = retrieveEmail(userID);

            GmailSMTP smtp = new GmailSMTP();

            smtp.Send(registeredEmail, "MarketStory Activation Code", "Activation Code: " + newCode, true);

            resetActivationCount(userID);
        }
コード例 #5
0
        private void updateOrderedProduct(string orderedProductsID, ListViewCommandEventArgs e)
        {
            if (((DropDownList)e.Item.FindControl("productDeliveryStatus")).SelectedValue == "CANCELLED" && ((TextBox)e.Item.FindControl("additionalComments")).Text == "")
            {
                ScriptManager.RegisterStartupScript(this, typeof(string), "requestCancelledScript", "alert('Please leave your reason for cancellation of the order request in the Additional Comments section!');", true);
            }
            else
            {
                SqlDataSource1.UpdateParameters.Add("@productDeliveryStatus", ((DropDownList)e.Item.FindControl("productDeliveryStatus")).SelectedValue);
                SqlDataSource1.UpdateParameters.Add("@trackingInformation", ((TextBox)e.Item.FindControl("trackingInformation")).Text);
                SqlDataSource1.UpdateParameters.Add("@orderedProductsID", orderedProductsID);
                SqlDataSource1.UpdateParameters.Add("@additionalCOmments", ((TextBox)e.Item.FindControl("additionalComments")).Text);
                SqlDataSource1.Update();

                if (((DropDownList)e.Item.FindControl("productDeliveryStatus")).SelectedValue == "On Delivery")
                {
                    User buyer = new User();
                    buyer = buyer.retrieveUser(Convert.ToInt32(((HiddenField)e.Item.FindControl("HiddenField1")).Value));
                    GmailSMTP smtp                = new GmailSMTP();
                    string    itemName            = ((Label)e.Item.FindControl("displayProductName")).Text;
                    string    itemOrderedQuantity = ((Label)e.Item.FindControl("displayOrderedQuantity")).Text;
                    string    itemSentOnDelivery  = "Item: " + itemName + "\nQuantity you ordered: " + itemOrderedQuantity + "\nDelivery sent on: " + DateTime.Now.ToString() + "\n\nPlease login to MarketStory to find out the tracking information(if any)\n\nThank you for using MarketStory";
                    smtp.Send(buyer.getEmail(), "MarketStory Item On Delivery", "The following item has been sent on delivery by the seller: \n\n" + itemSentOnDelivery, true);
                }
                else if (((DropDownList)e.Item.FindControl("productDeliveryStatus")).SelectedValue == "CANCELLED")
                {
                    User buyer = new User();
                    buyer = buyer.retrieveUser(Convert.ToInt32(((HiddenField)e.Item.FindControl("HiddenField1")).Value));
                    GmailSMTP smtp                  = new GmailSMTP();
                    string    itemName              = ((Label)e.Item.FindControl("displayProductName")).Text;
                    string    itemOrderedQuantity   = ((Label)e.Item.FindControl("displayOrderedQuantity")).Text;
                    string    itemDeliveryCancelled = "Item: " + itemName + "\nQuantity you ordered: " + itemOrderedQuantity + "\nOrder cancelled on: " + DateTime.Now.ToString() + "\n\nPlease login to MarketStory to find out the reason of the seller's cancellation\n\nThank you for using MarketStory";
                    smtp.Send(buyer.getEmail(), "MarketStory Item Delivery CANCELLED", "The following item has been cancelled by the seller: \n\n" + itemDeliveryCancelled, true);
                }

                orderRequestList.EditIndex = -1;
                orderRequestList.DataBind();
            }
        }
コード例 #6
0
        protected void confirmCashOutButton_Click(object sender, EventArgs e)
        {
            int amountToCashOut = Convert.ToInt32(cashOutAmountInput.Text);

            if (amountToCashOut > user.getAccountBalance())
            {
                ScriptManager.RegisterStartupScript(this, typeof(string), "cashOutFailedScript", "alert('You cannot cash out more than what you earn!');", true);
            }
            else if (amountToCashOut < 10)
            {
                ScriptManager.RegisterStartupScript(this, typeof(string), "cashOutFailedScript", "alert('You need to check out a minimum of $10!');", true);
            }
            else if (amountToCashOut <= user.getAccountBalance())
            {
                ScriptManager.RegisterStartupScript(this, typeof(string), "cashOutSuccessScript", "alert('Cash out succeeded! Please check your email!');", true);

                user = user.retrieveUser(userID);
                user.updateUserAccountBalance(userID, -amountToCashOut);

                GmailSMTP smtp           = new GmailSMTP();
                string    cashOutMessage = "You have opted to cash out an amount of $" + HttpUtility.HtmlEncode(amountToCashOut) + " on " + HttpUtility.HtmlEncode(DateTime.Now.ToString());
                cashOutMessage += "\nPlease reply this email with your residential information so we can mail you the cheque";
                cashOutMessage += "\nYou may also provide us with your banking information so we can bank transfer you the money";
                cashOutMessage += "\n\nThank you for using MarketStory";
                smtp.Send(user.getEmail(), "MarketStory Cash Out Success", cashOutMessage, true);

                user = user.retrieveUserAccountBalance(userID);
                displayUserAccountBalance.Text = HttpUtility.HtmlEncode("$" + Convert.ToString(user.getAccountBalance()));

                displayAmountToCashOut.Visible = false;
                cashOutAmountInput.Visible     = false;
                confirmCashOutButton.Visible   = false;
                cancelCashOutButton.Visible    = false;
                cashOutAmountInput.Text        = null;
                cashOutButton.Visible          = true;
            }
        }
コード例 #7
0
        protected void ButtonRecovery_Click(object sender, EventArgs e)
        {
            string stringID2 = Request.QueryString["@"];
            int    userID2   = Convert.ToInt32(stringID2);

            int    emailCode2      = retrieveCode(userID2);
            string emailCodeVerify = emailCode2.ToString();

            int    otp2      = retrieveOtp(userID2);
            string otpVerify = otp2.ToString();

            if (emailCodeVerify.Equals(TextBoxEmailCode.Text) && otpVerify.Equals(TextBoxOTP.Text))
            {
                int count  = retrieveEmailCodeCount(userID2);
                int count2 = retrieveOtpCount(userID2);
                if (count <= 3 && count2 <= 3)
                {
                    RandomPasswordGenerator rpg = new RandomPasswordGenerator();
                    string ranGenPw             = rpg.GetRandomPasswordUsingGUID(10);

                    string registeredEmail = retrieveEmail(userID2);

                    GmailSMTP smtp = new GmailSMTP();
                    smtp.Send(registeredEmail, "MarketStory Activation Code", "Your new password is: " + ranGenPw, true);

                    string ranGenPwHash;
                    ranGenPwHash = CreatePasswordHash(ranGenPw);

                    updatePassword(userID2, ranGenPwHash);

                    ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('Successfully Recovered\\n\\A random generated password has been sent to your registered email address');window.open('MainPage.aspx','_self');", true);
                }
                else if (count > 3)
                {
                    Page.ClientScript.RegisterClientScriptBlock(GetType(), "ThanksPopScript", "alert('Email code expired\\n\\Please request for a new code');", true);
                }
                else if (count2 > 3)
                {
                    Page.ClientScript.RegisterClientScriptBlock(GetType(), "ThanksPopScript", "alert('OTP expired\\n\\Please request for a new otp');", true);
                }
            }
            else if (!(otpVerify.Equals(TextBoxOTP.Text)))
            {
                insertOtpCount(userID2);
                int count = retrieveOtpCount(userID2);

                if (count <= 3)
                {
                    Page.ClientScript.RegisterClientScriptBlock(GetType(), "ThanksPopScript", "alert('Invalid OTP\\n\\Please re-enter the otp');", true);
                }
                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(GetType(), "ThanksPopScript", "alert('OTP expired\\n\\Please request for a new otp');", true);
                }
            }
            else if (!(emailCodeVerify.Equals(TextBoxEmailCode.Text)))
            {
                insertEmailCodeCount(userID2);
                int count = retrieveEmailCodeCount(userID2);

                if (count <= 3)
                {
                    Page.ClientScript.RegisterClientScriptBlock(GetType(), "ThanksPopScript", "alert('Invalid Email Code\\n\\Please re-enter the email code');", true);
                }
                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(GetType(), "ThanksPopScript", "alert('Email code expired\\n\\Please request for a new code');", true);
                }
            }
        }