private void getthridcustomergrid(HttpContext context) { string page = context.Request.Form["page"]; string rows = context.Request.Form["rows"]; long startRowIndex = (long.Parse(page) - 1) * long.Parse(rows); int pageSize = int.Parse(rows); string Keywords = context.Request["Keywords"]; DateTime StartTime = WebUtil.GetDateValue(context, "StartTime"); DateTime EndTime = WebUtil.GetDateValue(context, "EndTime"); int SendStatus = WebUtil.GetIntValue(context, "SendStatus"); string ProjectName = context.Request["ProjectName"]; bool canexport = WebUtil.GetBoolValue(context, "canexport"); DataGrid dg = ThirdCustomer.GetThirdCustomerListByKeywords(Keywords, StartTime, EndTime, SendStatus, ProjectName, "order by LastSendTime desc,ID desc", startRowIndex, pageSize, canexport: canexport); if (canexport) { bool isTemplate = WebUtil.GetIntValue(context, "istemplate") == 1; string downloadurl = string.Empty; string error = string.Empty; bool status = APPCode.ExportHelper.DownLoadThirdCustomerData(dg, isTemplate, out downloadurl, out error); WebUtil.WriteJson(context, new { status = status, downloadurl = downloadurl, error = error }); } else { WebUtil.WriteJson(context, dg); } }
private void savethirdcustomer(HttpContext context) { int ID = WebUtil.GetIntValue(context, "ID"); ThirdCustomer data = null; if (ID > 0) { data = ThirdCustomer.GetThirdCustomer(ID); } if (data == null) { data = new ThirdCustomer(); data.AddTime = DateTime.Now; data.AddUserID = WebUtil.GetUser(context).UserID; } data.ProjectName = context.Request["ProjectName"]; data.RoomName = context.Request["RoomName"]; data.CustomerName = context.Request["CustomerName"]; data.PhoneNumber = context.Request["PhoneNumber"]; data.SignDate = WebUtil.GetDateValue(context, "SignDate"); var existData = ThirdCustomer.GetThirdCustomerByPhone(data.PhoneNumber); if (existData.ID != data.ID) { WebUtil.WriteJson(context, new { status = false, error = "手机号码重复,请检查" }); return; } data.Save(); WebUtil.WriteJson(context, new { status = true }); }
private void doremovethridcustomer(HttpContext context) { int ID = WebUtil.GetIntValue(context, "ID"); ThirdCustomer.DeleteThirdCustomer(ID); WebUtil.WriteJson(context, new { status = true }); }
private void getthirdprojectlist(HttpContext context) { var list = ThirdCustomer.GetThirdProjectList(); WebUtil.WriteJson(context, new { list = list }); }
private void importthirdcustomer(HttpContext context) { HttpFileCollection uploadFiles = context.Request.Files; if (uploadFiles.Count == 0) { context.Response.Write("请选择一个文件"); return; } if (string.IsNullOrEmpty(uploadFiles[0].FileName)) { context.Response.Write("请选择一个文件"); return; } HttpPostedFile postedFile = uploadFiles[0]; string filepath = HttpContext.Current.Server.MapPath("~/upload/ImportRoomSource/" + DateTime.Now.ToString("yyyyMMdd")); if (!System.IO.Directory.Exists(filepath)) { System.IO.Directory.CreateDirectory(filepath); } string filename = DateTime.Now.ToLocalTime().ToString("yyyyMMddHHmmss") + "_" + postedFile.FileName; string fullpath = Path.Combine(filepath, filename); postedFile.SaveAs(fullpath); DataTable table = ExcelExportHelper.NPOIReadExcel(fullpath); string msg = string.Empty; int count = 0; var user = WebUtil.GetUser(context); using (SqlHelper helper = new SqlHelper()) { try { helper.BeginTransaction(); #region 导入处理 for (int i = 0; i < table.Rows.Count; i++) { count = i; ThirdCustomer data = null; string PhoneNumber = table.Rows[i]["手机号码"].ToString(); if (string.IsNullOrEmpty(PhoneNumber)) { msg += "<p>第" + (i + 2) + "行上传失败。原因:手机号码为空</p>"; continue; } object Value = table.Rows[i]["ID"]; int ID = 0; if (Value != null) { int.TryParse(Value.ToString(), out ID); } if (ID > 0) { data = Foresight.DataAccess.ThirdCustomer.GetThirdCustomer(ID, helper); } if (data == null) { data = ThirdCustomer.GetThirdCustomerByPhone(PhoneNumber, helper); } if (data == null) { data = new ThirdCustomer(); data.AddTime = DateTime.Now; data.AddUserID = user.UserID; } data.PhoneNumber = PhoneNumber; data.CustomerName = table.Rows[i]["项目名称"].ToString(); data.ProjectName = table.Rows[i]["姓名"].ToString(); data.RoomName = table.Rows[i]["资源编号"].ToString(); data.SignDate = WebUtil.GetDateTimeByStr(table.Rows[i]["签约日期"].ToString()); data.Save(helper); } #endregion helper.Commit(); msg += "<p>导入完成</p>"; } catch (Exception ex) { LogHelper.WriteError("ImportSourceHandler", "visit: importroomsource", ex); msg = "导入失败,第" + (count + 2) + "行数据有问题,导入取消"; helper.Rollback(); } } context.Response.Write(msg); }