Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Пояснительная записка Колпаков.doc
Скачиваний:
0
Добавлен:
01.05.2025
Размер:
6.55 Mб
Скачать

Приложение б. Листинг страниц системы.

Файл SearchForm.aspx

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Globalization;

public partial class SearchForm : System.Web.UI.Page

{

protected class LotIndex

{

public Guid ID { get; set; }

public string Name { get; set; }

public string Lev { get; set; }

public int? Lev2 { get; set; }

public bool Checked { get; set; }

}

List<LotIndex> queryInd

{

get { return Session["queryInd"] as List<LotIndex>; }

set { Session["queryInd"] = value; }

}

List<LotIndex> SelectedItemsInd

{

get { return Session["SelectedItemsInd"] as List<LotIndex>; }

set { Session["SelectedItemsInd"] = value; }

}

List<LotIndex> FilterQueryInd

{

get { return Session["FilterQueryInd"] as List<LotIndex>; }

set { Session["FilterQueryInd"] = value; }

}

List<LotIndex> FirstQueryInd

{

get { return Session["FirstQueryInd"] as List<LotIndex>; }

set { Session["FirstQueryInd"] = value; }

}

protected class Activity

{

public Guid ID { get; set; }

public string Name { get; set; }

public string Lev { get; set; }

public int? Lev2 { get; set; }

public bool Checked { get; set; }

}

List<Activity> queryAct

{

get { return Session["queryAct"] as List<Activity>; }

set { Session["queryAct"] = value; }

}

List<Activity> SelectedItemsAct

{

get { return Session["SelectedItemsAct"] as List<Activity>; }

set { Session["SelectedItemsAct"] = value; }

}

List<Activity> FilterQueryAct

{

get { return Session["FilterQueryAct"] as List<Activity>; }

set { Session["FilterQueryAct"] = value; }

}

List<Activity> FirstQueryAct

{

get { return Session["FirstQueryAct"] as List<Activity>; }

set { Session["FirstQueryAct"] = value; }

}

protected void On_ProdCategory_IndexChanged(Object sender, EventArgs e)

{

ListItem Li = new ListItem();

Li.Text = "";

Li.Value = "none";

ListItem Li2 = new ListItem();

Li2.Text = "";

Li2.Value = "none";

/*

Get_Product_SubCategory();

DrDL_ProdSubCategory.Items.Insert(0, Li);

Get_Product_SubSubCategory();

DrDL_ProdSubSubCategory.Items.Insert(0, Li2);

*/

}

protected void On_ProdSubCategory_IndexChanged(Object sender, EventArgs e)

{

ListItem Li = new ListItem();

Li.Text = "";

Li.Value = "none";

/*

Get_Product_SubSubCategory();

DrDL_ProdSubSubCategory.Items.Insert(0, Li);

*/

}

protected void ShowSearchForm(object sender, EventArgs e)

{

Pan_SelectLotType.Visible = false;

Pan_SearchForms.Visible = true;

MV_SearchForms.ActiveViewIndex = DrD_SelectLotType.SelectedIndex;

}

protected void ChangeCountry(object sender, EventArgs e)

{

if (!DrDL_LotCountry.SelectedValue.Equals("none"))

{

ListItem Li = new ListItem();

Li.Text = "";

Li.Value = "none";

PublicFunctions.GetCity_To_DrDL(DrDL_LotCity, DrDL_LotCountry.SelectedValue);

DrDL_LotCity.Items.Insert(0, Li);

}

else

{

DrDL_LotCity.Items.Clear();

}

}

protected override void OnPreInit(EventArgs e)

{

PublicFunctions.SetCulture(this, Response, Request);

}

protected override void OnLoadComplete(EventArgs e)

{

if (PreviousPage == null)

{

ASP.controls_wucsearch2_ascx FastSearchForm = null;

FastSearchForm =

(ASP.controls_wucsearch2_ascx)Master.FindControl("FastSearchForm");

if (FastSearchForm.b == 3)

{

Pan_SelectLotType.Visible = true;

Pan_SearchForms.Visible = false;

PLoad();

}

}

lvActivities.DataSource = queryAct;

lvActivities.DataBind();

lvLotIndexes.DataSource = queryInd;

lvLotIndexes.DataBind();

}

protected void Page_Load(object sender, EventArgs e)

{

Master.Title = Resources.Site.Search;

if (!Page.IsPostBack)

{

PLoad();

}

}

protected void PLoad ()

{

DrD_SelectLotType.Items.Clear();

LotTypes.LotTypesDataContext DB = new LotTypes.LotTypesDataContext();

DB.TBL_LotIndexes_As_Lists.Context.CommandTimeout = 600;

FirstQueryInd = (from v in DB.TBL_LotIndexes_As_Lists

orderby v.NewLevel

select new LotIndex

{

ID = v.LotIndexID,

Name = PublicFunctions.Get_LotIndex_Name(DB.LotIndexes.Single(l => l.LotIndexID == v.LotIndexID), CultureInfo.CurrentCulture, false),

Lev = v.NewLevel,

Lev2 = v.TreeLevel,

Checked = false

}).ToList();

queryInd = FirstQueryInd;

FirstQueryAct = (from v in DB.TBL_Activities_As_Lists

orderby v.NewLevel

select new Activity

{

ID = v.ActivityID,

Name = PublicFunctions.Get_Activity_Name(DB.Activities.Single(l => l.ActivityID == v.ActivityID), CultureInfo.CurrentCulture, false),

Lev = v.NewLevel,

Lev2 = v.TreeLevel,

Checked = false

}).ToList();

queryAct = FirstQueryAct;

//PublicFunctions.Get_LotIndex_ToDrDL(DrDL_Index, null);

//PublicFunctions.Get_Activity_ToDrDL(DrDL_Activity, null);

PublicFunctions.Get_EngineType_ToDrDL(DrDL_VehEngineType);

PublicFunctions.Get_TransmissionType_ToDrDL(DrDL_VehTransmission);

System.Linq.IQueryable<LotTypes.LotType> LotTypes =

from LT in DB.LotTypes

orderby LT.Number ascending

select LT;

foreach (LotTypes.LotType LT in LotTypes)

{

ListItem LI = new ListItem();

LI.Value = LT.LotTypeID.ToString();

LI.Text = LT.LotTypeNameHE;

switch (CultureInfo.CurrentCulture.TwoLetterISOLanguageName)

{

case "en":

if (LT.LotTypeNameEN.Length > 0)

LI.Text = LT.LotTypeNameEN;

break;

case "ru":

if (LT.LotTypeNameRU.Length > 0)

LI.Text = LT.LotTypeNameRU;

break;

}

DrD_SelectLotType.Items.Add(LI);

}

ListItem Li = new ListItem();

Li.Text = "";

Li.Value = "none";

ListItem Li2 = new ListItem();

Li2.Text = "";

Li2.Value = "none";

ListItem Li3 = new ListItem();

Li3.Text = "";

Li3.Value = "none";

ListItem Li4 = new ListItem();

Li4.Text = "";

Li4.Value = "none";

ListItem Li5 = new ListItem();

Li5.Text = "";

Li5.Value = "none";

ListItem Li6 = new ListItem();

Li6.Text = "";

Li6.Value = "none";

ListItem Li7 = new ListItem();

Li7.Text = "";

Li7.Value = "none";

PublicFunctions.Get_Country_To_DrDL(DrDL_LotCountry);

DrDL_LotCountry.Items.Insert(0, Li);

PublicFunctions.GetCity_To_DrDL(DrDL_LotCity, DrDL_LotCountry.SelectedValue);

DrDL_LotCity.Items.Insert(0, Li2);

PublicFunctions.Get_Currency_To_DrDL(DrDL_LotCurrency);

//PublicFunctions.Get_Activity_ToDrDL(DrDL_ComActivity, null);

//PublicFunctions.Get_Activity_ToDrDL(DrDL_IndActivity, null);

//DrDL_ComActivity.Items.Insert(0, Li4);

/*

Get_Product_Category();

DrDL_ProdCategory.Items.Insert(0, Li5);

Get_Product_SubCategory();

DrDL_ProdSubCategory.Items.Insert(0, Li6);

Get_Product_SubSubCategory();

DrDL_ProdSubSubCategory.Items.Insert(0, Li7);

*/

var RealEstateID = (from LType in DB.LotTypes

where LType.LotTypeNameEN == "Real Estate"

select LType.LotTypeID);

foreach (Guid ID in RealEstateID)

PublicFunctions.Get_LotCategories_To_DrDL(DrDL_RE_Type, null, ID.ToString());

DrDL_RE_Type.Items.Insert(0, Li3);

RealEstateID = (from LType in DB.LotTypes

where LType.LotTypeNameEN == "Vehicle"

select LType.LotTypeID);

foreach (Guid ID in RealEstateID)

PublicFunctions.Get_LotCategories_To_DrDL(DrDL_VehType, null, ID.ToString());

DrDL_VehType.Items.Insert(0, Li4);

RealEstateID = (from LType in DB.LotTypes

where LType.LotTypeNameEN == "Intellectual Property"

select LType.LotTypeID);

foreach (Guid ID in RealEstateID)

PublicFunctions.Get_LotCategories_To_DrDL(DrDL_IPTypes, null, ID.ToString());

DrDL_IPTypes.Items.Insert(0, Li5);

DrDL_VehEngineType.Items.Insert(0, Li6);

DrDL_VehTransmission.Items.Insert(0, Li7);

}

protected void btnActFilter_Click(object sender, EventArgs e)

{

lNoResultsForInd.Visible = false;

if (string.IsNullOrEmpty(tbActFilter.Text))

{

queryAct = FirstQueryAct;

return;

}

LotTypes.LotTypesDataContext DB = new LotTypes.LotTypesDataContext();

FilterQueryAct = (from v in FirstQueryAct

where v.Name != null && v.Name.ToLower().StartsWith(tbActFilter.Text.ToLower())

orderby v.Lev

select new Activity

{

ID = v.ID,

Name = v.Name,

Lev2 = v.Lev2,

Checked = v.Checked

}).ToList();

if (FilterQueryAct.Count == 0) lNoResultsForAct.Visible = true;

queryAct = FilterQueryAct;

if ((DataPager)lvActivities.FindControl("pg") == null) return;

((DataPager)lvActivities.FindControl("pg")).SetPageProperties(0, 15, false);

}

protected void btnIndexFilter_Click(object sender, EventArgs e)

{

lNoResultsForInd.Visible = false;

if (string.IsNullOrEmpty(tbIndexFilter.Text))

{

queryInd = FirstQueryInd;

return;

}

LotTypes.LotTypesDataContext DB = new LotTypes.LotTypesDataContext();

FilterQueryInd = (from v in FirstQueryInd

where v.Name != null && v.Name.ToLower().StartsWith(tbIndexFilter.Text.ToLower())

orderby v.Lev

select new LotIndex

{

ID = v.ID,

Name = v.Name,

Lev2 = v.Lev2,

Checked = v.Checked

}).ToList();

if (FilterQueryInd.Count == 0) lNoResultsForInd.Visible = true;

queryInd = FilterQueryInd;

if ((DataPager)lvLotIndexes.FindControl("pg") == null) return;

((DataPager)lvLotIndexes.FindControl("pg")).SetPageProperties(0, 15, false);

}

protected void OnSelectActClick(Object sender, EventArgs e)

{

//Label3.Text = lviewUsers.DataKeys[((ListViewDataItem)((LinkButton)sender).Parent).DisplayIndex].Value.ToString();

lSelectedAct.Text = queryAct.Single(q => q.ID == (Guid)lvActivities.DataKeys[((ListViewDataItem)((LinkButton)sender).Parent).DisplayIndex].Value).Name;

lvActivities.SelectedIndex = ((ListViewDataItem)((LinkButton)sender).Parent).DisplayIndex;

}

protected void OnSelectIndexClick(Object sender, EventArgs e)

{

//Label3.Text = lviewUsers.DataKeys[((ListViewDataItem)((LinkButton)sender).Parent).DisplayIndex].Value.ToString();

lSelectedIndex.Text = queryInd.Single(q => q.ID == (Guid)lvLotIndexes.DataKeys[((ListViewDataItem)((LinkButton)sender).Parent).DisplayIndex].Value).Name;

lvLotIndexes.SelectedIndex = ((ListViewDataItem)((LinkButton)sender).Parent).DisplayIndex;

}

}

Файл AdminContent.aspx

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Globalization;

using System.Configuration;

using System.Web.Security;

public class AuctionsInfo

{

public string AuthorName { get; set; }

public Guid? AuthorID { get; set; }

public string AuctionName { get; set; }

public int AuctionID { get; set; }

public bool AuctionIsApproved { get; set; }

}

public class LotInfo

{

public string AuthorName { get; set; }

public Guid? AuthorID { get; set; }

public string LotName { get; set; }

public int LotID { get; set; }

public bool? LotIsHot { get; set; }

}

public partial class AdminContent : System.Web.UI.Page

{

System.Linq.IQueryable<AuctionsInfo> AuctList;

protected System.Collections.Generic.IEnumerable<LotInfo> LotList

{

get { return Session["LotList_admin"] as System.Collections.Generic.IEnumerable<LotInfo>; }

set { Session["LotList_admin"] = value; }

}

protected override void OnLoadComplete(EventArgs e)

{

base.OnLoadComplete(e);

Master.Title = Resources.Site1.ContentManagement;

if (!(Membership.GetUser() != null) || !(Roles.IsUserInRole(Membership.GetUser().UserName, "Admin")))

{

LabelCap.Text = Resources.Site.NotEnoughPrivileges;

UpdatePanel1.Visible = false;

L_AdminAuction.Visible = false;

L_AdminLots.Visible = false;

return;

}

LabelCap.Text = Resources.Site1.ContentManagement;

UpdatePanel1.Visible = true;

LotTypes.LotTypesDataContext DB = new LotTypes.LotTypesDataContext();

AuctList = from Auct in DB.Auctions

select new AuctionsInfo

{

AuctionID = Auct.AuctionID,

AuctionIsApproved = Auct.Approved == 1 ? true : false,

AuctionName = PublicFunctions.Get_Auction_Name(Auct, CultureInfo.CurrentCulture),

AuthorID = Auct.UserId,

AuthorName = Auct.aspnet_User.UserName,

};

LV_AuctionsList.DataSource = AuctList;

LV_AuctionsList.DataBind();

if (LotList == null)

{

LotList = from Lt in DB.Lots

let Ht = Lt.hot == true ? true : false

select new LotInfo

{

LotID = Lt.LotID,

LotIsHot = Lt.hot == null ? false : Lt.hot,

LotName = PublicFunctions.Get_Lot_Name(Lt, CultureInfo.CurrentCulture),

AuthorID = Lt.UserID,

AuthorName = Lt.aspnet_User.UserName,

};

}

LV_LotsList.DataSource = LotList.ToList();

LV_LotsList.DataBind();

}

protected void Show_Lots_Handler(Object sender, CommandEventArgs e)

{

Label1.Visible = false; Label2.Visible = false;

LotTypes.LotTypesDataContext DB = new LotTypes.LotTypesDataContext();

Guid? UserID = PublicFunctions.GetUserGuid(Profile.UserName);

if (e.CommandName.Equals("ShowAuctionLots"))

{

int AuctionID = int.Parse((string)e.CommandArgument);

LotTypes.Auction Auction = DB.Auctions.First(a => a.AuctionID== AuctionID);

string nameauction = PublicFunctions.Get_Auction_Name(Auction, CultureInfo.CurrentCulture);

L_AdminLots.Text =String.Format(Resources.Site1.YouLotforAuction,nameauction);

LotList = from Lt in DB.Lots

join La in DB.AuctionLots on Lt.LotID equals La.LotID

where La.AuctionID==AuctionID

select new LotInfo

{

LotID = Lt.LotID,

LotIsHot = Lt.hot == null ? false : Lt.hot,

LotName = PublicFunctions.Get_Lot_Name(Lt, CultureInfo.CurrentCulture),

AuthorID = Lt.UserID,

AuthorName = Lt.aspnet_User.UserName,

};

}

}

protected void Page_Load(object sender, EventArgs e)

{

Label1.Visible = false; Label2.Visible = false;

}

protected void On_Bn_ApplyApprovation_Click(object sender, EventArgs e)

{

LotTypes.LotTypesDataContext DB = new LotTypes.LotTypesDataContext();

foreach (ListViewDataItem Itm in LV_AuctionsList.Items)

{

int AuctionID = (int)LV_AuctionsList.DataKeys[Itm.DisplayIndex].Value;

CheckBox ChB_Approved = (CheckBox)Itm.FindControl("ChB_Approved");

var Auctions = from Auct in DB.Auctions

where Auct.AuctionID==AuctionID

select Auct;

foreach (LotTypes.Auction auct in Auctions)

{

if (auct.StartDate!=null && auct.EndDate!=null)

if (ChB_Approved.Checked)

{

auct.Approved = 1;

//допустить лоты по данному аукциону

var LotAucts = from t in DB.Lots

join La in DB.AuctionLots on t.LotID equals La.LotID

where La.AuctionID==AuctionID

select t;

foreach (LotTypes.Lot curlot in LotAucts)

{

curlot.hot = true;

}

}

else

{

auct.Approved = 0;

//не допустить лоты по данному аукциону

var LotAucts = from t in DB.Lots

join La in DB.AuctionLots on t.LotID equals La.LotID

where La.AuctionID == AuctionID

select t;

foreach (LotTypes.Lot curlot in LotAucts)

{

curlot.hot = false;

}

}

}

}

DB.SubmitChanges();

Label1.Visible = true; Label2.Visible = false;

}

protected void On_Bn_ApplyHot_Click(object sender, EventArgs e)

{

// Label1.Text=Label2.te

foreach (ListViewDataItem Itm in LV_LotsList.Items)

{

LotTypes.LotTypesDataContext DB = new LotTypes.LotTypesDataContext();

int LotID = (int)LV_LotsList.DataKeys[Itm.DisplayIndex].Value;

CheckBox ChB_Hot = (CheckBox)Itm.FindControl("ChB_Hot");

var Lots = from Lt in DB.Lots

where Lt.LotID == LotID

select Lt;

foreach (LotTypes.Lot Lt in Lots)

{

// if (Lt.StartDate != null && auct.EndDate != null)

if (ChB_Hot.Checked)

{

Lt.hot = true;

DB.SubmitChanges();

}

else

{

Lt.hot =false ;

DB.SubmitChanges();

}

}

}

Label1.Visible = false; Label2.Visible = true;

}

protected void On_btnDeleteAuction_Click(object sender, EventArgs e)

{

Label1.Visible = true; Label2.Visible = false;

UpdatePanel1.FindControl("panWarning").Visible = true;

lWarning.Text = Resources.Site.Delete + " "+ Resources.Site.Auction+"? " ;

btnDelete.CommandName = "Auction";

btnDelete.CommandArgument = Convert.ToString(LV_AuctionsList.DataKeys[((ListViewDataItem)((Button)sender).Parent).DisplayIndex].Value);

}

protected void DeleteLot(LotTypes.Lot l, ref List<Guid?> bidders, ref List<string> Lots)

{

Label1.Visible = false; Label2.Visible = true;

LotTypes.LotTypesDataContext DB = new LotTypes.LotTypesDataContext();

LotTypes.Lot lot = new LotTypes.Lot();

lot = DB.Lots.SingleOrDefault(lt=>lt.LotID == l.LotID);

if (lot == default(LotTypes.Lot)) return;

if (lot.Lots.Count == 0)

{

foreach (LotTypes.LotBid lb in lot.LotBids)

{

if (!bidders.Any(b => b == lb.Bidder)) bidders.Add(lb.Bidder);

}

DB.LotBids.DeleteAllOnSubmit(lot.LotBids);

DB.Lots.DeleteOnSubmit(lot);

DB.SubmitChanges();

Lots.Add(lot.NameEN);

}

else

{

foreach (LotTypes.Lot sublot in lot.Lots)

{

DeleteLot(sublot, ref bidders, ref Lots);

foreach (LotTypes.LotBid lb in lot.LotBids)

{

if (!bidders.Any(b => b == lb.Bidder)) bidders.Add(lb.Bidder);

}

DB.LotBids.DeleteAllOnSubmit(sublot.LotBids);

DB.Lots.DeleteOnSubmit(sublot);

}

DB.LotBids.DeleteAllOnSubmit(lot.LotBids);

DB.Lots.DeleteOnSubmit(lot);

Lots.Add(lot.NameEN);

DB.SubmitChanges();

}

}

protected void On_btnDelete_Click(Object sender, CommandEventArgs e)

{

Label1.Visible = false; Label2.Visible = false;

if (e.CommandName == "Auction")

{

bool WhoDel = false; // 1 – Admin, 0 – Creator

LotTypes.LotTypesDataContext DB = new LotTypes.LotTypesDataContext();

int AucID = Convert.ToInt32(e.CommandArgument);

LotTypes.Auction AucToDel = DB.Auctions.SingleOrDefault(a=>a.AuctionID == AucID);

if (AucToDel == default(LotTypes.Auction)) return;

IQueryable<LotTypes.Lot> LotsToDel = from al in DB.AuctionLots

where al.AuctionID == AucID && al.Lot.ParentLotID == null

select al.Lot;

List<Guid?> Bidders = new List<Guid?>();

List<string> Lots = new List<string>();

foreach (LotTypes.Lot lot in LotsToDel)

{

DeleteLot(lot, ref Bidders, ref Lots);

}

if ((Membership.GetUser() != null) &&

(PublicFunctions.GetUserGuid(Membership.GetUser().UserName) != AucToDel.UserId))

{

WhoDel = true;

if (!Bidders.Any(b => b == AucToDel.UserId)) Bidders.Add(AucToDel.UserId);

}

DB.Auctions.DeleteOnSubmit(AucToDel);

DB.SubmitChanges();

string Subject = Resources.Site1.AuctionHasBeenDeleted;

string smtrServerIP = ConfigurationManager.AppSettings["SmtpServer"].ToString();

string us = ConfigurationManager.AppSettings["EmailCredentialUser"].ToString();

string pass = ConfigurationManager.AppSettings["EmailCredentialPassword"].ToString();

string FromAddress = ConfigurationManager.AppSettings["FromAddress"].ToString();

bool Result;

foreach (Guid? bidder in Bidders)

{

string ToAddress = (from u in DB.aspnet_Users

where u.UserId == bidder

select u.UserName).FirstOrDefault();

if (ToAddress == default(string)) return;

string Body = String.Format(Resources.Site1.DeleteAucLetter, AucToDel.ANameE, (WhoDel?Resources.Site1.ByAdmin:Resources.Site1.ByCreator));

if (!string.IsNullOrEmpty(Body)) Result = NewsLetterManager.SendMail(smtrServerIP, FromAddress, ToAddress, Subject, Body, us, pass, null);

}

}

if (e.CommandName == "Lot")

{

bool WhoDel = false; // 1 – Admin, 0 – Creator

LotTypes.LotTypesDataContext DB = new LotTypes.LotTypesDataContext();

int LotID = Convert.ToInt32(e.CommandArgument);

LotTypes.Lot LotToDel = DB.Lots.SingleOrDefault(l => l.LotID == LotID);

if (LotToDel == default(LotTypes.Lot)) return;

List<Guid?> Bidders = new List<Guid?>();

List<string> Lots = new List<string>();

DeleteLot(LotToDel, ref Bidders, ref Lots);

Lots.Remove(LotToDel.NameEN);

if ((Membership.GetUser() != null) &&

(PublicFunctions.GetUserGuid(Membership.GetUser().UserName) != LotToDel.UserID))

{

WhoDel = true;

if (!Bidders.Any(b => b == LotToDel.UserID)) Bidders.Add(LotToDel.UserID);

}

string Subject = Resources.Site1.LotHasBeenDeleted;

string smtrServerIP = ConfigurationManager.AppSettings["SmtpServer"].ToString();

string us = ConfigurationManager.AppSettings["EmailCredentialUser"].ToString();

string pass = ConfigurationManager.AppSettings["EmailCredentialPassword"].ToString();

string FromAddress = ConfigurationManager.AppSettings["FromAddress"].ToString();

bool Result;

foreach (Guid? bidder in Bidders)

{

string ToAddress = (from u in DB.aspnet_Users

where u.UserId == bidder

select u.UserName).FirstOrDefault();

if (ToAddress == default(string)) return;

string Body = String.Format(Resources.Site1.DeleteLotLetter, LotToDel.NameEN, (WhoDel ? Resources.Site1.ByAdmin : Resources.Site1.ByCreator));

if (Lots.Count > 0) Body += Resources.Site1.SublotsList;

foreach (string l in Lots)

{

Body += l + "<br>";

}

if (!string.IsNullOrEmpty(Body)) Result = NewsLetterManager.SendMail(smtrServerIP, FromAddress, ToAddress, Subject, Body, us, pass, null);

}

}

UpdatePanel1.FindControl("panWarning").Visible = false;

}

protected void On_btnCancel_Click(object sender, EventArgs e)

{

Label1.Visible = false; Label2.Visible = false;

UpdatePanel1.FindControl("panWarning").Visible = false;

}

protected void On_btnDeleteLot_Click(object sender, EventArgs e)

{

Label1.Visible = false; Label2.Visible = false;

UpdatePanel1.FindControl("panWarning").Visible = true;

lWarning.Text = Resources.Site1.DeleteLot;

btnDelete.CommandName = "Lot";

btnDelete.CommandArgument = Convert.ToString(LV_LotsList.DataKeys[((ListViewDataItem)((Button)sender).Parent).DisplayIndex].Value);

}

}

Файл Lot.aspx

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Globalization;

using System.Web.Profile;

using System.Web.Security;

public partial class Lot : System.Web.UI.Page

{

public string [] strs1 = new string[17];

public string[] table3 = new string[9];

public string[] table4 = new string[14];

public class PicsItem

{

public int PicID { get; set; }

public string PicDesc { get; set; }

public string PicIntPath { get; set; }

public string Pic { get; set; }

public string Src { get; set; }

}

System.Linq.IQueryable<PicsItem> query

{

get { return Session["query"] as System.Linq.IQueryable<PicsItem>; }

set { Session["query"] = value; }

}

protected int LotID;

protected string LotIndexID;

protected void Page_Load(object sender, EventArgs e)

{

Panel1.Visible = true;

Panel2.Visible = false;

Panel3.Visible = true;

strs1[0] = Resources.Site.LotName;

strs1[1] = Resources.Site.LotActivity;

strs1[2] = Resources.Site.LotIndex;

strs1[3] = Resources.Site.LotClass;

strs1[4] = Resources.Site.LotModel;

strs1[5] = Resources.Site.LotNo;

strs1[6] = Resources.Site.LotYear;

strs1[7] = Resources.Site.LotEstate;

strs1[8] = Resources.Site.LotEnd;

strs1[9] = Resources.Site.LotPlace;

strs1[10] = Resources.Site.LotKol;

strs1[11] = Resources.Site.LotState;

strs1[12] = Resources.Site.LotWhenGet;

strs1[13] = Resources.Site.LotGaranty;

strs1[14] = Resources.Site.LotSellerGar;

strs1[15] = Resources.Site.LotMark;

strs1[16] = Resources.Site.LotMinPrice;

table3[0] = Resources.Site.AucSortMark;

table3[1] = Resources.Site.AucMark;

table3[2] = Resources.Site.AucNumber;

table3[3] = Resources.Site.AucMarker;

table3[4] = Resources.Site.AucDocs;

table3[5] = Resources.Site.AucGenCon;

table3[6] = Resources.Site.AucBuyCon;

table3[7] = Resources.Site.AucHowTake;

table3[8] = Resources.Site.AucInsure;

table4[0] = Resources.Site.AucTransaction;

table4[1] = Resources.Site.AucType;

table4[2] = Resources.Site.AucTime;

table4[3] = Resources.Site.EndDate;

table4[4] = Resources.Site.TourProp;

table4[5] = Resources.Site.AucMaster;

table4[6] = Resources.Site.AucPlace;

table4[7] = Resources.Site.AucMader;

table4[8] = Resources.Site.AucMaderTel;

table4[9] = Resources.Site.AucMaderEmail;

table4[10] = Resources.Site.AucCont;

table4[11] = Resources.Site.AucContTel;

table4[12] = Resources.Site.AucContEmail;

table4[13] = Resources.Site.AucTidaNlli;

Label1.Text = Resources.Site.LotInfo;// Resources.Site.ItemName;

Label4.Text = Resources.Site.AskSeller;

//Label5.Text = "HIDE!!!";//Resources.Site.GeneralInfo;

Label6.Text = Resources.Site.Documents;

Label3.Text = Resources.Site.TransDesc;

LotTypes.LotTypesDataContext DB = new LotTypes.LotTypesDataContext();

string StrLotID = Request.Params["LotID"];

if (string.IsNullOrEmpty(StrLotID))

{

ErrorPanel.Visible = true;

L_error.Text = Resources.Site1.LotClosed;

Panel1.Visible = false;

Panel2.Visible = false;

Panel3.Visible = false;

return;

}

bool LotIDPassed = int.TryParse(StrLotID, out LotID);

LotTypes.Lot LotToDisplay = new LotTypes.Lot();

LotTypes.Auction AuctionToDisplay = new LotTypes.Auction();

AuctionToDisplay = PublicFunctions.GetActiveAuctionForLot(LotID);

if (AuctionToDisplay == null) return;

if (LotIDPassed)

{

System.Linq.IQueryable<LotTypes.Lot> Lot =

from lt in DB.Lots

where lt.LotID == LotID && lt.hot==true

select lt;

foreach (LotTypes.Lot lt in Lot)

{

LotToDisplay = lt;

break;

}

if (LotToDisplay.hot != true)

{

ErrorPanel.Visible = true;

L_error.Text =Resources.Site1.LotClosed;

Panel1.Visible = false;

Panel2.Visible = false;

Panel3.Visible = false;

return;

}

if (Membership.GetUser() != null)

if ((Roles.IsUserInRole(Membership.GetUser().UserName, "admin")) || (PublicFunctions.GetUserGuid(Membership.GetUser().UserName) == LotToDisplay.UserID))

{

lbutEditLot.Visible = true;

lEditLot.Text = Resources.Site1.EditLot;

lbutEditLot.PostBackUrl = "Create_Lot.aspx?Edit=" + LotID;

}

LotTypes.Auction auc = new LotTypes.Auction();

auc = PublicFunctions.GetActiveAuctionForLot(LotToDisplay.LotID);

if (auc.Approved == 0)

{

ErrorPanel.Visible = true;

L_error.Text =Resources.Site1.LotIsNotApproved;

Panel1.Visible = false;

Panel2.Visible = false;

Panel3.Visible = false;

};

}

//add info about lot

MultiView_LotTypes.ActiveViewIndex = (int)LotToDisplay.LotType.Number – 1;

TB_VehMileage.Text = LotToDisplay.Km.ToString();

PublicFunctions.Get_EngineType_ToDrDL(DrDL_VehEngineType, LotToDisplay.EngineTypesID);

PublicFunctions.Get_TransmissionType_ToDrDL(DrDL_VehTransmission, LotToDisplay.TransmissionTypeID);

TB_MfgWarranty.Text = LotToDisplay.MfgWarranty;

LotTypes.Valuation Val;

if (LotToDisplay.Valuations.Count > 0)

Val = LotToDisplay.Valuations[0];

else

Val = new LotTypes.Valuation();

if (Val.ContactPerson == null)

Val.ContactPerson = new LotTypes.ContactPerson();

if (Val.ContactPerson.Company == null)

Val.ContactPerson.Company = new LotTypes.Company();

LotIndexID = LotToDisplay.IndexID.ToString();

LinkButton1.PostBackUrl = "LotQuestion.aspx?LotID=" + Convert.ToString(LotID);

LinkButton3.PostBackUrl = "AuctionDocuments.aspx?LotID=" + Convert.ToString(LotID);

Master.Title = PublicFunctions.Get_Lot_Name(LotToDisplay, CultureInfo.CurrentCulture);

int f = -1;

for (int j = 0; j < strs1.Length; j++)

{

string Value = "";

// Get values from database

switch (j)

{

case 0:

{

Value = PublicFunctions.Get_Lot_Name(LotToDisplay, CultureInfo.CurrentCulture);// LotName

Label1.Text += " " + Value;

Label1.Text += String.Format("; {0}:{1}:",Resources.Site.Category, PublicFunctions.Get_LotTypes_Name(LotToDisplay, CultureInfo.CurrentCulture));

break;

}

case 1:

Value = null;

foreach (LotTypes.Activity_Lot_Link act in LotToDisplay.Activity_Lot_Links)

{

Value += PublicFunctions.Get_Activity_Name(act.Activity, CultureInfo.CurrentCulture, false) + "<br>";// LotActivity

}

if (Value == null) Value = Resources.Site.Unspecified;

break;

case 2: Value = PublicFunctions.Get_LotIndex_Name(LotToDisplay.LotIndex, CultureInfo.CurrentCulture, false);// LotIndex

break;

case 3: Value = PublicFunctions.Get_LotCategory_Name(LotToDisplay.LotCategory, CultureInfo.CurrentCulture);// LotClass

break;

case 4:

Value = LotToDisplay.Model;// LotModel

break;

case 6:

if (LotToDisplay.MfgDate != null)

Value = ((DateTime)LotToDisplay.MfgDate).ToString("d", CultureInfo.CurrentCulture);

else

Value = "";

break;

case 8:

LotTypes.Auction Auct = PublicFunctions.GetActiveAuctionForLot(LotID);

Value = (Auct != null && Auct.EndDate!=null) ? ((DateTime)Auct.EndDate).ToString("d", CultureInfo.CurrentCulture) : "";

break;

case 9: Value = (!string.IsNullOrEmpty(LotToDisplay.Address)) ? LotToDisplay.Address : LotToDisplay.VisitAddress;

if (!string.IsNullOrEmpty(Value)) Value += ", ";

if (LotToDisplay.City == null) break;

Value += PublicFunctions.Get_City_Name(LotToDisplay.City, CultureInfo.CurrentCulture) + ", ";

Value += PublicFunctions.Get_Country_Name(LotToDisplay.City.Country, CultureInfo.CurrentCulture);

break;

case 10: Value = !(String.IsNullOrEmpty(LotToDisplay.Quantity.ToString())) ? LotToDisplay.Quantity.ToString() : "1";

break;

case 11: Value = PublicFunctions.Get_LotState_Name(LotToDisplay.LotState, CultureInfo.CurrentCulture);

break;

case 12:

if (LotToDisplay.Availability != null)

Value = ((DateTime)LotToDisplay.Availability).ToString("d", CultureInfo.CurrentCulture);

else

Value = "";

break;

case 13: Value = LotToDisplay.MfgWarranty;

break;

case 14: Value = LotToDisplay.SellerWarranty;

break;

case 15: Value = (LotToDisplay.Valuations.Count > 0) ? (LotToDisplay.Valuations[0].EvaluationPrice + " " + PublicFunctions.Get_Currency_Type(LotToDisplay.Valuations[0].Currency, CultureInfo.CurrentCulture)) : "";

break;

case 16: Value = Convert.ToString(LotToDisplay.MinPrice);

break;

/* case 3: // LotClass

break;

case 3: // LotClass

break;

case 3: // LotClass

break;*/

}

if (String.IsNullOrEmpty(Value)) Value=Resources.Site.Unspecified;

if ((j == 5) || (j == 7)) continue;

f *= -1;

TableRow r = new TableRow();

TableCell c = new TableCell();

c.Controls.Add(new LiteralControl(strs1[j]));

if (f == 1) c.BackColor = System.Drawing.Color.FromArgb(248, 248, 248);

else c.BackColor = System.Drawing.Color.FromArgb(219, 231, 221);

c.Width = 170;

c.Height = 15;

c.CssClass = "TableLotCell";

r.Cells.Add(c);

c = new TableCell();

c.Controls.Add(new LiteralControl(Value));

if (f == 1) c.BackColor = System.Drawing.Color.FromArgb(248, 248, 248);

else c.BackColor = System.Drawing.Color.FromArgb(219, 231, 221);

c.Width = 170;

c.Height = 15;

r.Cells.Add(c);

Table1.Rows.Add(r);

}

Label3.Text +=String.Format(" <a href='Auction.aspx?AuctID={0}' target='_blank'>{1}</a>",AuctionToDisplay.AuctionID, PublicFunctions.Get_Auction_Name(AuctionToDisplay, CultureInfo.CurrentCulture));

for (int j = 0; j < table3.Length; j++)

{

string Value = "";

// Get values from database

switch (j)

{

case 0: Value = (LotToDisplay.Valuations.Count > 0) ? PublicFunctions.Get_ValuationType_Name(LotToDisplay.Valuations[0].ValuationType, CultureInfo.CurrentCulture) : "";

break;

case 1: Value = (LotToDisplay.Valuations.Count > 0) ? (LotToDisplay.Valuations[0].EvaluationPrice + " " + PublicFunctions.Get_Currency_Type(LotToDisplay.Valuations[0].Currency, CultureInfo.CurrentCulture)) : "";

break;

case 2: Value = (LotToDisplay.Valuations.Count > 0) ? (Convert.ToString(LotToDisplay.Valuations[0].ValuationDate)) : "";

break;

case 3: if (LotToDisplay.Valuations.Count > 0)

Value = (LotToDisplay.Valuations[0].ContactPerson != null) ? (LotToDisplay.Valuations[0].ContactPerson.Name + " " + LotToDisplay.Valuations[0].ContactPerson.Surname) : "";

break;

case 4:

for (int i = 0; i < AuctionToDisplay.auction_document_links.Count; i++)

{

if (AuctionToDisplay.auction_document_links[i].AuctionDocument != null)

{

Value += AuctionToDisplay.auction_document_links[i].AuctionDocument.Name;

if (i < AuctionToDisplay.auction_document_links.Count – 1) Value += ", ";

}

}

break;

case 5:

break;

case 6:

break;

case 8:

break;

}

if (String.IsNullOrEmpty(Value)) Value = Resources.Site.Unspecified;

if (j == 7) continue;

TableRow r = new TableRow();

TableCell c = new TableCell();

c.Controls.Add(new LiteralControl(table3[j]));

c.Width = 170;

c.Height = 15;

c.CssClass = "TableLotCell";

r.Cells.Add(c);

c = new TableCell();

c.Controls.Add(new LiteralControl(Value));

c.Width = 170;

c.Height = 15;

r.Cells.Add(c);

Table3.Rows.Add(r);

r = new TableRow();

c = new TableCell();

c.ColumnSpan = 2;

c.Controls.Add(new LiteralControl("<hr>"));

r.Cells.Add(c);

Table3.Rows.Add(r);

}

if (AuctionToDisplay != null)

for (int j = 0; j < table4.Length; j++)

{

string Value = "";

// Get values from database

switch (j)

{

case 0: Value = PublicFunctions.Get_Auction_Description(AuctionToDisplay, CultureInfo.CurrentCulture);

break;

case 1: Value = PublicFunctions.Get_AuctionType_Name(AuctionToDisplay.auctiontype_new, CultureInfo.CurrentCulture);

break;

case 2: Value = (AuctionToDisplay.Auction_Visits.Count > 0) ? (AuctionToDisplay.Auction_Visits[0].VisitDate + " " + Convert.ToString(AuctionToDisplay.Auction_Visits[0].StartTime) + " – " + Convert.ToString(AuctionToDisplay.Auction_Visits[0].EndTime)) : "";

break;

case 3: Value = Convert.ToString(AuctionToDisplay.EndDate);

break;

case 4: Value = Convert.ToString(AuctionToDisplay.StartDate);

break;

case 5:

break;

case 6: if (AuctionToDisplay.Auction_Visits.Count > 0)

{

if (AuctionToDisplay.Auction_Visits[0].City == null) break;

Value = PublicFunctions.Get_City_Name(AuctionToDisplay.Auction_Visits[0].City, CultureInfo.CurrentCulture) + ", ";

Value += PublicFunctions.Get_Country_Name(AuctionToDisplay.Auction_Visits[0].City.Country, CultureInfo.CurrentCulture);

}

break;

case 7:

{

ProfileCommon prof = (AuctionToDisplay.aspnet_User != null) ? (ProfileCommon)ProfileBase.Create(AuctionToDisplay.aspnet_User.UserName) : null;

if (prof != null) Value = prof.FNname + " " + prof.LName;

}

break;

case 8:

{

ProfileCommon prof = (AuctionToDisplay.aspnet_User != null) ? (ProfileCommon)ProfileBase.Create(AuctionToDisplay.aspnet_User.UserName) : null;

if (prof != null) Value = prof.Telephone;

}

break;

case 9: if (AuctionToDisplay.aspnet_User != null) Value = AuctionToDisplay.aspnet_User.UserName;

break;

case 10: if (AuctionToDisplay.AuctionMng != null)

if (AuctionToDisplay.AuctionMng.ContactPerson != null)

Value = AuctionToDisplay.AuctionMng.ContactPerson.Name + AuctionToDisplay.AuctionMng.ContactPerson.Surname;

break;

case 11:

if (AuctionToDisplay.AuctionMng != null)

if (AuctionToDisplay.AuctionMng.ContactPerson != null)

Value = AuctionToDisplay.AuctionMng.ContactPerson.Tel;

break;

case 12:

if (AuctionToDisplay.AuctionMng != null)

if (AuctionToDisplay.AuctionMng.ContactPerson != null)

Value = AuctionToDisplay.AuctionMng.ContactPerson.Email;

break;

case 13:

break;

}

if (String.IsNullOrEmpty(Value)) Value = Resources.Site.Unspecified;

if (j == 13) continue;

TableRow r = new TableRow();

TableCell c = new TableCell();

c.Controls.Add(new LiteralControl(table4[j]));

c.Width = 170;

c.Height = 15;

c.CssClass = "TableLotCell";

r.Cells.Add(c);

c = new TableCell();

c.Controls.Add(new LiteralControl(Value));

c.Width = 170;

c.Height = 15;

r.Cells.Add(c);

Table4.Rows.Add(r);

r = new TableRow();

c = new TableCell();

c.ColumnSpan = 2;

c.Controls.Add(new LiteralControl("<hr>"));

r.Cells.Add(c);

Table4.Rows.Add(r);

}

query = from lp in DB.LotPictures

where lp.LotID == LotID

select new PicsItem

{

PicID = lp.PictureID,

PicIntPath = lp.InternalPath,

Pic = lp.InternalPath.Replace("\\", "/") + lp.Picture.Replace("\\", "/"),

PicDesc = PublicFunctions.Get_LotPicture_Description(lp, CultureInfo.CurrentCulture)

};

lviewLotPicture.DataSource = query;

//lviewLotPicture.DataBind();

}

protected void pg_PagerCommand(object sender, DataPagerCommandEventArgs e)

{

e.NewMaximumRows = e.Item.Pager.MaximumRows;

switch (e.CommandName)

{

case "Previous":

if (e.Item.Pager.StartRowIndex > 0)

e.NewStartRowIndex = e.Item.Pager.StartRowIndex – 1;

break;

case "Next":

e.NewStartRowIndex = e.Item.Pager.StartRowIndex + 1;

break;

}

}

protected void AddLotToBasket(object sender, EventArgs e)

{

LotTypes.LotTypesDataContext DB = new LotTypes.LotTypesDataContext();

Guid? UserID = PublicFunctions.GetUserGuid(Profile.UserName);

if (UserID != null && LotID != null)

{

var Temp = from b in DB.UserBaskets

where b.UserID.Equals(UserID)

&& b.LotID == LotID

select b;

if (Temp.Count() == 0)

{

LotTypes.UserBasket BasketItem = new LotTypes.UserBasket();

BasketItem.ID = Guid.NewGuid();

BasketItem.LotID = LotID;

BasketItem.UserID = UserID;

DB.GetTable<LotTypes.UserBasket>().InsertOnSubmit(BasketItem);

DB.SubmitChanges();

div_info.Visible = true;

Label_info.Text = Resources.Site.SucAddToBacket;

ASP.controls_basket_ascx tt = (ASP.controls_basket_ascx)Page.Master.FindControl("Basket1");

tt.Refresh();

}

}

if (UserID == null)

{

div_info.Visible = true;

Label_info.Text = Resources.Site.PleaseLogIn;

}

}

protected void LinkButton5_Click(object sender, EventArgs e)

{

Response.Redirect("LotList.aspx?LotIndexID="+LotIndexID);

}

}

Файл MyBasket.aspx

using System;

using System.Collections;

using System.Configuration;

using System.Data;

using System.Linq;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Xml.Linq;

using System.Collections.Generic;

using System.Globalization;

public class BasketLotInformation

{

public string LotNameHE { get; set; }

public string LotNameEN { get; set; }

public string LotNameRU { get; set; }

public string CityNameHE { get; set; }

public string CityNameEN { get; set; }

public string CityNameRU { get; set; }

public int? Quantity { get; set; }

public string MfgDate { get; set; }

public string Manufacturer { get; set; }

public string Model { get; set; }

public string Condition { get; set; }

public string StateHE { get; set; }

public string StateEN { get; set; }

public string StateRU { get; set; }

public int PictureQuantity { get; set; }

public string LotIndexNameHE { get; set; }

public string LotIndexNameEN { get; set; }

public string LotIndexNameRU { get; set; }

public string AuctionNameHE { get; set; }

public string AuctionNameEN { get; set; }

public string AuctionNameRU { get; set; }

public bool CheckBoxValue { get; set; }

public int LotID { get; set; }

public int AuctionID { get; set; }

public double? Bid { get; set; }

public string CurrencyForBids { get; set; }

public bool BuyDocsCollaterals { get; set; }

public bool ShowMakeBid { get; set; }

public bool LotNotOpened { get; set; }

public double? CountToBuy { get; set; }

public bool ShowCountToBuy { get; set; }

public bool ShowLinkToBids { get; set; }

}

public partial class MyBasket : System.Web.UI.Page

{

protected System.Linq.IQueryable<LotTypes.UserBasket> BasketItemsToDelete

{

get { return Session["BasketItemsToDelete"] as System.Linq.IQueryable<LotTypes.UserBasket>; }

set { Session["BasketItemsToDelete"] = value; }

}

protected string TwoLetterCulture;

protected System.Linq.IQueryable<BasketLotInformation> Results

{

get { return Session["BasketLotListResult"] as System.Linq.IQueryable<BasketLotInformation>; }

set { Session["BasketLotListResult"] = value; }

}

protected List<Guid> BasketsIDToDelete

{

get { return Session["BasketsIDToDelete"] as List<Guid>; }

set { Session["BasketsIDToDelete"] = value; }

}

protected void OnBn_Delete_Confirm(object sender, EventArgs e)

{

DeleteFromBasket(sender, e);

LotTypes.LotTypesDataContext DB = new LotTypes.LotTypesDataContext();

var TembBaskets = from Bi in DB.UserBaskets

// from id in BasketsIDToDelete

where BasketsIDToDelete.Contains(Bi.ID)

select Bi;

DB.UserBaskets.DeleteAllOnSubmit(TembBaskets);

DB.SubmitChanges();

if (Results.Count() == 0)

{

Bn_MakeBid.Visible = false;

Bn_DeleteFromBasket.Visible = false;

Label1_info.Text = Resources.Site.BasketEmpty;

}

}

protected void MakeBids(object sender, EventArgs e)

{

foreach (ListViewDataItem Itm in LV_LotList.Items)

{

LotTypes.LotTypesDataContext DB = new LotTypes.LotTypesDataContext();

int LotID = (int)LV_LotList.DataKeys[Itm.DisplayIndex].Value;

TextBox TB_Bid = (TextBox)Itm.FindControl("TB_Bid");

TextBox TB_CountToBuy = (TextBox)Itm.FindControl("TB_CountToBuy");

bool TB_CTB_Visible = TB_CountToBuy.Visible;

Guid? UserID = PublicFunctions.GetUserGuid(Profile.UserName);

if (TB_Bid != null)

{

double Bid = 0;

TB_Bid.Text = TB_Bid.Text.Replace(',', '.');

bool SuccessParse = double.TryParse(TB_Bid.Text, out Bid);

if (!SuccessParse)

{

TB_Bid.Text = TB_Bid.Text.Replace('.', ',');

SuccessParse = double.TryParse(TB_Bid.Text, out Bid);

}

if (SuccessParse && Bid > 0)

{

if (Bid > DB.GetMaxUserLotBid(UserID, LotID) + 0.001)

{

LotTypes.LotBid LtBid = new LotTypes.LotBid();

LtBid.BidID = Guid.NewGuid();

LtBid.Bidder = UserID;

LtBid.BidValue = Bid;

LtBid.BidDate = DateTime.Now;

LtBid.LotID = LotID;

if (TB_CTB_Visible)

{

double Cnt;

SuccessParse = double.TryParse(TB_CountToBuy.Text, out Cnt);

if (TB_CTB_Visible)

LtBid.Count = Cnt;

}

DB.LotBids.InsertOnSubmit(LtBid);

DB.SubmitChanges();

Label1_info.Text = Resources.Site.SaveOk;

}

}

}

}

}

protected void DeleteFromBasket(object sender, EventArgs e)

{

LotTypes.LotTypesDataContext DB = new LotTypes.LotTypesDataContext();

Guid? UserID = PublicFunctions.GetUserGuid(Profile.UserName);

BasketsIDToDelete.Clear();

if (UserID != null)

{

foreach (ListViewDataItem Itm in LV_LotList.Items)

{

int LotID = (int)LV_LotList.DataKeys[Itm.DisplayIndex].Value;

CheckBox ChB = (CheckBox)Itm.FindControl("CheckBox1");

if (ChB.Checked)

{

System.Linq.IQueryable<LotTypes.UserBasket> BasketItems =

// BasketItemsToDelete =

from Bi in DB.UserBaskets

where Bi.UserID.Equals(UserID)

&& Bi.LotID == LotID

select Bi;

foreach (LotTypes.UserBasket BI in BasketItems)

{

BasketsIDToDelete.Add(BI.ID);

}

System.Linq.IQueryable<LotTypes.Lot> TempLots =

from L in DB.Lots

where L.LotID == LotID

select L;

}

}

} /**/

}

protected override void OnLoadComplete(EventArgs e)

{

base.OnLoadComplete(e);

try

{

LV_LotList.DataSource = Results.ToList();

LV_LotList.DataBind();

}

catch (Exception Err)

{

string S = Err.Message;

}

}

protected void Page_Load(object sender, EventArgs e)

{

LotTypes.LotTypesDataContext DB = new LotTypes.LotTypesDataContext();

TwoLetterCulture = CultureInfo.CurrentCulture.TwoLetterISOLanguageName;

Bn_DeleteFromBasket.Text = Resources.Site1.DeleteFromBasket;

Bn_MakeBid.Text = Resources.Site1.MakeBid;

Master.Title = Resources.Site.MyBasket;

if (!Page.IsPostBack)

{

BasketsIDToDelete = new List<Guid>();

}

Guid? UserUID = PublicFunctions.GetUserGuid(Profile.UserName);

if (UserUID != null)

{

System.Linq.IQueryable<BasketLotInformation> Res;

string StrAuctID = Request.Params["AuctID"];

int AuctID;

bool Success = int.TryParse(StrAuctID, out AuctID);

Res = from ub in DB.UserBaskets

from al in DB.AuctionLots

let CtyNameEN = string.IsNullOrEmpty(al.Lot.City.CityNameEN)

? al.Lot.City.CityName : al.Lot.City.CityNameEN

let CtyNameEN2 = al.Lot.City == null ? Resources.Site.Unspecified : CtyNameEN

let CtyNameRU = string.IsNullOrEmpty(al.Lot.City.CityNameRU)

? al.Lot.City.CityName : al.Lot.City.CityNameRU

let CtyNameRU2 = al.Lot.City == null ? Resources.Site.Unspecified : CtyNameRU

let LINameEN = string.IsNullOrEmpty(al.Lot.LotIndex.NameEN)

? al.Lot.LotIndex.NameHE : al.Lot.LotIndex.NameEN

let LINameEN2 = al.Lot.LotIndex == null ? Resources.Site.Unspecified : LINameEN

let LINameRU = string.IsNullOrEmpty(al.Lot.LotIndex.NameRU)

? al.Lot.LotIndex.NameHE : al.Lot.LotIndex.NameRU

let LINameRU2 = al.Lot.LotIndex == null ? Resources.Site.Unspecified : LINameRU

let ShowLinkToBids1 = DB.ShowLinkToBids(al.Auction.AuctionID)

where

ub.UserID.Equals(UserUID)

&& ub.LotID == al.LotID

&& al.Auction.Approved == 1

// && al.Auction.Active==1

&& (Success == false || al.Auction.AuctionID == AuctID)

select new BasketLotInformation

{

LotNameHE = al.Lot.NameHE,

LotNameEN = string.IsNullOrEmpty(al.Lot.NameEN)

? al.Lot.NameHE

: al.Lot.NameEN,

LotNameRU = string.IsNullOrEmpty(al.Lot.NameRU)

? al.Lot.NameHE

: al.Lot.NameRU,

CityNameHE = al.Lot.City != null ? al.Lot.City.CityName : Resources.Site.Unspecified,

CityNameEN = CtyNameEN2,

CityNameRU = CtyNameRU2,

Quantity = al.Lot.Quantity != null ? al.Lot.Quantity : 1,

MfgDate = al.Lot.MfgDate.ToString() != null ? al.Lot.MfgDate.ToString() != "" ? al.Lot.MfgDate.ToString() : Resources.Site.Unspecified : Resources.Site.Unspecified,

Manufacturer = al.Lot.Manufacturer != null ? al.Lot.Manufacturer != "" ? al.Lot.Manufacturer : Resources.Site.Unspecified : Resources.Site.Unspecified,

Model = al.Lot.Model,

Condition = al.Lot.Condition != null ? al.Lot.Condition != "" ? al.Lot.Condition : Resources.Site.Unspecified : Resources.Site.Unspecified,

StateHE = al.Lot.LotState.LotStateNameHE,

StateRU = al.Lot.LotState.LotStateNameRU,

StateEN = al.Lot.LotState.LotStateNameEN,

PictureQuantity = al.Lot.LotPictures.Count,

LotIndexNameHE = al.Lot.LotIndex != null ?

al.Lot.LotIndex.NameHE

: Resources.Site.Unspecified,

LotIndexNameEN = LINameEN2,

LotIndexNameRU = LINameRU2,

AuctionNameHE = al.Auction.ANameH,

AuctionNameEN = string.IsNullOrEmpty(al.Auction.ANameE)

? al.Auction.ANameH : al.Auction.ANameE,

AuctionNameRU = string.IsNullOrEmpty(al.Auction.ANameRU)

? al.Auction.ANameH : al.Auction.ANameRU,

CheckBoxValue = false,

LotID = al.Lot.LotID,

Bid = DB.GetMaxUserLotBid(UserUID, al.Lot.LotID),

CurrencyForBids = al.Lot.Currency.CurrencySymbol,

AuctionID = al.AuctionID,

BuyDocsCollaterals =

(DB.MustBuyDocsForAuction(UserUID, al.AuctionID) == 1

|| DB.MustBuyCollateralsForAuction(UserUID, al.AuctionID) == 1)

&& al.Lot.LotStateID == 2,

ShowMakeBid =

DB.MustBuyDocsForAuction(UserUID, al.AuctionID) != 1

&& DB.MustBuyCollateralsForAuction(UserUID, al.AuctionID) != 1

&& al.Lot.LotStateID == 2

&& ShowLinkToBids1 != true,

LotNotOpened = al.Lot.LotStateID != 2,

CountToBuy = DB.GetMaxUserLotBidCount(UserUID, al.Lot.LotID),

ShowCountToBuy = DB.Is_Show_BidCount_Field(al.AuctionID) == 1

&& ShowLinkToBids1 != true

? true : false,

ShowLinkToBids = DB.MustBuyDocsForAuction(UserUID, al.AuctionID) != 1

&& DB.MustBuyCollateralsForAuction(UserUID, al.AuctionID) != 1

&& al.Lot.LotStateID == 2

&& ShowLinkToBids1 == true,

};

Results = Res;

if (Results.Count() == 0)

{

Bn_MakeBid.Visible = false;

Bn_DeleteFromBasket.Visible = false;

Label1_info.Text = Resources.Site.BasketEmpty;

}

}

else

{

Bn_MakeBid.Visible = false;

Bn_DeleteFromBasket.Visible = false;

Label1_info.Text = Resources.Site.BasketEmpty;

Results = null;

}

}

protected void BuyDocCollateral_Handler(Object sender, CommandEventArgs e)

{

Response.Redirect("BuyDocuments.aspx?BuyLot=" + e.CommandName);

}

protected void LinkToBids_Handler(Object sender, CommandEventArgs e)

{

Response.Redirect("MakeBid.aspx?LotID=" + e.CommandName);

}

}

Файл Start.aspx

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Configuration;

using System.Web.Security;

using System.Globalization;

public partial class Start : System.Web.UI.Page

{

public class AuctionDB

{

public string NameEN { get; set; }

public string NameRU { get; set; }

public string NameHE { get; set; }

public DateTime? StartDate { get; set; }

public DateTime? EndDate { get; set; }

public int AuctionID { get; set; }

public string AuctionTypeHE { get; set; }

public string AuctionTypeRU { get; set; }

public string AuctionTypeEN { get; set; }

public string ImageUrl { get; set; }

}

public class LotInformation1

{

public string LotNameHE { get; set; }

public string LotNameEN { get; set; }

public string LotNameRU { get; set; }

public string CityNameHE { get; set; }

public string CityNameEN { get; set; }

public string CityNameRU { get; set; }

public int? Quantity { get; set; }

public string MfgDate { get; set; }

public string Manufacturer { get; set; }

public string Model { get; set; }

public string Condition { get; set; }

public string StateHE { get; set; }

public string StateEN { get; set; }

public string StateRU { get; set; }

public string StateID { get; set; }

public int PictureQuantity { get; set; }

public string LotIndexNameHE { get; set; }

public string LotIndexNameEN { get; set; }

public string LotIndexNameRU { get; set; }

public string AuctionNameHE { get; set; }

public string AuctionNameEN { get; set; }

public string AuctionNameRU { get; set; }

public int LotID { get; set; }

public int AuctionID { get; set; }

public float Price { get; set; }

public string Currency { get; set; }

}

protected System.Collections.Generic.List<AuctionDB> Auctions

{

get { return Session["AuctionDB"] as System.Collections.Generic.List<AuctionDB>; }

set { Session["AuctionDB"] = value; }

}

public class AucToApprove

{

public string NameEN { get; set; }

public string NameRU { get; set; }

public string NameHE { get; set; }

public int AuctionID { get; set; }

}

public class LotDB

{

public int ID;

public bool? Hot;

public int State;

public DateTime? EndDate;

public string Desc;

public int? Quantity;

public double? Price;

}

public string MyTime = null;

protected string TwoLetterCulture;

private static bool SearchNewAucts(AuctionDB Auct)

{

if (DateTime.Now.Subtract(Auct.StartDate.Value).Days <= 2) return true;

else return false;

}

protected void Page_Load(object sender, EventArgs e)

{

TwoLetterCulture = CultureInfo.CurrentCulture.TwoLetterISOLanguageName;

Master.Title = Resources.Site.HomePage;

if (!Page.IsPostBack)

{

LotTypes.LotTypesDataContext DB = new LotTypes.LotTypesDataContext();

LotTypes.AppSetting appset = new LotTypes.AppSetting();

appset = DB.AppSettings.Single(a => a.Name == "HttpHost");

appset.Value = "http://" + Request.ServerVariables["HTTP_HOST"] + Request.ApplicationPath;

DB.SubmitChanges();

// Label7.Text = Resources.Site.HotDeals;

System.Collections.Generic.IEnumerable<AuctionDB> Auctions_Filters = from t in DB.Auctions

where t.EndDate >= DateTime.Now && t.StartDate <= DateTime.Now && t.Approved == 1

orderby t.EndDate

select new AuctionDB

{

NameHE = t.ANameH,

NameRU = string.IsNullOrEmpty(t.ANameRU)

? t.ANameH

: t.ANameRU,

NameEN = string.IsNullOrEmpty(t.ANameE)

? t.ANameH

: t.ANameE,

AuctionTypeHE = t.auctiontype_new.NameHE,

AuctionTypeRU = string.IsNullOrEmpty(t.auctiontype_new.NameRU)

? t.auctiontype_new.NameHE

: t.auctiontype_new.NameRU,

AuctionTypeEN = string.IsNullOrEmpty(t.auctiontype_new.NameEN)

? t.auctiontype_new.NameHE

: t.auctiontype_new.NameEN,

ImageUrl = (t.ImagePath + t.ImageName).Replace("\\", "/"),

StartDate = t.StartDate,

EndDate = t.EndDate,

AuctionID = t.AuctionID,

};

Auctions = Auctions_Filters.ToList().FindAll(SearchNewAucts);

foreach (AuctionDB auc in Auctions)

{

string image_url = auc.ImageUrl;

System.IO.FileInfo FilePhoto = new System.IO.FileInfo(Server.MapPath(image_url));

if (!FilePhoto.Exists)

auc.ImageUrl = "Image/Default2/none.png";

}

HotAuctions.DataSource = Auctions;

HotAuctions.DataBind();

//select lot

//List<LotTypes.Lot> HotLots = Auctions.FindAll(a=> a.);

System.Collections.Generic.IEnumerable<LotInformation1> Res =

from fl in DB.Lots.ToList()

from al in fl.AuctionLots

join bl in Auctions.ToList() on al.AuctionID equals bl.AuctionID

let CtyNameEN = al.Lot.City != null &&

!string.IsNullOrEmpty(al.Lot.City.CityNameEN)

? al.Lot.City.CityNameEN : Resources.Site.Unspecified

let CtyNameEN2 = string.IsNullOrEmpty(CtyNameEN) &&

al.Lot.City != null ? al.Lot.City.CityName : CtyNameEN

let CtyNameRU = al.Lot.City != null &&

!string.IsNullOrEmpty(al.Lot.City.CityNameRU)

? al.Lot.City.CityNameRU : Resources.Site.Unspecified

let CtyNameRU2 = string.IsNullOrEmpty(CtyNameRU) &&

al.Lot.City != null ? al.Lot.City.CityName : CtyNameRU

let LINameEN = al.Lot.LotIndex != null &&

!string.IsNullOrEmpty(al.Lot.LotIndex.NameEN)

? al.Lot.LotIndex.NameEN : Resources.Site.Unspecified

let LINameEN2 = string.IsNullOrEmpty(LINameEN) && al.Lot.LotIndex != null

? al.Lot.LotIndex.NameHE : LINameEN

let LINameRU = al.Lot.LotIndex != null &&

!string.IsNullOrEmpty(al.Lot.LotIndex.NameRU)

? al.Lot.LotIndex.NameRU : Resources.Site.Unspecified

let LINameRU2 = string.IsNullOrEmpty(LINameRU) && al.Lot.LotIndex != null

? al.Lot.LotIndex.NameHE : LINameRU

where

al.Auction.Approved == 1&&al.Lot.LotID==fl.LotID

select new LotInformation1

{

LotNameHE = al.Lot.NameHE,

LotNameEN = string.IsNullOrEmpty(al.Lot.NameEN)

? al.Lot.NameHE

: al.Lot.NameEN,

LotNameRU = string.IsNullOrEmpty(al.Lot.NameRU)

? al.Lot.NameHE

: al.Lot.NameRU,

CityNameHE = al.Lot.City != null ? al.Lot.City.CityName : Resources.Site.Unspecified,

CityNameEN = CtyNameEN2,

CityNameRU = CtyNameRU2,

Quantity = al.Lot.Quantity != null ? al.Lot.Quantity : 1,

MfgDate = !String.IsNullOrEmpty(al.Lot.MfgDate.ToString()) ? al.Lot.MfgDate.ToString() : Resources.Site.Unspecified,

Manufacturer = !String.IsNullOrEmpty(al.Lot.Manufacturer) ? al.Lot.Manufacturer : Resources.Site.Unspecified,

Model = al.Lot.Model,

Price=al.Lot.MinPrice,

Currency=al.Lot.Currency.CurrencySymbol,

Condition = !String.IsNullOrEmpty(al.Lot.Condition) ? al.Lot.Condition : Resources.Site.Unspecified,

StateHE = al.Lot.LotState.LotStateNameHE,

StateRU = al.Lot.LotState.LotStateNameRU,

StateEN = al.Lot.LotState.LotStateNameEN,

StateID = al.Lot.LotStateID.ToString(),

PictureQuantity = al.Lot.LotPictures.Count,

LotIndexNameHE = al.Lot.LotIndex != null ?

al.Lot.LotIndex.NameHE

: Resources.Site.Unspecified,

LotIndexNameEN = LINameEN2,

LotIndexNameRU = LINameRU2,

AuctionNameHE = al.Auction.ANameH,

AuctionNameEN = string.IsNullOrEmpty(al.Auction.ANameE)

? al.Auction.ANameH : al.Auction.ANameE,

AuctionNameRU = string.IsNullOrEmpty(al.Auction.ANameRU)

? al.Auction.ANameH : al.Auction.ANameRU,

LotID = al.Lot.LotID,

AuctionID = al.AuctionID,

};

HotLots.DataSource = Res.ToList();

HotLots.DataBind();

}

}

protected override void OnLoadComplete(EventArgs e)

{

try

{

base.OnLoadComplete(e);

HotAuctions.DataSource = Auctions;

HotAuctions.DataBind();

}

catch { return; }

}

}

Файл LotQuestion.aspx

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Configuration;

using System.Globalization;

public partial class LotQuestion : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

switch (CultureInfo.CurrentCulture.TwoLetterISOLanguageName)

{

case "en":

cssLink.Href = "dif_left.css";

break;

case "ru":

cssLink.Href = "dif_left.css";

break;

case "he":

cssLink.Href = "dif_right.css";

break;

}

if (Page.User.Identity.IsAuthenticated)

{

string StrLotID = Request.Params["LotID"];

string StrAuctionID = Request.Params["AuctID"];

if (!String.IsNullOrEmpty(StrAuctionID))

{

lAskQeustion.Text = Resources.Site.AucQuestion + ":";

bSend.Text = Resources.Site.Send;

Label1.Text =String.Format(Resources.Site.AskDetailAuc,Profile.UserName);

return;

}

if ( !String.IsNullOrEmpty(StrLotID) )

{

lAskQeustion.Text = Resources.Site.LotQuestion + ":";

bSend.Text = Resources.Site.Send;

Label1.Text = String.Format(Resources.Site.AskDetaliLot, Profile.UserName);

return;

}

lAskQeustion.Visible = false;

tbLetter.Visible = false;

bSend.Visible = false;

}

else

{

lAskQeustion.Visible=false;

LinkButton_rezult.Visible=true;

LinkButton_rezult.Text= Resources.Site.PleaseLogIn;

tbLetter.Visible = false;

bSend.Visible = false;

}

}

protected void bSend_Click(object sender, EventArgs e)

{

string StrLotID = Request.Params["LotID"];

string StrAuctionID = Request.Params["AuctID"];

bool ForLot = false;

bool ForAuct = false;

string body_info = "";

string Subject = null;

string ToAddress = null;

string AnswerTo = null;

bool rez1=false,rez2=false;

string smtrServerIP = ConfigurationManager.AppSettings["SmtpServer"].ToString();

string user = ConfigurationManager.AppSettings["EmailCredentialUser"].ToString();

string pass = ConfigurationManager.AppSettings["EmailCredentialPassword"].ToString();

string FromAddress = ConfigurationManager.AppSettings["FromAddress"].ToString();

try

{

LotTypes.Auction auc = null;

LotTypes.LotTypesDataContext DB = new LotTypes.LotTypesDataContext();

if (!string.IsNullOrEmpty(StrLotID))

{

ForLot = true;

LotTypes.Lot ask_lot = DB.Lots.First(a => a.LotID.ToString() == StrLotID);

body_info = String.Format("Name lot: {0} <br> Description of lot:{1} ", ask_lot.NameHE, ask_lot.DescriptionEN);

auc = PublicFunctions.GetActiveAuctionForLot(Convert.ToInt32(StrLotID));

Subject = "Question about lot: "+ask_lot.NameEN;

}

if (!string.IsNullOrEmpty(StrAuctionID))

{

ForAuct = true;

LotTypes.Auction ask_auc = DB.Auctions.First(a => a.AuctionID.ToString() == StrAuctionID);

auc = PublicFunctions.GetAuctionByID(int.Parse(StrAuctionID));

Subject = "Question about auction: " + ask_auc.ANameE;

}

if (auc != null)

{

body_info += String.Format("Name auction: {0} <br> Type of auction:{1}", auc.ANameE, auc.auctiontype_new.NameEN);

var query2 = from a in DB.aspnet_Memberships

where a.UserId == PublicFunctions.GetUserGuid(Profile.UserName)

select a.Email;

AnswerTo = query2.FirstOrDefault();

if (auc.AuctionMng != null)

{

if (auc.AuctionMng.ContactPerson != null)

{

if (!String.IsNullOrEmpty(auc.AuctionMng.ContactPerson.Email))

{

ToAddress = auc.AuctionMng.ContactPerson.Email;

string Body = "<html><body>" + Subject + "<br>" + body_info + "<br>User: " + Profile.UserName + " ask: <br>" + tbLetter.Text + "<br>Please, write answer to this email:" + AnswerTo + "</body></html>";

rez1 = NewsLetterManager.SendMail(smtrServerIP, FromAddress, ToAddress, Subject, Body, user, pass, null);

}

else rez1 = true;

}

else rez1 = true;

}

else rez1 = true;

if (ForAuct)

{

var query = from a in DB.Auctions

join b in DB.aspnet_Memberships

on a.UserId equals b.UserId into ab

from b in ab.DefaultIfEmpty()

where a.AuctionID.ToString() == StrAuctionID

select b.Email;

ToAddress = query.FirstOrDefault();

}

if (ForLot)

{

var query = from a in DB.Lots

join b in DB.aspnet_Memberships

on a.UserID equals b.UserId into ab

from b in ab.DefaultIfEmpty()

where a.LotID.ToString() == StrLotID

select b.Email;

ToAddress = query.FirstOrDefault();

}

}

else

{

LinkButton_rezult.Text = Resources.Site.SendEmailRezultNo;

LinkButton_rezult.Visible = true;

return;

}

if (!String.IsNullOrEmpty(ToAddress))

{

string Body = "<html><body>"+Subject+"<br>" + body_info + "<br>User: "+Profile.UserName+" ask: <br>" + tbLetter.Text + "<br>Please, write answer to this email:" + AnswerTo + "</body></html>";

rez2 = NewsLetterManager.SendMail(smtrServerIP, FromAddress, ToAddress, Subject, Body, user, pass, null);

if (rez1 && rez2)

{

LinkButton_rezult.Text = Resources.Site.SendEmailRezultOk;

tbLetter.Text = "";

LinkButton_rezult.Visible = true;

return;

}

else { throw new Exception(); }

}

}

catch

{

LinkButton_rezult.Text = Resources.Site.SendEmailRezultNo; ;

LinkButton_rezult.Visible = true;

}

}

}

Файл Profile.aspx

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Globalization;

namespace ProfilePage

{

class AuctionComparer : IEqualityComparer<MyOwnAuctions>

{

// Products are equal if their names and product numbers are equal.

public bool Equals(MyOwnAuctions x, MyOwnAuctions y)

{

// Check whether the compared objects reference the same data.

if (Object.ReferenceEquals(x, y)) return true;

// Check whether any of the compared objects is null.

if (Object.ReferenceEquals(x, null) || Object.ReferenceEquals(y, null))

return false;

// Check whether the products' properties are equal.

return x.AuctionId == y.AuctionId;

}

// If Equals() returns true for a pair of objects,

// GetHashCode must return the same value for these objects.

public int GetHashCode(MyOwnAuctions Auct)

{

// Check whether the object is null.

if (Object.ReferenceEquals(Auct, null)) return 0;

// Get the hash code for the Name field if it is not null.

int hashProductName = Auct.AuctionId == null ? 0 : Auct.AuctionId.GetHashCode();

// Calculate the hash code for the product.

return hashProductName;

}

}

class LotComparer : IEqualityComparer<MyOwnLots>

{

// Products are equal if their names and product numbers are equal.

public bool Equals(MyOwnLots x, MyOwnLots y)

{

// Check whether the compared objects reference the same data.

if (Object.ReferenceEquals(x, y)) return true;

// Check whether any of the compared objects is null.

if (Object.ReferenceEquals(x, null) || Object.ReferenceEquals(y, null))

return false;

// Check whether the products' properties are equal.

return x.LotID == y.LotID;

}

// If Equals() returns true for a pair of objects,

// GetHashCode must return the same value for these objects.

public int GetHashCode(MyOwnLots Lot)

{

// Check whether the object is null.

if (Object.ReferenceEquals(Lot, null)) return 0;

// Get the hash code for the Name field if it is not null.

int hashProductName = Lot.LotID == null ? 0 : Lot.LotID.GetHashCode();

// Calculate the hash code for the product.

return hashProductName;

}

}

}

public class BidsForMyLots

{

public string LotNameHE { get; set; }

public string LotNameEN { get; set; }

public string LotNameRU { get; set; }

public string BidderName { get; set; }

public double? BidValue { get; set; }

public bool ChowWinnerCheckbox { get; set; }

public bool Checked { get; set; }

public Guid BidID { get; set; }

}

public class MyOwnAuctions

{

public string AuctionNameHE { get; set; }

public string AuctionNameEN { get; set; }

public string AuctionNameRU { get; set; }

public string IsApproved { get; set; }

public DateTime? StartDate { get; set; }

public DateTime? EndDate { get; set; }

public int AuctionId { get; set; }

public bool CanBeReopen { get; set; }

}

public class MyOwnLots

{

public string LotNameHE { get; set; }

public string LotNameEN { get; set; }

public string LotNameRU { get; set; }

public double? MaxBid { get; set; }

public double? SubLotBids { get; set; }

public int LotID { get; set; }

public string StateHE { get; set; }

public string StateEN { get; set; }

public string StateRU { get; set; }

public string Winner { get; set; }

public string FactPay { get; set; }

}

public partial class SellerProfile : System.Web.UI.Page

{

protected string TwoLetterCulture;

protected List<BidsForMyLots> ResBidsForMyLots

{

get { return Session["Prof_ResBidsForMyLots"] as List<BidsForMyLots>;}

set { Session["Prof_ResBidsForMyLots"] = value; }

}

protected List<MyOwnAuctions> ResAuctionList

{

get { return Session["Prof_ResAuctionList"] as List<MyOwnAuctions>; }

set { Session["Prof_ResAuctionList"] = value; }

}

protected List<MyOwnLots> ResLotList

{

get { return Session["Prof_ResLotList"] as List<MyOwnLots>; }

set { Session["Prof_ResLotList"] = value; }

}

protected bool? OrderAuctionName

{

get { return Session["Profile_OrderAuctionName"] as bool?; }

set { Session["Profile_OrderAuctionName"] = value; }

}

protected bool? OrderIsApproved

{

get { return Session["Profile_OrderIsApproved"] as bool?; }

set { Session["Profile_OrderIsApproved"] = value; }

}

protected bool? OrderStartDate

{

get { return Session["Profile_OrderStartDate"] as bool?; }

set { Session["Profile_OrderStartDate"] = value; }

}

protected bool? OrderEndDate

{

get { return Session["Profile_OrderEndDate"] as bool?; }

set { Session["Profile_OrderEndDate"] = value; }

}

protected bool? OrderLotName

{

get { return Session["Profile_OrderLotName"] as bool?; }

set { Session["Profile_OrderLotName"] = value; }

}

protected bool? OrderMaxBid

{

get { return Session["Profile_OrderMaxBid"] as bool?; }

set { Session["Profile_OrderMaxBid"] = value; }

}

protected bool? OrderBidOfSubLots

{

get { return Session["Profile_OrderBidOfSubLots"] as bool?; }

set { Session["Profile_OrderBidOfSubLots"] = value; }

}

protected bool? OrderWinner

{

get { return Session["Profile_OrderWinner"] as bool?; }

set { Session["Profile_OrderWinner"] = value; }

}

protected int? CurrentLotToDisplay

{

get { return Session["Profile_CurrentLotToDisplay"] as int?; }

set { Session["Profile_CurrentLotToDisplay"] = value; }

}

public class AucToApprove

{

public string NameEN { get; set; }

public string NameRU { get; set; }

public string NameHE { get; set; }

public int AuctionID { get; set; }

}

protected override void OnLoadComplete(EventArgs e)

{

base.OnLoadComplete(e);

try

{

LV_SellerAuctionsList.DataSource = ResAuctionList;

LV_SellerAuctionsList.DataBind();

LV_SellerLotList.DataSource = ResLotList;

LV_SellerLotList.DataBind();

LV_LotBids.DataSource = ResBidsForMyLots;

LV_LotBids.DataBind();

}

catch (Exception Err)

{

string S = Err.Message;

}

}

protected void Page_Load(object sender, EventArgs e)

{

Label2.Text = Resources.Site1.YouLot;

Master.Title = Resources.Site.Profile;

if (ResBidsForMyLots != null)

ResBidsForMyLots.Clear();

if (!Page.IsPostBack)

{

OrderAuctionName = true;

OrderIsApproved = true;

OrderStartDate = true;

OrderEndDate = true;

OrderLotName = true;

OrderMaxBid = true;

OrderBidOfSubLots = true;

OrderWinner = true;

}

TwoLetterCulture = CultureInfo.CurrentCulture.TwoLetterISOLanguageName;

Guid? UserID = PublicFunctions.GetUserGuid(Profile.UserName);

LotTypes.LotTypesDataContext DB = new LotTypes.LotTypesDataContext();

if (!Page.IsPostBack)

{

var NotAprAuc = from a in DB.Auctions

where a.UserId == UserID && a.Approved == 0 && a.AuctionLots.Count == 0

select new AucToApprove

{

AuctionID = a.AuctionID,

NameEN = a.ANameE,

NameHE = a.ANameH,

NameRU = a.ANameRU

};

if (NotAprAuc.Count() != 0)

{

Label_info.Visible = true;

Label_info.Text=Resources.Site1.AucHaveNoLot;

}

System.Collections.Generic.IEnumerable<MyOwnAuctions> SellerAuctions =

from Auct in DB.Auctions

where Auct.UserId.Equals(UserID)

select new MyOwnAuctions

{

AuctionNameHE = Auct.ANameH,

AuctionNameEN = string.IsNullOrEmpty(Auct.ANameE.Trim())

? Auct.ANameH

: Auct.ANameE,

AuctionNameRU = string.IsNullOrEmpty(Auct.ANameRU.Trim())

? Auct.ANameH

: Auct.ANameRU,

IsApproved = Auct.Approved == 1 ? "Yes" : "No",

StartDate = Auct.StartDate,

EndDate = Auct.EndDate,

AuctionId = Auct.AuctionID,

//////////////////

CanBeReopen = DB.AuctionCanReopen(Auct.AuctionID)==1,

};

var R = SellerAuctions.Distinct(new ProfilePage.AuctionComparer());

ResAuctionList = R.ToList();

System.Collections.Generic.IEnumerable<MyOwnLots> SellerLots =

from Lt in DB.Lots

join wn in DB.Winners on Lt.LotID equals wn.LotID

into w

from Winr in w.DefaultIfEmpty()

// from Winr in Lt.Winners

where Lt.UserID.Equals(UserID)

let MB = DB.GetMaxLotBid(Lt.LotID)

let SLB = DB.GetMaxSubLotBid(Lt.LotID)

select new MyOwnLots

{

LotNameHE = Lt.NameHE,

LotNameEN = string.IsNullOrEmpty(Lt.NameEN.Trim())

? Lt.NameHE

: Lt.NameEN,

LotNameRU = string.IsNullOrEmpty(Lt.NameRU.Trim())

? Lt.NameHE

: Lt.NameRU,

MaxBid = MB == null ? 0 : MB,

SubLotBids = SLB,

LotID = Lt.LotID,

StateHE =Lt.LotState.LotStateNameHE,

StateRU =Lt.LotState.LotStateNameRU,

StateEN =Lt.LotState.LotStateNameEN,

Winner = Winr != null

?Winr.LotBid.aspnet_User.UserName

: "",

FactPay=Winr.WasPayed==1 ? Resources.Site.AlreadyPay: "",

};

ResLotList = SellerLots.ToList();

}

}

protected void Order_Auct_Handler(Object sender, CommandEventArgs e)

{

System.Collections.Generic.IEnumerable<MyOwnAuctions> Temp = null;

switch (e.CommandName)

{

case "OrderAuctionName":

switch (TwoLetterCulture)

{

case "he":

if (OrderAuctionName != false)

{

Temp = from R in ResAuctionList

orderby R.AuctionNameHE ascending

select R;

OrderAuctionName = false;

}

else

{

Temp = from R in ResAuctionList

orderby R.AuctionNameHE descending

select R;

OrderAuctionName = true;

}

break;

case "en":

if (OrderAuctionName != false)

{

Temp = from R in ResAuctionList

orderby R.AuctionNameEN ascending

select R;

OrderAuctionName = false;

}

else

{

Temp = from R in ResAuctionList

orderby R.AuctionNameEN descending

select R;

OrderAuctionName = true;

}

break;

case "ru":

if (OrderAuctionName != false)

{

Temp = from R in ResAuctionList

orderby R.AuctionNameRU ascending

select R;

OrderAuctionName = false;

}

else

{

Temp = from R in ResAuctionList

orderby R.AuctionNameRU descending

select R;

OrderAuctionName = true;

}

break;

}

break;

case "OrderIsApproved":

if (OrderIsApproved != false)

{

Temp = from R in ResAuctionList

orderby R.IsApproved ascending

select R;

OrderIsApproved = false;

}

else

{

Temp = from R in ResAuctionList

orderby R.IsApproved descending

select R;

OrderIsApproved = true;

}

break;

case "OrderStartDate":

if (OrderStartDate != false)

{

Temp = from R in ResAuctionList

orderby R.StartDate ascending

select R;

OrderStartDate = false;

}

else

{

Temp = from R in ResAuctionList

orderby R.StartDate descending

select R;

OrderStartDate = true;

}

break;

case "OrderEndDate":

if (OrderEndDate != false)

{

Temp = from R in ResAuctionList

orderby R.EndDate ascending

select R;

OrderEndDate = false;

}

else

{

Temp = from R in ResAuctionList

orderby R.EndDate descending

select R;

OrderEndDate = true;

}

break;

}

ResAuctionList = Temp.ToList();

}

protected void Show_Lots_Handler(Object sender, CommandEventArgs e)

{

LotTypes.LotTypesDataContext DB = new LotTypes.LotTypesDataContext();

Guid? UserID = PublicFunctions.GetUserGuid(Profile.UserName);

if(e.CommandName.Equals("ShowAuctionLots"))

{

int AuctionID = int.Parse((string)e.CommandArgument);

LotTypes.Auction Auction = DB.Auctions.First(a => a.AuctionID== AuctionID);

string nameauction = PublicFunctions.Get_Auction_Name(Auction, CultureInfo.CurrentCulture);

///////////////////////////////////////////

System.Collections.Generic.IEnumerable<MyOwnLots> Temp =

from Lt in DB.Lots

join wn in DB.Winners on Lt.LotID equals wn.LotID

into w

from Winr in w.DefaultIfEmpty()

from al in Lt.AuctionLots

// from Winr in Lt.Winners

where Lt.UserID.Equals(UserID) &&

al.Auction.AuctionID == AuctionID

&& al.Lot.ParentLotID == null

let MB = DB.GetMaxLotBid(Lt.LotID)

let SLB = DB.GetMaxSubLotBid(Lt.LotID)

select new MyOwnLots

{

LotNameHE = Lt.NameHE,

LotNameEN = string.IsNullOrEmpty(Lt.NameEN.Trim())

? Lt.NameHE

: Lt.NameEN,

LotNameRU = string.IsNullOrEmpty(Lt.NameRU.Trim())

? Lt.NameHE

: Lt.NameRU,

MaxBid = MB == null ? 0 : MB,

SubLotBids = SLB,

LotID = Lt.LotID,

StateHE = Lt.LotState.LotStateNameHE,

StateRU = Lt.LotState.LotStateNameRU,

StateEN = Lt.LotState.LotStateNameEN,

Winner = Winr != null

? Winr.LotBid.aspnet_User.UserName

: "",

FactPay = Winr.WasPayed == 1 ? Resources.Site.AlreadyPay : "",

};

ResLotList = Temp.Distinct(new ProfilePage.LotComparer()).ToList();

Label2.Text =String.Format(Resources.Site1.YouLotforAuction,nameauction);

}

if(e.CommandName.Equals("ShowSubLots"))

{

int LotID = int.Parse((string)e.CommandArgument);

CurrentLotToDisplay = LotID;

Label2.Text = Resources.Site1.YouSubLot;

///////////////////////////////////////////

System.Collections.Generic.IEnumerable<MyOwnLots> Temp =

from Lt in DB.Lots

join wn in DB.Winners on Lt.LotID equals wn.LotID

into w

from Winr in w.DefaultIfEmpty()

from al in Lt.AuctionLots

// from Winr in Lt.Winners

where Lt.UserID.Equals(UserID) && al.Lot.ParentLotID == LotID // Only root

let MB = DB.GetMaxLotBid(Lt.LotID)

let SLB = DB.GetMaxSubLotBid(Lt.LotID)

select new MyOwnLots

{

LotNameHE = Lt.NameHE,

LotNameEN = string.IsNullOrEmpty(Lt.NameEN.Trim())

? Lt.NameHE

: Lt.NameEN,

LotNameRU = string.IsNullOrEmpty(Lt.NameRU.Trim())

? Lt.NameHE

: Lt.NameRU,

MaxBid = MB == null ? 0 : MB,

SubLotBids = SLB,

LotID = Lt.LotID,

StateHE = Lt.LotState.LotStateNameHE,

StateRU = Lt.LotState.LotStateNameRU,

StateEN = Lt.LotState.LotStateNameEN,

Winner = Winr != null

? Winr.LotBid.aspnet_User.UserName

: "",

};

ResLotList = Temp.Distinct(new ProfilePage.LotComparer()).ToList();

// Display bids for selected lot

ShowSelectedLotBids(LotID);

}

}

protected void OnReopenAuction(Object sender, CommandEventArgs e)

{

if (e.CommandName == "ReopenAuction")

{

int AuctID = int.Parse((string)e.CommandArgument);

Response.Redirect("create_auction.aspx?Edit=" + AuctID);

}

}

protected void ShowSelectedLotBids(int LotID)

{

// BidsForMyLots

LotTypes.LotTypesDataContext DB = new LotTypes.LotTypesDataContext();

System.Collections.Generic.IEnumerable<BidsForMyLots> Temp =

from Bd in DB.LotBids

let CanMakeBids = Bd.Lot.LotStateID!=2? true : false

let CanMakeBids2 = DB.ChildrenHasWinners(Bd.LotID) == 1

|| DB.ParentHasWinners(Bd.LotID) == 1

? false

: true

where Bd.LotID == LotID

select new BidsForMyLots

{

BidID = Bd.BidID,

LotNameHE = Bd.Lot.NameHE,

LotNameEN = string.IsNullOrEmpty(Bd.Lot.NameEN)

? Bd.Lot.NameEN

: Bd.Lot.NameHE,

LotNameRU = string.IsNullOrEmpty(Bd.Lot.NameRU)

? Bd.Lot.NameRU

: Bd.Lot.NameHE,

BidValue = Bd.BidValue,

BidderName = Bd.aspnet_User.UserName,

ChowWinnerCheckbox = CanMakeBids && CanMakeBids2,

Checked = DB.IsPriorBidForLot(Bd.LotID, Bd.BidID) == 1

? true

: false,

};

ResBidsForMyLots = Temp.ToList();

}

protected void Order_Lot_Handler(Object sender, CommandEventArgs e)

{

System.Collections.Generic.IEnumerable<MyOwnLots> Temp = null;

switch (e.CommandName)

{

case "OrderLotName":

switch (TwoLetterCulture)

{

case "he":

if (OrderLotName != false)

{

Temp = from R in ResLotList

orderby R.LotNameHE ascending

select R;

OrderLotName = false;

}

else

{

Temp = from R in ResLotList

orderby R.LotNameHE descending

select R;

OrderLotName = true;

}

break;

case "en":

if (OrderLotName != false)

{

Temp = from R in ResLotList

orderby R.LotNameEN ascending

select R;

OrderLotName = false;

}

else

{

Temp = from R in ResLotList

orderby R.LotNameEN descending

select R;

OrderLotName = true;

}

break;

case "ru":

if (OrderLotName != false)

{

Temp = from R in ResLotList

orderby R.LotNameRU ascending

select R;

OrderLotName = false;

}

else

{

Temp = from R in ResLotList

orderby R.LotNameRU descending

select R;

OrderLotName = true;

}

break;

}

break;

case "OrderMaxBid":

if (OrderMaxBid != false)

{

Temp = from R in ResLotList

orderby R.MaxBid ascending

select R;

OrderMaxBid = false;

}

else

{

Temp = from R in ResLotList

orderby R.MaxBid descending

select R;

OrderMaxBid = true;

}

break;

case "OrderBidOfSubLots":

if (OrderBidOfSubLots != false)

{

Temp = from R in ResLotList

orderby R.SubLotBids ascending

select R;

OrderBidOfSubLots = false;

}

else

{

Temp = from R in ResLotList

orderby R.SubLotBids descending

select R;

OrderBidOfSubLots = true;

}

break;

case "OrderWinner":

if (OrderWinner != false)

{

Temp = from R in ResLotList

orderby R.Winner ascending

select R;

OrderWinner = false;

}

else

{

Temp = from R in ResLotList

orderby R.Winner descending

select R;

OrderWinner = true;

}

break;

}

ResLotList = Temp.ToList();

}

protected void Order_Bid_Handler(Object sender, CommandEventArgs e)

{

// OrderLotName

// OrderBidValue

// OrderBidderName

System.Collections.Generic.IEnumerable<MyOwnLots> Temp = null;

switch (e.CommandName)

{

case "OrderLotName":

switch (TwoLetterCulture)

{

case "he":

if (OrderLotName != false)

{

Temp = from R in ResLotList

orderby R.LotNameHE ascending

select R;

OrderLotName = false;

}

else

{

Temp = from R in ResLotList

orderby R.LotNameHE descending

select R;

OrderLotName = true;

}

break;

case "en":

if (OrderLotName != false)

{

Temp = from R in ResLotList

orderby R.LotNameEN ascending

select R;

OrderLotName = false;

}

else

{

Temp = from R in ResLotList

orderby R.LotNameEN descending

select R;

OrderLotName = true;

}

break;

case "ru":

if (OrderLotName != false)

{

Temp = from R in ResLotList

orderby R.LotNameRU ascending

select R;

OrderLotName = false;

}

else

{

Temp = from R in ResLotList

orderby R.LotNameRU descending

select R;

OrderLotName = true;

}

break;

}

break;

case "OrderMaxBid":

if (OrderMaxBid != false)

{

Temp = from R in ResLotList

orderby R.MaxBid ascending

select R;

OrderMaxBid = false;

}

else

{

Temp = from R in ResLotList

orderby R.MaxBid descending

select R;

OrderMaxBid = true;

}

break;

case "OrderBidOfSubLots":

if (OrderBidOfSubLots != false)

{

Temp = from R in ResLotList

orderby R.SubLotBids ascending

select R;

OrderBidOfSubLots = false;

}

else

{

Temp = from R in ResLotList

orderby R.SubLotBids descending

select R;

OrderBidOfSubLots = true;

}

break;

}

ResLotList = Temp.ToList();

}

protected void On_Bn_MakeWinner_Click(object sender, EventArgs e)

{

LotTypes.LotTypesDataContext DB = new LotTypes.LotTypesDataContext();

// Delete old winners

var DeletedWinnersForLot =

from wnr in DB.Winners

where wnr.LotID == CurrentLotToDisplay

&& wnr.Auction.Active == 1

select wnr;

DB.GetTable<LotTypes.Winner>().DeleteAllOnSubmit(DeletedWinnersForLot);

DB.SubmitChanges();

// Select active auction for lot

int? ActiveAuctionID = PublicFunctions.GetActiveAuctionForLot(CurrentLotToDisplay);

List<string> SelectedWin = new List<string>();

if (CurrentLotToDisplay != null && ActiveAuctionID != null)

{

foreach (ListViewDataItem Itm in LV_LotBids.Items)

{

CheckBox ChB = (CheckBox)Itm.FindControl("ChB_Winner");

Label LName = (Label)Itm.FindControl("BidName");

string Name = LName.Text;

Guid BidID = (Guid)LV_LotBids.DataKeys[Itm.DisplayIndex].Value;

if (ChB.Checked)

{

if (!SelectedWin.Contains(Name))

{

LotTypes.Winner Winr = new LotTypes.Winner();

Winr.ID = Guid.NewGuid();

Winr.LotID = CurrentLotToDisplay;

Winr.Bid = BidID;

Winr.AuctionID = ActiveAuctionID;

DB.GetTable<LotTypes.Winner>().InsertOnSubmit(Winr);

DB.SubmitChanges();

SelectedWin.Add(Name);

}

}

}

}

Response.Redirect(Request.Url.ToString());

}

}

Файл NewClaim.aspx

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Configuration;

public partial class NewClaim : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

Master.Title = Resources.Site.WriteBad;

string StAuctID = Request.Params["AuctID"];

if (String.IsNullOrEmpty(StAuctID)) { MultiView1.ActiveViewIndex = 1;

Label_status.Text = Resources.Site.NoAuct; return; }

if (!Page.User.Identity.IsAuthenticated)

{

MultiView1.ActiveViewIndex = 1;

Label_status.Text = Resources.Site.PleaseLogIn;

return;

}

else

{

// LabelInfo.Text = String.Format("Info about choise auction:<br><br>Auction name: {1}<br> AuctionID {2}<br> AuctionOwner {3}", auc.ANameE, auc.AuctionID, auc.AuctionMng.ContactPerson.Name + " " + auc.AuctionID, auc.AuctionMng.ContactPerson.Surname);

//}

Label1.Text = String.Format(Resources.Site.AttentionBad, Profile.UserName);

MultiView1.ActiveViewIndex = 0;

}

}

protected void Button1_Click(object sender, EventArgs e)

{

try

{

string StAuctID = Request.Params["AuctID"];

SystemEmail Email = NewsLetterManager.GetSystemEmail("ask_admin");

string Body = string.Format(Email.Body, StAuctID, Page.User.Identity.Name, TextBox_comment.Text);

string Subject = Email.Subject;

// Send email about registration

string smtrServerIP = ConfigurationManager.AppSettings["SmtpServer"].ToString();

string ToAddress = ConfigurationManager.AppSettings["FromAddress"].ToString();

string user = ConfigurationManager.AppSettings["EmailCredentialUser"].ToString();

string pass = ConfigurationManager.AppSettings["EmailCredentialPassword"].ToString();

LotTypes.LotTypesDataContext DB = new LotTypes.LotTypesDataContext();

var query2 = from a in DB.aspnet_Memberships

where a.UserId == PublicFunctions.GetUserGuid(Profile.UserName)

select a.Email;

string FromAddress = query2.FirstOrDefault();

if (!String.IsNullOrEmpty(FromAddress))

NewsLetterManager.SendMail(smtrServerIP, FromAddress, ToAddress, Subject, Body, user, pass, null);

else { throw new Exception(); }

MultiView1.ActiveViewIndex = 1;

Label_status.Text=Resources.Site.SendEmailRezultOk;

}

catch

{

MultiView1.ActiveViewIndex = 1;

Label_status.Text = Resources.Site.SendEmailRezultNo;

}

}

}

Файл NewsLetters.aspx

using System;

using System.Collections.Generic;

using System.Linq;

using System.Data;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.Configuration;

using System.Data.SqlClient;

using System.Globalization;

using System.Configuration;

using System.Web.Security;

public partial class NewsLetters : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

lSent.Visible = false;

lTimeApplied.Visible = false;

if (!Page.IsPostBack)

{

Master.Title = Resources.Site.NewslettersManagement;

}

if (!(Membership.GetUser() != null) || !(Roles.IsUserInRole(Membership.GetUser().UserName, "Admin")))

{

lIfNotAdmin.Text = Resources.Site.NotEnoughPrivileges;

return;

}

if (!Page.IsPostBack)

{

Panel3.Visible = true;

TreeNode root = new TreeNode(Resources.Site.Activities, "-5");

root.Expanded = true;

root.ShowCheckBox = true;

TrV_Activities.Nodes.Add(root);

PublicFunctions.AddNodesToActivityTree(root, false, null);

root = new TreeNode(Resources.Site.LotIndexes, "-5");

root.Expanded = true;

root.ShowCheckBox = true;

TrV_LotCategories.Nodes.Add(root);

PublicFunctions.AddNodesToCategoryTree(root, false, null);

Panel.Visible = false;

lTimeInt.Text = Resources.Site.TimeInterval + ":";

btnApplyTime.Text = Resources.Site.Apply;

btnSendNewsLetter.Text = Resources.Site.SendNewsletter;

L_LotCategories.Text = Resources.Site.Categories;

L_Activities.Text = Resources.Site.Activities;

lSubject.Text = Resources.Site.LetterSubject;

lBody.Text = Resources.Site.LetterBody;

lDate.Text = Resources.Site.Date;

lTime.Text = Resources.Site.Time;

btnSend.Text = Resources.Site.Send;

CompareValidatorTimeInt.ErrorMessage = Resources.Site.TimeIntInteger;

RequiredFieldValidatorTimeInt.ErrorMessage = Resources.Site.RequiredValue;

CompareValidatorTimeInt2.ErrorMessage = Resources.Site.TimeIntGreater0;

RequiredFieldValidatorSub.ErrorMessage = Resources.Site.RequiredValue;

RequiredFieldValidatorBody.ErrorMessage = Resources.Site.RequiredValue;

lActTreeValid.Text = Resources.Site.SelectActLotInd;

//lLotIndTreeValid.Text = "Select at least one category";

lActTreeValid.Visible = false;

//lLotIndTreeValid.Visible = false;

lDateValid.Visible = false;

lDateValid.Text = Resources.Site.DateTimeValid;

CompareValidatorDate.ValueToCompare = DateTime.Now.ToString("d");

CompareValidatorDate.ErrorMessage = Resources.Site.DateGreater;

CompareValidatorHours.ErrorMessage = Resources.Site.HoursInteger;

CompareValidatorMinutes.ErrorMessage = Resources.Site.MinutesInteger;

RangeValidatorHours.ErrorMessage = Resources.Site.Hours023;

RangeValidatorMinutes.ErrorMessage = Resources.Site.Minutes059;

lHours.Text = Resources.Site.h;

lMinutes.Text = Resources.Site.m;

lTimeApplied.Text = Resources.Site.TimeIntApplied;

lSent.Text = Resources.Site.LetterAdded;

}

}

/// <summary>

/// Get the data from the database and create the top-level

/// TreeView items

/// </summary>

private void PopulateTreeView(TreeView tv, string selectCom, int f)

{

DataTable treeViewData = GetTreeViewData(selectCom);

AddTopTreeViewNodes(treeViewData, tv, f);

}

/// <summary>

/// Use a DataAdapter and DataTable to grab the database data

/// </summary>

/// <returns></returns>

private DataTable GetTreeViewData(string selectCom)

{

// Get Discuss table

string selectCommand = selectCom;

string conString = WebConfigurationManager.ConnectionStrings["NewServer"].ConnectionString;

SqlDataAdapter dad = new SqlDataAdapter(selectCommand, conString);

DataTable dtblDiscuss = new DataTable();

dad.Fill(dtblDiscuss);

return dtblDiscuss;

}

/// <summary>

/// Filter the data to get only the rows that have a

/// null ParentID (these are the top-level TreeView items)

/// </summary>

private void AddTopTreeViewNodes(DataTable treeViewData, TreeView tv, int f)

{

TreeNode newNode = new TreeNode();

string Name = "";

DataView view = new DataView(treeViewData);

view.RowFilter = "ParentID IS NULL";

foreach (DataRowView row in view)

{

switch (CultureInfo.CurrentCulture.TwoLetterISOLanguageName)

{

case "en":

if (!String.IsNullOrEmpty(row["NameRU"].ToString()))

Name = row["NameRU"].ToString();

if (!String.IsNullOrEmpty(row["NameHE"].ToString()))

Name = row["NameHE"].ToString();

if (!String.IsNullOrEmpty(row["NameEN"].ToString()))

Name = row["NameEN"].ToString();

break;

case "ru":

if (!String.IsNullOrEmpty(row["NameEN"].ToString()))

Name = row["NameEN"].ToString();

if (!String.IsNullOrEmpty(row["NameHE"].ToString()))

Name = row["NameHE"].ToString();

if (!String.IsNullOrEmpty(row["NameRU"].ToString()))

Name = row["NameRU"].ToString();

break;

case "he":

if (!String.IsNullOrEmpty(row["NameRU"].ToString()))

Name = row["NameRU"].ToString();

if (!String.IsNullOrEmpty(row["NameEN"].ToString()))

Name = row["NameEN"].ToString();

if (!String.IsNullOrEmpty(row["NameHE"].ToString()))

Name = row["NameHE"].ToString();

break;

}

if (f == 0) newNode = new TreeNode(Name, row["ActivityID"].ToString());

else newNode = new TreeNode(Name, row["LotIndexID"].ToString());

newNode.Expanded = false;

tv.Nodes.Add(newNode);

AddChildTreeViewNodes(treeViewData, newNode, f);

}

}

/// <summary>

/// Recursively add child TreeView items by filtering by ParentID

/// </summary>

private void AddChildTreeViewNodes(DataTable treeViewData, TreeNode parentTreeViewNode, int f)

{

TreeNode newNode = new TreeNode();

string Name = "";

DataView view = new DataView(treeViewData);

view.RowFilter = "ParentID='" + parentTreeViewNode.Value + "'";

foreach (DataRowView row in view)

{

switch (CultureInfo.CurrentCulture.TwoLetterISOLanguageName)

{

case "en":

if (!String.IsNullOrEmpty(row["NameRU"].ToString()))

Name = row["NameRU"].ToString();

if (!String.IsNullOrEmpty(row["NameHE"].ToString()))

Name = row["NameHE"].ToString();

if (!String.IsNullOrEmpty(row["NameEN"].ToString()))

Name = row["NameEN"].ToString();

break;

case "ru":

if (!String.IsNullOrEmpty(row["NameEN"].ToString()))

Name = row["NameEN"].ToString();

if (!String.IsNullOrEmpty(row["NameHE"].ToString()))

Name = row["NameHE"].ToString();

if (!String.IsNullOrEmpty(row["NameRU"].ToString()))

Name = row["NameRU"].ToString();

break;

case "he":

if (!String.IsNullOrEmpty(row["NameRU"].ToString()))

Name = row["NameRU"].ToString();

if (!String.IsNullOrEmpty(row["NameEN"].ToString()))

Name = row["NameEN"].ToString();

if (!String.IsNullOrEmpty(row["NameHE"].ToString()))

Name = row["NameHE"].ToString();

break;

}

if (f == 0) newNode = new TreeNode(Name, row["ActivityID"].ToString());

else newNode = new TreeNode(Name, row["LotIndexID"].ToString());

newNode.Expanded = false;

parentTreeViewNode.ChildNodes.Add(newNode);

AddChildTreeViewNodes(treeViewData, newNode, f);

}

}

protected void btnApplyTime_Click(object sender, EventArgs e)

{

LotTypes.LotTypesDataContext DB = new LotTypes.LotTypesDataContext();

LotTypes.AppSetting appset = new LotTypes.AppSetting();

appset = DB.AppSettings.Single(a=>a.Name == "NewsLettersTimeInt");

appset.Value = tbTimeInt.Text;

DB.SubmitChanges();

lTimeApplied.Visible = true;

}

protected void btnSendNewsLetter_Click(object sender, EventArgs e)

{

Panel.Visible = true;

}

protected void btnSend_Click(object sender, EventArgs e)

{

double Hours = 0, Minutes = 0;

DateTime Date;

if ((tbHours.Text == "") && (tbMinutes.Text == "") && (tbDate.Text == "")) Date = DateTime.Now;

else

{

if (tbHours.Text == "") Hours = 0;

else Hours = Convert.ToDouble(tbHours.Text);

if (tbMinutes.Text == "") Minutes = 0;

else Minutes = Convert.ToDouble(tbMinutes.Text);

if (tbDate.Text == "") Date = DateTime.Now.Date;

else Date = Convert.ToDateTime(tbDate.Text);

}

if ((Date.Date == DateTime.Now.Date) && (Hours == 0) && (Minutes == 0))

{

Hours = DateTime.Now.Hour;

Minutes = DateTime.Now.Minute;

}

if ((TrV_LotCategories.CheckedNodes.Count == 0) && (TrV_Activities.CheckedNodes.Count == 0)) lActTreeValid.Visible = true;

else

{

//lLotIndTreeValid.Visible = false;

lActTreeValid.Visible = false;

}

if (Date.Date == DateTime.Now.Date)

{

if (Hours < DateTime.Now.Hour) lDateValid.Visible = true;

if ((Hours == DateTime.Now.Hour) && (Minutes < DateTime.Now.Minute)) lDateValid.Visible = true;

}

else lDateValid.Visible = false;

if (/*lLotIndTreeValid.Visible || */lActTreeValid.Visible || lDateValid.Visible) return;

LotTypes.LotTypesDataContext DB = new LotTypes.LotTypesDataContext();

LotTypes.NewsLetters2 nl2 = new LotTypes.NewsLetters2();

nl2.LetterID = Guid.NewGuid();

nl2.LetterSubject = tbSubject.Text;

nl2.LetterBody = tbBody.Text;

nl2.SendDateTime = Date.AddHours(Hours).AddMinutes(Minutes);

foreach (TreeNode tn in TrV_Activities.CheckedNodes)

{

LotTypes.NewsLetters_Activity nl_a = new LotTypes.NewsLetters_Activity();

LotTypes.Activity act = DB.Activities.Single(a => Convert.ToString(a.ActivityID) == tn.Value);

nl_a.RowID = Guid.NewGuid();

nl_a.ActivityID = new Guid(tn.Value);

nl2.NewsLetters_Activities.Add(nl_a);

act.NewsLetters_Activities.Add(nl_a);

}

foreach (TreeNode tn in TrV_LotCategories.CheckedNodes)

{

LotTypes.NewsLetters_LotIndex nl_li = new LotTypes.NewsLetters_LotIndex();

LotTypes.LotIndex lotind = DB.LotIndexes.Single(l => Convert.ToString(l.LotIndexID) == tn.Value);

nl_li.RowID = Guid.NewGuid();

nl_li.LotIndexID = new Guid(tn.Value);

nl2.NewsLetters_LotIndexes.Add(nl_li);

lotind.NewsLetters_LotIndexes.Add(nl_li);

}

DB.NewsLetters2s.InsertOnSubmit(nl2);

DB.SubmitChanges();

lSent.Visible = true;

}

protected void UpdatePanel1_Load(object sender, EventArgs e)

{

ScriptManager.RegisterStartupScript(this, GetType(), "UpdatePanel1_Load + Page", "restorePosition1();", true);

ScriptManager.RegisterStartupScript(this, GetType(), "UpdatePanel1_Load2 + Page", "restorePosition2();", true);

}

protected void TrV_LotCategories_TreeNodeExpanded(object sender, TreeNodeEventArgs e)

{

PublicFunctions.AddNodesToCategoryTree(e.Node, false, null);

}

protected void TrV_Activities_TreeNodeExpanded(object sender, TreeNodeEventArgs e)

{

PublicFunctions.AddNodesToActivityTree(e.Node, false, null);

}

}

Файл User.aspx

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.Profile;

using System.Web.UI;

using System.Web.UI.WebControls;

public partial class User : System.Web.UI.Page

{

protected override void OnLoadComplete(EventArgs e)

{

base.OnLoadComplete(e);

if (Profile.IsAnonymous) return;

string StrUserID = Request.Params["UserID"];

LotTypes.LotTypesDataContext DB = new LotTypes.LotTypesDataContext();

ProfileCommon NewProfile;//

//= (ProfileCommon)ProfileBase.Create(CreateUserWizard1.UserName);

if (!string.IsNullOrEmpty(StrUserID))

{

string UserName = "";

var Usrs = from us in DB.aspnet_Users

where us.UserId.ToString().Equals(StrUserID)

select us;

foreach (LotTypes.aspnet_User Usr in Usrs)

{

UserName = Usr.UserName;

}

NewProfile = (ProfileCommon)ProfileBase.Create(UserName);

Bn_Edit.Visible = false;

}

else

{

NewProfile = (ProfileCommon)ProfileBase.Create(Profile.UserName);

Bn_Edit.Visible = true;

}

if (NewProfile != null)

{

L_Adress.Text = String.IsNullOrEmpty(NewProfile.Adress) ? Resources.Site.Unspecified : NewProfile.Adress;

TextBox_Adress.Text = NewProfile.Adress;

L_City.Text = String.IsNullOrEmpty(NewProfile.City) ? Resources.Site.Unspecified : NewProfile.City;

TextBox_City.Text = NewProfile.City;

L_Fax.Text = String.IsNullOrEmpty(NewProfile.Fax) ? Resources.Site.Unspecified : NewProfile.Fax;

TextBox_Fax.Text = NewProfile.Fax;

L_FName.Text = String.IsNullOrEmpty(NewProfile.FNname) ? Resources.Site.Unspecified : NewProfile.FNname ;

TextBox_FName.Text = NewProfile.FNname;

L_LName.Text = String.IsNullOrEmpty(NewProfile.LName) ? Resources.Site.Unspecified : NewProfile.LName;

TextBox_LName.Text = NewProfile.LName;

L_Pasport.Text = String.IsNullOrEmpty(NewProfile.Pasport) ? Resources.Site.Unspecified : NewProfile.Pasport;

TextBox_Pasport.Text = NewProfile.Pasport;

L_Telephone.Text = String.IsNullOrEmpty(NewProfile.Telephone) ? Resources.Site.Unspecified : NewProfile.Telephone;

TextBox_Telephone.Text = NewProfile.Telephone;

}

Bn_Edit.Text = Resources.Site.Edit;

Bn_Apply.Text = Resources.Site.Apply;

}

protected void Page_Load(object sender, EventArgs e)

{

Master.Title = Resources.Site.PersonInfo;

if (Profile.IsAnonymous)

{

LblContent.Visible = true;

LblContent.Text = Resources.Site.PleaseLogIn;

MV_User.Visible = false;

}

else

{

LblContent.Visible =false;

MV_User.Visible = true;

MV_User.ActiveViewIndex = 0;

}

}

protected void On_Bn_Edit_Click(object sender, EventArgs e)

{

MV_User.ActiveViewIndex = 1;

}

// Save user info into profile

protected void SetToProfile(string name, string value)

{

try

{

ProfileCommon NewProfile = (ProfileCommon)ProfileBase.Create(Profile.UserName);

// Temporary set language

NewProfile.Language = "HE";

//////////////////////////

switch (name)

{

case "FNname":

NewProfile.FNname = value;

break;

case "LName":

NewProfile.LName = value;

break;

case "Telephone":

NewProfile.Telephone = value;

break;

case "Fax":

NewProfile.Fax = value;

break;

case "City":

NewProfile.City = value;

break;

case "Adress":

NewProfile.Adress = value;

break;

case "Pasport":

NewProfile.Pasport = value;

break;

}

NewProfile.Save();

}

catch (Exception Exp)

{

string error = Exp.Message;

}

}

protected void TextBox_FName_TextChanged(object sender, EventArgs e)

{

SetToProfile("FNname", TextBox_FName.Text);

}

protected void TextBox_LName_TextChanged(object sender, EventArgs e)

{

SetToProfile("LName", TextBox_LName.Text);

}

protected void TextBox_Telephone_TextChanged(object sender, EventArgs e)

{

SetToProfile("Telephone", TextBox_Telephone.Text);

}

protected void TextBox_Fax_TextChanged(object sender, EventArgs e)

{

SetToProfile("Fax", TextBox_Fax.Text);

}

protected void TextBox_City_TextChanged(object sender, EventArgs e)

{

SetToProfile("City", TextBox_City.Text);

}

protected void TextBox_Adress_TextChanged(object sender, EventArgs e)

{

SetToProfile("Adress", TextBox_Adress.Text);

}

protected void TextBox_Pasport_TextChanged(object sender, EventArgs e)

{

SetToProfile("Pasport", TextBox_Pasport.Text);

}

protected void Question_TextChanged(object sender, EventArgs e)

{

}

}