Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#define Release
- #region Include Classes
- using System;
- using System.Threading;
- using System.Text;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Data;
- using MySql;
- using MySql.Web;
- using MySql.Data;
- using MySql.Data.Common;
- using MySql.Data.Entity;
- using MySql.Data.Entity.Properties;
- using MySql.Data.MySqlClient;
- using MySql.Data.MySqlClient.Authentication;
- using MySql.Data.MySqlClient.Properties;
- using MySql.Data.Types;
- #endregion
- namespace WebApplication1
- {
- public partial class NewOffer : System.Web.UI.Page
- {
- private bool isCookiesEmpty = false;
- protected void Page_Load(object sender, EventArgs e)
- {
- this.btnQuit.Click += new ImageClickEventHandler(btnQuit_Click);
- this.btnMakeNewOffer.Click += new EventHandler(btnMakeNewOffer_Click);
- try
- {
- InitMe();
- }
- catch (Exception exc)
- {
- exc.ToString();
- }
- #if Release
- if (isCookiesEmpty) Response.Redirect("Default.aspx");
- if (BankView.sentOffer) Response.Redirect("TradePlace.aspx?view=my");
- #endif
- }
- void btnMakeNewOffer_Click(object sender, EventArgs e)
- {
- string valueSteps = Request.Form["valueSteps"];
- if (valueSteps != null && valueSteps != String.Empty)
- {
- int stepsCount = Convert.ToInt32(valueSteps);
- List<string> arrayDocs = new List<string>();
- foreach (var item in Page.Controls)
- {
- if (item.GetType().Name == "CheckBox")
- {
- CheckBox checkBox = item as CheckBox;
- if (checkBox.ID != null && checkBox.ID != String.Empty && checkBox.Checked)
- {
- arrayDocs.Add(checkBox.ID);
- }
- }
- }
- StringBuilder queryBuilder = new StringBuilder();
- List<string>.Enumerator enumCheckedBoxes = arrayDocs.GetEnumerator();
- queryBuilder.Append("NewOffer.aspx?step=2&checkedValues=[");
- while (enumCheckedBoxes.MoveNext())
- {
- queryBuilder.Append(enumCheckedBoxes.Current);
- queryBuilder.Append(',');
- }
- queryBuilder.Remove(queryBuilder.Length - 1, 1);
- queryBuilder.Append("]");
- Response.Redirect(queryBuilder.ToString());
- }
- else NewOfferStatus.showAlert = true;
- }
- void btnQuit_Click(object sender, ImageClickEventArgs e)
- {
- string[] myCookies = Request.Cookies.AllKeys;
- foreach (string cookie in myCookies)
- {
- Response.Cookies[cookie].Expires = DateTime.Now.AddDays(-1);
- }
- Response.Redirect("Default.aspx");
- }
- void CheckHttpMethod()
- {
- if (Request.HttpMethod == "POST")
- {
- }
- else if (Request.HttpMethod == "GET")
- {
- string clientString = HttpUtility.UrlDecode(Request.QueryString.ToString());
- if (clientString != String.Empty && clientString != null)
- {
- int indexStart = clientString.IndexOf('[');
- int indexEnd = clientString.IndexOf(']');
- string tmpParams = clientString.Substring(indexStart + 1, indexEnd - indexStart - 1);
- string[] clientDocuments = tmpParams.Split(',');
- DocumentHandler objectDocumentHandler = new DocumentHandler(ref clientDocuments);
- int[] docsMapValues = objectDocumentHandler.GetMapCheckedDocuments();
- DocumentData.docsMap = new Dictionary<int, string>();
- for (int i = 0; i < clientDocuments.Length; i++)
- {
- DocumentData.docsMap.Add(docsMapValues[i], clientDocuments[i]);
- }
- }
- }
- }
- void InitMe()
- {
- NewOfferStatus.showAlert = false;
- BankView.sentOffer = false;
- CheckHttpMethod();
- UserCookies dataUserCookies = new UserCookies();
- foreach (string item in Request.Cookies)
- {
- switch (item)
- {
- case "sessionId":
- dataUserCookies.sessionGuid = Guid.Parse(Request.Cookies[item].Value);
- break;
- case "userName":
- dataUserCookies.userName = Request.Cookies[item].Value;
- break;
- case "userType":
- dataUserCookies.userType = Convert.ToInt32(Request.Cookies[item].Value);
- break;
- case "clientIp":
- dataUserCookies.clientIp = Request.Cookies[item].Value;
- break;
- case "timeAuth":
- dataUserCookies.timeAuth = DateTime.Parse(Request.Cookies[item].Value);
- break;
- }
- }
- isCookiesEmpty = CheckUserCookiesObject(ref dataUserCookies);
- }
- bool CheckUserCookiesObject(ref UserCookies objHanlder)
- {
- bool isEmpty = false;
- if (objHanlder.userName == String.Empty) isEmpty = true;
- if (objHanlder.userType == -1) isEmpty = true;
- if (objHanlder.clientIp == String.Empty) isEmpty = true;
- return isEmpty;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement