<$EndForeach$>";
//4 回应
WriteString(BLL.Template.ProcessTemplate(template, dt));
}
///
/// 用户登录
///
private static void LoginCheck()
{
string username = GF("username").Trim();
string pin = GF("password").Trim();
KeyValuePair node;
KeyValuePair node2;
OEnum.Mem.LogingInResult result = BLL.Mem.Login(username, pin, DateTime.Now, IP);
switch (result)
{
case NSW.OEnum.Mem.LogingInResult.Disabled:
node = new KeyValuePair("state", "0");
node2 = new KeyValuePair("msg", "This username has not yet been activated, please activate your account before login");
WriteXml(node, node2);
break;
case NSW.OEnum.Mem.LogingInResult.Falied:
node = new KeyValuePair("state", "0");
node2 = new KeyValuePair("msg", "Login failed, please try again later");
WriteXml(node, node2);
break;
case NSW.OEnum.Mem.LogingInResult.IncorrectPin:
node = new KeyValuePair("state", "0");
node2 = new KeyValuePair("msg", "Incorrect username or password, please check and try again later");
WriteXml(node, node2);
break;
case NSW.OEnum.Mem.LogingInResult.NonVerified:
node = new KeyValuePair("state", "0");
node2 = new KeyValuePair("msg", "An account needs to be activated for new records, please check your E-mail and activate your account");
WriteXml(node, node2);
break;
case NSW.OEnum.Mem.LogingInResult.NonVerifiedEmail:
node = new KeyValuePair("state", "0");
node2 = new KeyValuePair("msg", "This mailbox has been used by a registered user");
WriteXml(node, node2);
break;
case NSW.OEnum.Mem.LogingInResult.Successful:
node = new KeyValuePair("state", "1");
node2 = new KeyValuePair("msg", "Successful login, welcome");
WriteXml(node, node2);
break;
case NSW.OEnum.Mem.LogingInResult.UserNotExists:
node = new KeyValuePair("state", "0");
node2 = new KeyValuePair("msg", "This user does not exist, please double check");
WriteXml(node, node2);
break;
default:
break;
}
}
///
/// 初始化通用头部热门关键词信息
///
private static void InitCommonHeaderKeywords()
{
string s = GF("s").Trim();
//关键词
WriteString(_Tools.InitCommonHeaderKeywords(s));
}
///
///填加一个友情连接
///
private static void AddApply()
{
string Type = GF("Type");
string Url = GF("Url");
string Name = GF("Name");
string PhotoPath = GF("PhotoPath");
string Content = GF("Content");
string UserName = GF("UserName");
string Phone = GF("Phone");
string Email = GF("Email");
string QQ = GF("QQ");
tbApply Obj = new tbApply();
Obj.Type = int.Parse(Type);
Obj.Url = Url;
Obj.Name = Name;
Obj.PhotoPath = PhotoPath;
Obj.Content = Content;
Obj.UserName = UserName;
Obj.Phone = Phone;
Obj.Email = Email;
Obj.QQ = QQ;
Obj.State = 0;
Obj.InputTime = DateTime.Now;
int rowsAffected = DbSession.Default.Save(Obj);
if (rowsAffected > 0)
{
KeyValuePair node1 = new KeyValuePair("state", "1");
KeyValuePair node2 = new KeyValuePair("msg", "Application for links is successfully submitted, please wait for the reply from administrator!");
WriteXml(node1, node2);
}
else
{
KeyValuePair node1 = new KeyValuePair("state", "0");
KeyValuePair node2 = new KeyValuePair("msg", "Failed to submit the application for links, please try again later!");
WriteXml(node1, node2);
}
}
///
/// 处理产品的对比车(产品是不同类别)
///
private static void AddCompare()
{
string ids = GF("ids");
string flag = GF("flag");
string cookie = OCookie.Mem.ProductCompare;
string [] arrcookie = cookie.Split(',');
string newcookie = string.Empty;
if (cookie == "")
{
newcookie = ids;
}
else
{
//添加
if (flag == "true")
{
bool res = false;
foreach (string obj in arrcookie)
{
if (obj == ids)
{
res = true;
}
else
{
if (newcookie == "")
{
newcookie += obj;
}
else
{
newcookie += "," + obj;
}
}
}
if (res ==true)
{
newcookie = newcookie+","+ids;
}
else
{
newcookie = cookie + "," + ids;
}
}
else//删除
{
foreach (string obj in arrcookie)
{
if (obj != ids)
{
if(newcookie=="")
{
newcookie += obj;
}
else
{
newcookie +="," +obj;
}
}
}
}
}
OCookie.Mem.ProductCompare = newcookie;
KeyValuePair node3 = new KeyValuePair("state", "1");
KeyValuePair node4 = new KeyValuePair("newcookie", newcookie);
WriteXml(node3, node4);
}
///
/// 移除产品的对比车中的某个产品(产品是不同类别)
///
private static void DelOneCompare()
{
string ids = GF("ids");
string cookie = OCookie.Mem.ProductCompare;
string[] arrcookie = cookie.Split(',');
string newcookie = string.Empty;
if (cookie == "")
{
newcookie = "";
}
else
{
foreach (string obj in arrcookie)
{
if (obj != ids)
{
if (newcookie == "")
{
newcookie += obj;
}
else
{
newcookie += "," + obj;
}
}
}
}
OCookie.Mem.ProductCompare = newcookie;
if (newcookie=="")
{
KeyValuePair node1 = new KeyValuePair("state", "0");
KeyValuePair node2 = new KeyValuePair("newcookie", "Product record does not exist");
WriteXml(node1, node2);
}
else
{
KeyValuePair node1 = new KeyValuePair("state", "1");
KeyValuePair node2 = new KeyValuePair("newcookie", "Successfully removed");
WriteXml(node1, node2);
}
}
///
/// 移除产品的对比车中的所有产品(产品是不同类别)
///
private static void DelAllCompare()
{
OCookie.Mem.ProductCompare = null;
KeyValuePair node1 = new KeyValuePair("state", "1");
KeyValuePair node2 = new KeyValuePair("newcookie", "Successfully removed");
WriteXml(node1, node2);
}
///
/// 删除代理商的定单
///
private static void DelAgentOrder()
{
if (!BLL.Mem.CheckPassport())
{
KeyValuePair node = new KeyValuePair("state", "0");
KeyValuePair node2 = new KeyValuePair("msg", "You are not currently Sign in or you are not currently a member, thus order management function is not available. Please log in or register Please log in or register.");
WriteXml(node, node2);
return;
}
//1 获取参数
string ids = GF("ids");
if (ids.IndexOf("on") != -1 && ids.Split(',').Length == 1)
{
KeyValuePair node = new KeyValuePair("state", "0");
KeyValuePair node2 = new KeyValuePair("msg", "No order record, no need to delete.");
WriteXml(node, node2);
return;
}
else
{
ids = ids.Replace("on,","");
}
//2 检查参数
if (!ComUtls.CheckIDsFormat(ids))
{
KeyValuePair node = new KeyValuePair("state", "0");
KeyValuePair node2 = new KeyValuePair("msg", "Parameter error: ids");
WriteXml(node, node2);
return;
}
//3 查询数据库
WhereClip nwhere = (tbAgentOrder._.ID.In(ids.Split(','))
&& tbAgentOrder._.UserID == OSession.Mem.ID);
int rowsAffected = DbSession.Default.Delete(nwhere);
//4 回应
if (rowsAffected > 0)
{
KeyValuePair node = new KeyValuePair("state", "1");
KeyValuePair node2 = new KeyValuePair("msg", string.Format("The franchisee order is successfully deleted, and {0} records are deleted in total。", rowsAffected));
WriteXml(node, node2);
return;
}
else
{
KeyValuePair node = new KeyValuePair("state", "0");
KeyValuePair node2 = new KeyValuePair("msg", "Failed to delete the franchisee order. Please try again later.");
WriteXml(node, node2);
return;
}
}
///
/// 加盟在线下单
///
private static void AgentOrder()
{
//1> 获取参数
KeyValuePair node1;
KeyValuePair node2;
string name = GF("s_name");
string title = GF("s_title");
string tel = GF("s_tel");
string email = GF("s_email");
string content = GF("s_content");
string address = GF("s_address");
string enddate = GF("s_enddate");
string s_IDList = GF("s_IDList");
bool isLogin = BLL.Mem.CheckPassport();
tbUser objUser = OSession.Mem.User;
if (objUser.UserGroupID != 5)
{
node1 = new KeyValuePair("state", "0");
node2 = new KeyValuePair("msg", "Sorry, you are not currently an agent, thus you do not have the permission to place an order here.");
WriteXml(node1, node2);
return;
}
tbAgentOrder ObjUserOrder = new tbAgentOrder();
ObjUserOrder.UserID = objUser.ID;
ObjUserOrder.ProductList = s_IDList;
ObjUserOrder.Title = title;
ObjUserOrder.Name = name;
ObjUserOrder.Phone = tel;
ObjUserOrder.Address = address;
ObjUserOrder.Email = email;
ObjUserOrder.FeedBack = "";
ObjUserOrder.EndDate = Convert.ToDateTime(enddate);
ObjUserOrder.InputTime = DateTime.Now;
ObjUserOrder.Content = content;
ObjUserOrder.PostState = 0;
ObjUserOrder.ReceiveState = 0;
//保存到数据库
int rowsAffected = DbSession.Default.Save(ObjUserOrder);
//显示提示
if (rowsAffected > 0)
{
node1 = new KeyValuePair("state", "1");
node2 = new KeyValuePair("msg", "The order is successfully submitted, and we will contact you as soon as possible, thank you!");
WriteXml(node1, node2);
}
else
{
node1 = new KeyValuePair("state", "0");
node2 = new KeyValuePair("msg", "Failed to submit the order. Please try again later!");
WriteXml(node1, node2);
// WriteString("0");
}
}
///
/// 发送获取资讯列表通知
///
private static void SendGetProductsByColumn()
{
//1\定义变量
string ColumnID, SearchText;
string ResultString = "";
//2\获取产品数据列表
ColumnID = GF("columnid");
SearchText = GF("searchtext");
WhereClip nwhere;
//3\绑定数据
if (SearchText.Length > 0)
{
nwhere = (VW_Product._.sid.Like(ColumnID + "%") && VW_Product._.Title.Like("%" + SearchText + "%")
&& VW_Product._.Enable == true);
}
else
{
nwhere = (VW_Product._.sid.Like(ColumnID + "%")
&& VW_Product._.Enable == true);
}
Field[] nfields = new Field[] {
VW_Product._.ID,
VW_Product._.Title
};
DataTable dt = DbSession.Default.From().Select(nfields).Where(nwhere).ToDataTable(1000);
foreach (DataRow dr in dt.Rows)
{
ResultString += dr[VW_Product._.ID.Name].ToString() + "$$" + dr[VW_Product._.Title.Name].ToString().Replace("$$", "").Replace("||", "");
ResultString += "||";
}
//4\结束
WriteString(ResultString);
}
private static void SubmitOrder()
{
KeyValuePair node1;
KeyValuePair node2;
//1 获取参数
int oid = ComUtls.ParseInt(GF("oid"), -1);
string contact = HttpUtility.HtmlEncode(GF("contact").Trim());
string compName = HttpUtility.HtmlEncode(GF("compName").Trim());
string tel = HttpUtility.HtmlEncode(GF("tel").Trim());
string mobile = HttpUtility.HtmlEncode(GF("mobile").Trim());
string email = HttpUtility.HtmlEncode(GF("email").Trim());
string addr = HttpUtility.HtmlEncode(GF("addr").Trim());
string country = HttpUtility.HtmlEncode(GF("country").Trim());
string content = HttpUtility.HtmlEncode(GF("content").Trim());
string vali = HttpUtility.HtmlEncode(GF("vali").Trim());
//2 检查参数
//获取订单号
string orderSnPrefix = "P";
string orderSn = BLL.Order.GetOrderSn(orderSnPrefix);
//开始进行订单创建事务
DbTran dbTran = DbSession.Default.BeginTran();
try
{
//4 填充实体
DateTime nowTime = DateTime.Now;
tbOrder orderObj = new tbOrder();
orderObj.ActConsumePoint = 0;
orderObj.ActDeliveryFee = 0;
orderObj.ActDeliveryMethod = 0;
orderObj.ActGoodsAccount = 0;
orderObj.ActOrderAccount = 0;
orderObj.ActPayMethod = 0;
orderObj.ActReturnPoint = 0;
orderObj.ConsumePoint = 0;
orderObj.DeliveryFee = 0;
orderObj.DeliveryState = (int)OEnum.DeliveryState.正在审核1;
orderObj.Enable = true;
orderObj.EndingColumn = -1;
orderObj.EndingRemark = string.Empty;
orderObj.GoodsAccount = 0;
orderObj.InputTime = nowTime;
orderObj.isLock = false;
orderObj.OrderAccount = 0;
orderObj.OrderNo = orderSn;
orderObj.OrderState = (int)OEnum.OrderState.待审核1;
orderObj.PayMethod = 0;
orderObj.PayState = (int)OEnum.PaymentState.未付款2;
orderObj.ReturnPoint = 0;
orderObj.UserName = OSession.Mem.Username;
//收货人信息
orderObj.UserRemark = "Company name:" + compName + ";\r\ndescription on purchase intention:" + content;
orderObj.ZipCode = string.Empty;
orderObj.Province = country;
orderObj.Phone = tel;
orderObj.ChnName = contact;
orderObj.Address = addr;
orderObj.City = string.Empty;
orderObj.Email = email;
orderObj.InvoiceTitle = string.Empty;
orderObj.MPhone = mobile;
orderObj.NeedInvoice = false;
//其它
orderObj.AdminRemark = string.Empty;
orderObj.DomainName = string.Empty;
orderObj.EKN = string.Empty;
orderObj.ESN = string.Empty;
orderObj.EUN = string.Empty;
orderObj.ActTaxAccount = 0;
orderObj.TaxAccount = 0;
//优惠券
orderObj.CardNo = string.Empty;
int rowsAfffected = dbTran.Save(orderObj);
if (rowsAfffected < 1)
{
//ShowMsgBox("", NSW.OEnum.Common.MessageType.Information);
//return;
throw new Exception("Failed to save the order. Please try again later.");
}
//保存订单产品信息
VW_Product objProd = DbSession.Default.Get(VW_Product._.ID == oid);
if (objProd == null)
{
throw new Exception("The product does not exist.");
}
//获取相关参数
int pid = objProd.ID;
string title = objProd.Title;
decimal price = 0;
decimal closingPrice = 0;
//填充实体
tbOrderDetail orderDetailObj = new tbOrderDetail();
orderDetailObj.Enable = true;
orderDetailObj.InputTime = nowTime;
orderDetailObj.Num = 0;
orderDetailObj.OrderID = orderSn;
orderDetailObj.PriceSum = 0;
orderDetailObj.ProductID = pid;
orderDetailObj.ProductName = title;
orderDetailObj.ProductPrice = price;
orderDetailObj.ShortDesc = string.Empty;
orderDetailObj.UserPrice = closingPrice;
int rowsAf = dbTran.Save(orderDetailObj);
if (rowsAf < 1)
{
throw new Exception("Failed to save details about ordered product. Please try again later.");
}
//提交事务
dbTran.Commit();
//bool rtnVal = ComUtls.SendMail(email, "Hi:" + contact + "," + OConfig.GlobalConfig.SiteName + "site under an intention to order.", OConfig.GlobalConfig.SiteName + " site orders you specific information as follows:
UserName:" + contact + "
Company name:" + compName + "
Telephone number:" + tel + "
Mobile phone number:" + mobile + "
Email:" + email + "
Country:" + country + "
Address:" + addr + "
nquire intention description:" + content + "
Product title:" + title + "
Product URL:" + OConfig.Common.SiteDomain + objProd.PageURL, true, 5);
// rtnVal = ComUtls.SendMail(OConfig.GlobalConfig.ReceivingOrderBuiltMailAddress, "Hello: Dear administrator." + contact + "," + OConfig.GlobalConfig.SiteName + " site under an intention to order.", contact + "," + OConfig.GlobalConfig.SiteName + " site orders you specific information as follows:
UserName:" + contact + "
Company name:" + compName + "
Telephone number:" + tel + "
Mobile phone number:" + mobile + "
Email:" + email + "
Country:" + country + "
Address:" + addr + "
nquire intention description:" + content + "
Product title:" + title + "
Product URL:" + OConfig.Common.SiteDomain + objProd.PageURL, true, 5);
node1 = new KeyValuePair("state", "1");
node2 = new KeyValuePair("msg", "Your purchase intention is successfully submitted, our related staff will contact you as soon as possible.");
}
catch (Exception ex)
{
dbTran.Rollback();
node1 = new KeyValuePair("state", "0");
node2 = new KeyValuePair("msg", ex.Message);
}
finally
{
dbTran.Close();
}
WriteXml(node1, node2);
}
///
/// 产品详细页面套餐中的产品价格
///
private static void GetTaoCanPrice()
{
string IDList = GF("IDList");
string[] arr = IDList.Split(',');
decimal OldPrice = 0;
decimal NowPrice = 0;
for (int i = 0; i < arr.Length;i++ )
{
VW_Product Product = DbSession.Default.Get(VW_Product._.ID == int.Parse(arr[i]));
//不存在冗于字段则返回
if (Product.CustomerFields == "")
{
if (BLL.Mem.CheckPassport())
{
OldPrice += Product.UserPrice;
NowPrice += Product.UserPrice;
}
else
{
OldPrice += Product.Price;
NowPrice += Product.Price;
}
}
else
{
BLL.KV kvv = new NSW.BLL.KV("$$", "||", Product.CustomerFields);
//10、套装销售产品
//1>设置好是否显示套装勾选框
Boolean EnableCombos = ComUtls.ParseBool(kvv.GetValue("EnablePackage"), false);
if (EnableCombos == true)
{
OldPrice += Product.Price;
NowPrice += ComUtls.ParseDecimal(kvv.GetValue("PackagePrice"), 0);
}
else
{
if (BLL.Mem.CheckPassport())
{
OldPrice += Product.UserPrice;
NowPrice += Product.UserPrice;
}
else
{
OldPrice += Product.Price;
NowPrice += Product.Price;
}
}
}
}
KeyValuePair node1 = new KeyValuePair("OldPrice", OldPrice.ToString());
KeyValuePair node2 = new KeyValuePair("NowPrice", NowPrice.ToString());
WriteXml(node1, node2);
}
///
/// 产品愿望夹(产品列表页面的预览功能)
///
private static void PostProductWishs()
{
string attr = GF("attr");
int num = ComUtls.ParseInt(GF("num"), 1);
int oid = int.Parse(GF("oid"));
if(!BLL.Mem.CheckPassport())
{
WriteState(0, "Failed to add. You are not currently Sign in. Please log in and try again.");
}
VW_Product Product = DbSession.Default.Get(VW_Product._.ID == oid);
if (Product==null)
{
WriteState(0, "Invalid request, the data does not exist.");
}
tbMyWish Obj = new tbMyWish();
Obj.Attr = attr;
Obj.Num = num;
Obj.PhotoPath = Product.PhotoPath;
Obj.ProductID = oid;
Obj.Title = Product.Title;
Obj.Url = Product.PageURL;
Obj.UserID = OSession.Mem.ID;
Obj.Enable = false;
Obj.InputTime = DateTime.Now;
int row = DbSession.Default.Save(Obj);
if (row > 0)
{
WriteState(1, "Successfully added to wishlist, please check");
}
else
{
WriteState(0, "Failed to add to wishlist. Please try again later");
}
}
///
/// 产品愿望夹(产品列表页面的预览功能)
///
private static void ShowMyWish()
{
StringBuilder sbRtnVal = new StringBuilder();
int ID = int.Parse(GF("oid"));
VW_Product Obj = DbSession.Default.Get(VW_Product._.ID == ID);
if(Obj==null)
{
WriteState(0, "The product does not exist!");
}
sbRtnVal.Append("
");
WriteString(sbRtnVal.ToString());
}
///
/// 产品预定(产品列表页面的预览功能)
///
private static void PostProductTips()
{
string email = GF("email");
string content = GF("content");
int state = int.Parse(GF("state"));
int oid = int.Parse(GF("oid"));
tbProductBooking Obj = new tbProductBooking();
Obj.ProductID = oid;
Obj.ShortDesc = content;
Obj.State = state;
Obj.UserEmail = email;
Obj.OrderID = 50;
Obj.InputTime = DateTime.Now;
int row = DbSession.Default.Save(Obj);
if (row > 0)
{
WriteState(1, "The product is successfully reserved, and we will send you latest information about the product in time.");
}
else
{
WriteState(0, "Failed to reserve the product. Please try again later.");
}
}
///
/// 获得产品的简单介绍(产品列表页面的预览功能)
///
private static void ShowProductInfo()
{
StringBuilder sbRtnVal = new StringBuilder();
int ID = int.Parse(GF("oid"));
int Index = int.Parse(GF("index"));
VW_Product Obj = DbSession.Default.Get(VW_Product._.ID == ID);
if (Obj == null)
{
return;
}
int n=0;
n = Index % 4;
if(n==0)
{
n = 4;
}
if (n > 2)
{
sbRtnVal.Append("