public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; DTcms.BLL.IntegralManage bllIntegralManage = new BLL.IntegralManage(); DTcms.BLL.BarCode bllBarCode = new BLL.BarCode(); DTcms.BLL.BarCodeCreateRecord bllBarCodeCreateRecord = new BLL.BarCodeCreateRecord(); DTcms.BLL.GoodCategory bllGoodCategory = new BLL.GoodCategory(); string type = context.Request.QueryString["type"]; switch (type) { case "select": //int pageIndex = int.Parse(context.Request.Form["page"]); //int pageSize = int.Parse(context.Request.Form["rows"]); List <Model.IntegralManage> listIntegralManage = bllIntegralManage.GetList(); List <Model.BarCode> listBarCode = bllBarCode.GetList(); List <Model.BarCodeCreateRecord> listBarCodeCreateRecord = bllBarCodeCreateRecord.GetList(); List <Model.GoodCategory> listGoodCategory = bllGoodCategory.GetList(); var query = listIntegralManage.Join(listBarCode, i => i.IntegralCode, b => b.IntegralCode, (i, b) => new { IntegralManageID = i.IntegralManageID, IntegralCode = i.IntegralCode, CreateTime = i.CreateTime, Remark = i.Remark, BarCodeCreateRecordID = b.BarCodeCreateRecordID }) .Join(listBarCodeCreateRecord, a => a.BarCodeCreateRecordID, c => c.BarCodeCreateRecordID, (a, c) => new { IntegralManageID = a.IntegralManageID, IntegralCode = a.IntegralCode, CreateTime = a.CreateTime, Remark = a.Remark, GoodCategoryID = c.GoodCategoryID }) .Join(listGoodCategory, d => d.GoodCategoryID, g => g.GoodCategoryID, (d, g) => new { IntegralManageID = d.IntegralManageID, IntegralCode = d.IntegralCode, CreateTime = d.CreateTime, Remark = d.Remark, IntegralRatio = g.IntegralRatio }); if (context.Request.QueryString["code"] != null) { query = query.Where(i => i.IntegralCode == context.Request.QueryString["code"]); } //query = query.Join(listBarCodeCreateRecord, i => i.BarCodeCreateRecordID, c => c.BarCodeCreateRecordID, (i, c) => new { IntegralManageID = i.IntegralManageID, IntegralCode = i.IntegralCode, CreateTime = i.CreateTime, Remark = i.Remark, GoodCategoryID = c.GoodCategoryID }); //query = query.Join(listBarCodeCreateRecord, i => i.BarCodeCreateRecordID, c => c.BarCodeCreateRecordID, (i, c) => new { aaa=i.BarCodeCreateRecordID}); string json = JsonConvert.SerializeObject(query); context.Response.Write(json); //context.Response.Write("{\"total\":" + "\"" + 50 + "\"" + ",\"rows\":" + json + "}"); break; } }
public void ExcelOut(string id) { Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application(); Microsoft.Office.Interop.Excel.Workbook wb = null; Microsoft.Office.Interop.Excel.Sheets sh = null; excel.Application.Workbooks.Add(true); excel.Cells[1, 1] = "箱码"; excel.Cells[1, 2] = "物流码"; excel.Cells[1, 3] = "积分码";; string content = " 箱码 物流码 积分码\r\n"; BLL.BarCode bllBarCode = new BLL.BarCode(); System.Data.DataTable dt = bllBarCode.GetBarCodeCreateDetailByBarCodeCreateRecordID(id); BLL.BarCodeCreateRecord bllBarCodeCreateRecord = new BLL.BarCodeCreateRecord(); int num = 2; string FileName; FileName = Guid.NewGuid().ToString(); object OsPath, FilePathxls, FilePathtxt; //表格文件的保存地址 OsPath = Server.MapPath("/DownLoad/"); //这里我定义了桌面的地址 FilePathxls = string.Format("{0}{1}", (string)OsPath, FileName + ".xls"); //为了自定义地址,加了一个地址拼接 FilePathtxt = string.Format("{0}{1}", (string)OsPath, FileName + ".txt"); //为了自定义地址,加了一个地址拼接 FileStream fs = File.Create(FilePathtxt.ToString()); foreach (DataRow dr in dt.Rows) { excel.Cells[num, 1] = dr["BoxCode"]; excel.Cells[num, 2] = dr["LogisticsCode"]; excel.Cells[num, 3] = dr["IntegralCode"]; content += dr["BoxCode"].ToString() + " " + dr["LogisticsCode"] + " " + dr["IntegralCode"] + "\r\n"; num++; } byte[] buffer = Encoding.UTF8.GetBytes(content); fs.Write(buffer, 0, buffer.Length); //bllBarCodeCreateRecord.Update(id, "//DownLoad//" + FileName); bllBarCodeCreateRecord.Update(id, FileName); excel.Visible = false; excel.DisplayAlerts = false; excel.AlertBeforeOverwriting = false; excel.ActiveWorkbook.SaveAs(FilePathxls); excel.Quit(); //Response.Write("/DownLoad/" + FileName + ".txt"); }
private void DoAdd() { Model.users model = new Model.users(); BLL.users bll = new BLL.users(); model.group_id = 1; model.status = 0; //检测用户名是否重复 //if (bll.Exists(txtUserName.Text.Trim())) //{ // return; //} model.user_name = tel.Text.Trim(); model.salt = Utils.GetCheckCode(6); //以随机生成的6位字符串做为密钥加密 model.password = DESEncrypt.Encrypt("123456", model.salt); model.reg_time = DateTime.Now; model.reg_ip = DTRequest.GetIP(); model.mobile = tel.Text.Trim(); List <string> list = new List <string>(); string aa = Request.Form["IntegralCode"]; var codes_list = Request.Form["IntegralCode"].Split(','); BLL.BarCode bllBar = new BLL.BarCode(); DataSet ds = null; ds = bllBar.QueryIntegralRatioSum(Request.Form["IntegralCode"]); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < codes_list.Length; i++) { if (!list.Contains(codes_list[i])) { list.Add(codes_list[i]); } } if (bll.Add(model, Convert.ToInt32(ds.Tables[0].Rows[0][0]), list)) { ClientScript.RegisterStartupScript(GetType(), "", "TipSuccess();", true); } else { ClientScript.RegisterStartupScript(GetType(), "", "TipFail();", true); } } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; DTcms.BLL.Promotion bll = new BLL.Promotion(); BLL.Client bllClient = new BLL.Client(); BLL.GoodCategory bllGoodCategory = new BLL.GoodCategory(); BLL.BarCode bllbarcode = new BLL.BarCode(); string type = context.Request.QueryString["type"]; switch (type) { case "select": int pageIndex = int.Parse(context.Request.Form["page"].ToString()); int pageSize = int.Parse(context.Request.Form["rows"].ToString()); try { int recordCount = 0; Model.manager adminmodel = context.Session[DTKeys.SESSION_ADMIN_INFO] as Model.manager; DataSet ds = bll.GetList(pageSize, pageIndex, "m.id=" + adminmodel.id, "PromotionID", out recordCount); DataTable dt = ds.Tables[0]; string result = ""; IsoDateTimeConverter timeFormat = new IsoDateTimeConverter(); timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; result = JsonConvert.SerializeObject(dt, new DataTableConverter(), timeFormat); context.Response.Write("{\"total\":" + "\"" + recordCount + "\"" + ",\"rows\":" + result + "}"); } catch (Exception) { } break; case "del": bll.Delete(context.Request.QueryString["ids"]); break; } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string type = context.Request.QueryString["type"]; Model.users model = null; BLL.users bll_users = new BLL.users(); switch (type) { case "select": break; case "exchange": BLL.users modelbll = new BLL.users(); BLL.BarCode bllBar = new BLL.BarCode(); DataSet ds = null; ds = bllBar.QueryIntegralCode(context.Request.QueryString["IntegralCode"]); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { if (Convert.ToInt32(ds.Tables[0].Rows[0]["state"]) < 4) { string uip = string.Empty; if (HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null) { uip = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString(); } else { uip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString(); } model = context.Session[DTKeys.SESSION_USER_INFO] as Model.users; if (bllBar.UserChange(Convert.ToInt32(ds.Tables[0].Rows[0]["IntegralRatio"]), model.user_name, context.Request.QueryString["IntegralCode"], uip)) { context.Response.Write("true"); } else { context.Response.Write("false"); } } else { context.Response.Write("false"); } } else { context.Response.Write("false"); } break; case "exchangeall": //string ip = string.Empty; //if (HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null) //{ // ip = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString(); //} //else //{ // ip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString(); //} model = new Model.users(); model.group_id = 1; model.status = 0; model.user_name = context.Request.QueryString["tel"]; model.salt = Utils.GetCheckCode(6); //以随机生成的6位字符串做为密钥加密 model.password = DESEncrypt.Encrypt("123456", model.salt); model.reg_time = DateTime.Now; model.reg_ip = DTRequest.GetIP(); model.telphone = context.Request.QueryString["tel"]; string codes = context.Request.QueryString["codes"]; List <string> list = new List <string>(); var codes_list = codes.Split(','); for (int i = 1; i < codes_list.Length; i++) { if (!list.Contains(codes_list[i])) { list.Add(codes_list[i]); } } if (bll_users.Add(model, 1, list)) { context.Response.Write("true"); } else { context.Response.Write("false"); } break; } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; BLL.users userBll = new BLL.users(); BLL.manager mBll = new BLL.manager(); Model.users user = null; string action = context.Request.QueryString["action"]; DataTable dt = null; BLL.BarCode bllBar = null; switch (action) { case "username": if (userBll.Exists(context.Request.QueryString["username"])) { context.Response.Write("false"); } else { context.Response.Write("true"); } break; case "adminusername": if (mBll.Exists(context.Request.QueryString["username"])) { context.Response.Write("false"); } else { context.Response.Write("true"); } break; case "tel": if (userBll.ExistsMobile(context.Request.Form["param"])) { context.Response.Write("{\"info\":\"该手机已存在!\",\"status\":\"n\"}"); } else { context.Response.Write("{\"info\":\"" + context.Request.Form["param"] + "为新用户,成功累计积分后系统自动注册为正式会员,默认密码为123456\",\"status\":\"y\"}"); } break; case "tel2": if (userBll.ExistsMobile(context.Request.QueryString["tel"])) { context.Response.Write("false"); } else { context.Response.Write("true"); } break; case "IntegralCode": bllBar = new BLL.BarCode(); DataSet ds = null; ds = bllBar.QueryIntegralCode(context.Request.Form["param"]); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0]["state"]) < 4) { context.Response.Write("{\"info\":\"验证通过!\",\"status\":\"y\"}"); } else { context.Response.Write("{\"info\":\"该积分码不存在或已兑换!\",\"status\":\"n\"}"); } break; case "UserIntegralCode": bllBar = new BLL.BarCode(); ds = bllBar.QueryIntegralCode(context.Request.QueryString["IntegralCode"]); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0]["state"]) < 4) { context.Response.Write("true"); } else { context.Response.Write("false"); } break; case "Username": BLL.users bll = new BLL.users(); //查询数据库 if (!bll.Exists(context.Request.QueryString["Username"])) { context.Response.Write("true"); } else { context.Response.Write("false"); } break; case "Exit": context.Session[DTKeys.SESSION_USER_INFO] = null; break; case "SearchLogisticsCode": bllBar = new BLL.BarCode(); dt = bllBar.GetBarCodeByLogisticsCode(context.Request.QueryString["LogisticsCode"]); if (dt != null) { IsoDateTimeConverter timeFormat2 = new IsoDateTimeConverter(); timeFormat2.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; context.Response.Write(JsonConvert.SerializeObject(dt, timeFormat2)); } else { context.Response.Write("false"); } break; case "SearchIntegralCode": bllBar = new BLL.BarCode(); dt = bllBar.GetBarCodeByIntegralCode(context.Request.QueryString["IntegralCode"]); if (dt != null) { IsoDateTimeConverter timeFormat2 = new IsoDateTimeConverter(); timeFormat2.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; context.Response.Write(JsonConvert.SerializeObject(dt, timeFormat2)); } else { context.Response.Write("false"); } break; case "State": context.Response.Write(Convert.ToInt32(context.Request.QueryString["State"]).ToEnumDescriptionString(typeof(EnumList.StateList))); break; case "OrderState": context.Response.Write(Convert.ToInt32(context.Request.QueryString["State"]).ToEnumDescriptionString(typeof(EnumList.OrderState))); break; //更换头像之后替换用户信息session case "Avatar": user = context.Session[DTKeys.SESSION_USER_INFO] as Model.users; user = userBll.GetModel(user.user_name); context.Session[DTKeys.SESSION_USER_INFO] = user; break; } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; List <Model.Promotion> list = new List <Model.Promotion>(); string type = context.Request.QueryString["type"]; BLL.Promotion bll = new BLL.Promotion(); BLL.BarCode bb = new BLL.BarCode(); switch (type) { case "one": if (context.Request.QueryString["code"] == null || context.Request.QueryString["code"] == "undefined" || context.Request.QueryString["code"] == "") { if (context.Cache["key"] != null) { list = (List <Model.Promotion>)context.Cache["key"]; IsoDateTimeConverter timeFormat = new IsoDateTimeConverter(); timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; context.Response.Write(JsonConvert.SerializeObject(list)); } } else { Model.manager adminmodel = context.Session[DTKeys.SESSION_ADMIN_INFO] as Model.manager; Model.Promotion model = new Model.Promotion(); //model.ClientID = 0; model.UniqueID = Guid.NewGuid(); model.LogisticsCode = context.Request.QueryString["code"]; model.Operator = adminmodel.id; model.State = 3; model.BrokerageRatio = 0; model.CreateTime = Convert.ToDateTime(DateTime.Now); model.Remark = string.Empty; if (context.Cache["key"] == null) { list.Add(model); context.Cache["key"] = list; } else { list = (List <Model.Promotion>)context.Cache["key"]; list.Add(model); } try { //if (bb.ExistsOut(context.Request.QueryString["code"])) //{ if (bll.Add(model, true)) { IsoDateTimeConverter timeFormat = new IsoDateTimeConverter(); timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; context.Response.Write(JsonConvert.SerializeObject(list, timeFormat)); } //} } catch (Exception) { } } break; case "two": Common.ComExcelHelper ch = new Common.ComExcelHelper(); DataTable dt = new DataTable(); dt = ch.ReadExcel2DataTable(context.Server.MapPath("/DownLoad/") + context.Request.QueryString["filename"], "nihao", "物流码"); dt.Rows.RemoveAt(0); dt.Columns.Add("UniqueID", typeof(Guid)); //dt.Columns.Add("ClientID", typeof(Int32)); dt.Columns.Add("Operator", typeof(Int32)); dt.Columns.Add("CreateTime", typeof(DateTime)); dt.Columns.Add("State", typeof(Int32)); for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i][1] = Guid.NewGuid(); dt.Rows[i][2] = 1; dt.Rows[i][3] = DateTime.Now; dt.Rows[i][4] = 3; if (dt.Rows[i][0] == null || dt.Rows[i][0].ToString() == "") { dt.Rows.RemoveAt(i); } } Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("UniqueID", "UniqueID"); //dic.Add("ClientID", "ClientID"); dic.Add("物流码", "LogisticsCode"); dic.Add("Operator", "Operator"); dic.Add("CreateTime", "CreateTime"); dic.Add("State", "State"); string json = ""; try { bll.Add(dt, "TempPromotion", dic); } catch (Exception) {} try { bll.Add(dt, "Promotion", dic); IsoDateTimeConverter timeFormat2 = new IsoDateTimeConverter(); int total = dt.Rows.Count; timeFormat2.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; dt = GetPagedTable(dt, Convert.ToInt32(context.Request.Form["page"]), Convert.ToInt32(context.Request.Form["rows"])); json = JsonConvert.SerializeObject(dt, new DataTableConverter(), timeFormat2); json = "{\"total\":" + "\"" + total + "\"" + ",\"rows\":" + json + "}"; } catch (Exception) { json = "{\"total\":" + "\"0\"" + ",\"rows\":[]}"; } finally { context.Response.Write(json); } break; case "Three": try { if (bb.ExistsOut(context.Request.QueryString["code"])) { context.Response.Write("true"); } else { context.Response.Write("false"); } } catch (Exception) { } break; } }