protected void checkOut_Click(object sender, EventArgs e) { Int64 cId = getCId(); using (SqlConnection con = new SqlConnection(CS)) { con.Open(); SqlCommand cmd = new SqlCommand("INSERT INTO OrderTable(CustomerID, PurchaseDateTime) VALUES('" + cId.ToString() + "', '" + DateTime.Now + "'); SELECT SCOPE_IDENTITY()", con); int OrderId = Convert.ToInt32(cmd.ExecuteScalar()); string CookiePID = Request.Cookies["OrderID" + cId.ToString()]["ProductID"].Split('=')[0]; string CookieQuantity = Request.Cookies["OrderID" + cId.ToString()]["Quantity"].Split('=')[0]; string CookieSize = Request.Cookies["OrderID" + cId.ToString()]["Size"].Split('=')[0]; List <String> CookiePIDList = CookiePID.Split(',').Select(i => i.Trim()).Where(i => i != string.Empty).ToList(); List <String> CookieQuantityList = CookieQuantity.Split(',').Select(i => i.Trim()).Where(i => i != string.Empty).ToList(); List <String> CookieSizeList = CookieSize.Split(',').Select(i => i.Trim()).Where(i => i != string.Empty).ToList(); for (int i = 0; i < CookiePIDList.Count(); i++) { SqlCommand cmd2 = new SqlCommand("INSERT INTO OrderDetails(ProductCode,OrderQnty,OrderSize,OrderTotalPrice,OrderID) VALUES(@ProductCode,@OrderQnty,@OrderSize,@OrderTotalPrice,@OrderID)", con); cmd2.Parameters.AddWithValue("@ProductCode", CookiePIDList.ElementAt(i)); cmd2.Parameters.AddWithValue("@OrderQnty", CookieQuantityList.ElementAt(i)); cmd2.Parameters.AddWithValue("@OrderSize", CookieSizeList.ElementAt(i)); DataTable price = new DataTable(); SqlCommand cmd3 = new SqlCommand("Select ProductPrice from PDetails where ProductCode=" + CookiePIDList.ElementAt(i)); price = access.SelectFromDatabase(cmd3); cmd2.Parameters.AddWithValue("@OrderTotalPrice", Convert.ToInt64(price.Rows[0]["ProductPrice"]) * Convert.ToInt64(CookieQuantityList.ElementAt(i))); cmd2.Parameters.AddWithValue("@OrderID", OrderId); int x = cmd2.ExecuteNonQuery(); if (x > 0) { subtractItems(CookiePIDList.ElementAt(i), CookieQuantityList.ElementAt(i), CookieSizeList.ElementAt(i)); } } addCustomerpayment(cId.ToString(), OrderId.ToString()); addVendorPayment(OrderId.ToString()); Accessible.sendOrderToCustomer(Session["Customer"].ToString(), OrderId.ToString(), getUserName()); deleteCookie(); Response.Redirect("~/CustomerBill.aspx?OrderID=" + OrderId); } }
protected void SignUpSuccessful(object sender, EventArgs e) { if (access.checkEmail(custEmail.Text, 'c')) { CEmailErrorMessage.Text = "Email address not available."; CEmailErrorMessage.ForeColor = Color.Red; } else if (access.checkEmail(custEmail.Text, 'v')) { CEmailErrorMessage.Text = "You have already signed as brand."; CEmailErrorMessage.ForeColor = Color.Red; } else { string randomVCode = access.genCode(); Accessible.sendMsg(custEmail.Text, custName.Text, custPassword.Text, randomVCode); using (SqlConnection con = new SqlConnection(CS)) { con.Open(); SqlCommand cmd = new SqlCommand("INSERT INTO CustomerDetails(CustomerName,CustomerAddress,CustomerPhoneNo,CustomerEmailAddress,CustomerPassword,CustomerCityId,VerifiedEmail,VerificationCode) VALUES(@CustomerName,@CustomerAddress,@CustomerPhoneNo,@CustomerEmailAddress,@CustomerPassword,@CustomerCityId,@VerifiedEmail,@VerificationCode); SELECT SCOPE_IDENTITY()", con); cmd.Parameters.AddWithValue("@CustomerName", custName.Text); cmd.Parameters.AddWithValue("@CustomerAddress", custLocation.Text); cmd.Parameters.AddWithValue("@CustomerPhoneNo", custphoneNum.Text); cmd.Parameters.AddWithValue("@CustomerEmailAddress", custEmail.Text); cmd.Parameters.AddWithValue("@CustomerPassword", custPassword.Text); cmd.Parameters.AddWithValue("@CustomerCityId", custCity.SelectedItem.Value); cmd.Parameters.AddWithValue("@VerifiedEmail", 0); cmd.Parameters.AddWithValue("@VerificationCode", randomVCode); cmd.ExecuteNonQuery(); Response.Redirect("/Activation.aspx?rurl=notVerifiedCust"); } } }
protected void SignUpSuccessful(object sender, EventArgs e) { // Read the file and convert it to Byte Array string filePath = VendorFileUpload.PostedFile.FileName; string filename = Path.GetFileName(filePath); string ext = Path.GetExtension(filename); string contenttype = String.Empty; //Set the contenttype based on File Extension switch (ext) { case ".jpg": contenttype = "image/jpg"; break; case ".png": contenttype = "image/png"; break; case ".gif": contenttype = "image/gif"; break; case ".pdf": contenttype = "application/pdf"; break; default: { VUploadError.Text = "Invalid Image"; VUploadError.ForeColor = Color.Red; break; } } if (access.checkEmail(vendorEmail.Text, 'v')) { VEmailErrorMessage.Text = "Email address not available."; VEmailErrorMessage.ForeColor = Color.Red; } else if (access.checkEmail(vendorEmail.Text, 'c')) { VEmailErrorMessage.Text = "You have already signed in as Customer"; VEmailErrorMessage.ForeColor = Color.Red; } else if (access.checkBrandName(vendorName.Text)) { VNameErrorMessage.Text = "This brand name has already been registered."; VNameErrorMessage.ForeColor = Color.Red; } else if (contenttype != String.Empty) { Stream fs = VendorFileUpload.PostedFile.InputStream; BinaryReader br = new BinaryReader(fs); Byte[] bytes = br.ReadBytes((Int32)fs.Length); string randomVCode = access.genCode(); Accessible.sendMsg(vendorEmail.Text, vendorName.Text, vendorPassword.Text, randomVCode); String CS = ConfigurationManager.ConnectionStrings["BrandBoxDatabaseConnectionString"].ConnectionString.ToString(); using (SqlConnection con = new SqlConnection(CS)) { con.Open(); SqlCommand cmd = new SqlCommand("INSERT INTO VendorPayment(VTotalPayment,VProfit) VALUES(@VTotalPayment,@VProfit); SELECT SCOPE_IDENTITY()", con); cmd.Parameters.AddWithValue("@VTotalPayment", 0); cmd.Parameters.AddWithValue("@VProfit", 0); int VendorPaymentFK = Convert.ToInt32(cmd.ExecuteScalar()); SqlCommand cmd2 = new SqlCommand("INSERT INTO Vendor(VendorEmail, VendorPassword, VendorLocation, VendorPhoneNo,VendorName,VendorDetails,VPaymentNo,ImageContentType,ImageData,VerifiedEmail,VerificationCode) VALUES(@VendorEmail,@VendorPassword,@VendorLocation,@VendorPhoneNo,@VendorName,@VendorDetails,@VPaymentNo,@ImageContentType,@ImageData,@VerifiedEmail,@VerificationCode)", con); cmd2.Parameters.AddWithValue("@VendorEmail", vendorEmail.Text); cmd2.Parameters.AddWithValue("@VendorPassword", vendorPassword.Text); cmd2.Parameters.AddWithValue("@VendorLocation", vendorLocation.Text); cmd2.Parameters.AddWithValue("@VendorPhoneNo", vendorphoneNum.Text); cmd2.Parameters.AddWithValue("@VendorName", vendorName.Text); cmd2.Parameters.AddWithValue("@VendorDetails", vendorDetails.Text); cmd2.Parameters.AddWithValue("@VPaymentNo", VendorPaymentFK); cmd2.Parameters.Add("@ImageContentType", SqlDbType.VarChar).Value = contenttype; cmd2.Parameters.Add("@ImageData", SqlDbType.Binary).Value = bytes; cmd2.Parameters.AddWithValue("@VerifiedEmail", 0); cmd2.Parameters.AddWithValue("@VerificationCode", randomVCode); cmd2.ExecuteNonQuery(); Response.Redirect("/Activation.aspx?rurl=notVerifiedVendor"); } } }