public void Prepare_Order_Form() { MySqlConnection dbconn = new MySqlConnection(CommonClass.connectionstring); dbconn.Open(); Populate_Products(dbconn); Show_Active_Promotion(dbconn); AddressBook1.Load_Address(dbconn, true); //AddressBook1.Load_Address(dbconn); if (Store_Place_Holder.Visible == false) { PAYMENT_TYPE_ID.Value = WalletPaymentType; ORDER_STATUS.Value = "Open"; } Payment_Received_Flag.ClearSelection(); Payment_Type.ClearSelection(); Delivery_Method.ClearSelection(); Calculate_Grand_Total(); Payment_Received_Information.Visible = false; PaymentControl1.Prepare_Payment_Form(dbconn); PaymentControl1.Clear_Cheque_Details(); dbconn.Close(); if (OrderLoad != null) { OrderLoad(this, EventArgs.Empty); } }
protected bool Validate_Order() { bool IsValid = true; Message.Text = ""; if (Grand_Total.Text == "0.0" || Grand_Total.Text == "0") { Message.Text += "Atleast one product should be ordered<br>"; IsValid = false; } if (Store_Place_Holder.Visible == true) { if (Payment_Received_Flag.SelectedValue == "") { Message.Text += "Select the Payment Information<br>"; IsValid = false; } if (Payment_Received_Information.Visible == true) { if (Payment_Type.SelectedValue == "") { Message.Text += "Select the Payment Type<br>"; IsValid = false; } else if (Payment_Type.SelectedItem.Text == "Cheque") { string lPaymentMessage = PaymentControl1.Validate_Cheque_Details(); if (lPaymentMessage != null) { Message.Text += lPaymentMessage + "<br>"; IsValid = false; } } } if (Delivery_Method.SelectedValue == "") { Message.Text += "Select the Delivery Information<br>"; IsValid = false; } } if (Online_Payment_PlaceHolder.Visible == true) { if (Online_Payment_Type.SelectedValue == "") { Message.Text += "Select the Payment Type<br>"; IsValid = false; } } if (AddressBook1.GetDeliveryAddressId == "" && AddressBook1.Visible == true) { Message.Text += "Select the Delivery Address<br>"; IsValid = false; } if (IsValid && Surprise_Gift_Percentage.Text == "") { //Surprise_Gift_PlaceHolder.Visible = true; if (Surprise_Gift_Percentage.Text == "") { Random rand = new Random(); int numIterations = rand.Next(1, 6); Surprise_Gift_Percentage.Text = numIterations.ToString(); } } if (Surprise_Gift_Percentage.Text != "" && IsValid && GLOBAL_DISCOUNT_APPLIED.Value == "0") { double lExistingSurpriseGift = double.Parse(Surprise_Gift.Text); double discountpercent = double.Parse(Surprise_Gift_Percentage.Text); //double lOrderAmount = double.Parse(Grand_Total.Text) + double.Parse(Shipping_Discount.Text) - double.Parse(Shipping_Charges.Text) + lExistingSurpriseGift; double lOrderAmount = double.Parse(Subtotal_Str.Text); double lSurpriseDiscount = Math.Round((lOrderAmount * discountpercent) / 100); // Grand_Total.Text = (double.Parse(Grand_Total.Text) - lSurpriseDiscount).ToString(); // Discounts.Text = (double.Parse(Discounts.Text) + lSurpriseDiscount).ToString(); bool lSurprise_Gift_Applied = false; double lPromotionalDiscount = double.Parse(Promotional_Discounts.Text); if (Surprise_Gift.Text == "") { Surprise_Gift.Text = lSurpriseDiscount.ToString(); lPromotionalDiscount += lSurpriseDiscount; lSurprise_Gift_Applied = true; } else { //double lExistingSurpriseGift = double.Parse(Surprise_Gift.Text); if (lExistingSurpriseGift != lSurpriseDiscount) { lPromotionalDiscount -= lExistingSurpriseGift; Surprise_Gift.Text = lSurpriseDiscount.ToString(); lPromotionalDiscount += lSurpriseDiscount; lSurprise_Gift_Applied = true; } } if (lSurprise_Gift_Applied == true) { string message = "Congratulations, you have won a surprise gift of INR " + lSurpriseDiscount.ToString() + ", Press Place Order Again to continue"; 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>"); Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString()); IsValid = false; } Promotional_Discounts.Text = lPromotionalDiscount.ToString(); Discounts.Text = (double.Parse(Shipping_Discount.Text) + lPromotionalDiscount).ToString(); Grand_Total.Text = (lOrderAmount + double.Parse(Shipping_Charges.Text) - double.Parse(Shipping_Discount.Text) - lPromotionalDiscount).ToString(); } return(IsValid); }