public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpRequest request = context.Request; if (request["Action"] == "CRM_Reports_year") { BLL.CRM_Customer ccc = new BLL.CRM_Customer(); string items = PageValidate.InputText(context.Request["stype_val"], 255); int year = int.Parse(context.Request["syear_val"]); DataSet ds = ccc.Reports_year(items, year, ""); string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } if (request["Action"] == "Follow_Reports_year") { BLL.CRM_Follow follow = new BLL.CRM_Follow(); string items = "Follow_Type"; int year = int.Parse(context.Request["syear_val"]); DataSet ds = follow.Reports_year(items, year, ""); string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpRequest request = context.Request; if (request["Action"] == "CRM_Reports_year") { BLL.CRM_Customer ccc = new BLL.CRM_Customer(); string items = PageValidate.InputText(context.Request["stype_val"], 255); int year = int.Parse(context.Request["syear_val"]); DataSet ds = ccc.Reports_year(items, year, ""); string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } if (request["Action"] == "Follow_Reports_year") { BLL.CRM_Follow follow = new BLL.CRM_Follow(); string items = "Follow_Type"; int year = int.Parse(context.Request["syear_val"]); DataSet ds = follow.Reports_year(items, year, ""); string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } //if (request["Action"] == "Funnel") //{ // string whereStr = " 1=1 "; // int year = int.Parse(context.Request["syear_val"]); // if (year > 0) // whereStr += string.Format(" and datediff(year,b.Create_date,'{0}-01-01')=0", year); // string items = PageValidate.InputText(context.Request["stype_val"], 255); // if (!string.IsNullOrEmpty(items) && items != "null") // whereStr += string.Format(" and a.id in({0})", items.Replace(';',',')); // //context.Response.Write(whereStr); // BLL.CRM_Customer ccc = new BLL.CRM_Customer(); // DataSet ds = ccc.Funnel(whereStr); // string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); // context.Response.Write(dt); //} }
/// <summary> /// 获得前几行数据 /// </summary> public DataSet GetListCRM(int Top, string strWhere, string filedOrder, string strEmp_id, string strFactoryId) { DataSet ds = dal.GetListCRM(Top, strWhere, filedOrder, strEmp_id, strFactoryId); BLL.CRM_Customer customer = new BLL.CRM_Customer(); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { //全部客户(权限内) string strTemp = customer.GetCount("dataAllCus", " Factory_Id='" + strFactoryId + "'" + " and privatecustomer='私客'" + " and isDelete=0 " + DataAuth(strEmp_id.ToString(), strFactoryId)).ToString();// //本月未联系(权限内) string sqlMonth = " lastfollow<DATE_ADD(curdate(),interval -day(curdate())+1 day)" + DataAuth(strEmp_id.ToString(), strFactoryId) + " and Factory_Id='" + strFactoryId + "' and privatecustomer='私客' and isDelete=0"; string strTemp1 = customer.GetCount("dataAllCus", sqlMonth).ToString();// //当天联系(权限内) string sqlDay = " date_format(lastfollow,'%Y-%m-%d')=curdate()" + DataAuth(strEmp_id.ToString(), strFactoryId) + " and Factory_Id='" + strFactoryId + "' and privatecustomer='私客' and isDelete=0"; string strTemp2 = customer.GetCount("dataAllCus", sqlDay).ToString(); foreach (DataRow item in ds.Tables[0].Rows) { switch (item["Menu_name"].ToString()) { case "全部客户(权限内)": item["count1"] = strTemp; break; case "本月未联系(权限内)": item["count1"] = strTemp1; break; case "当天联系(权限内)": item["count1"] = strTemp2; break; default: break; } } } return(ds); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpRequest request = context.Request; Model.hr_employee model = new Model.hr_employee(); var cookie = context.Request.Cookies[FormsAuthentication.FormsCookieName]; var ticket = FormsAuthentication.Decrypt(cookie.Value); string CoockiesID = ticket.UserData; BLL.hr_employee emp = new BLL.hr_employee(); int emp_id = int.Parse(CoockiesID); DataSet dsemp = emp.GetList("id=" + emp_id); string empname = dsemp.Tables[0].Rows[0]["name"].ToString(); string uid = dsemp.Tables[0].Rows[0]["uid"].ToString(); if (request["Action"] == "grid") { int PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]); int PageSize = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]); string sortname = request["sortname"]; string sortorder = request["sortorder"]; if (string.IsNullOrEmpty(sortname)) { sortname = " ID"; } if (string.IsNullOrEmpty(sortorder)) { sortorder = " desc"; } string sorttext = " " + sortname + " " + sortorder; string Total; string serchtxt = "uid!='admin'"; string did = request["did"]; if (!string.IsNullOrEmpty(did) && did != null && did != "null") { serchtxt += " and d_id=" + int.Parse(did); } string authtxt = request["auth"]; if (authtxt == "1") { Data.GetDataAuth dataauth = new Data.GetDataAuth(); string txt = dataauth.GetDataAuthByid("1", "Sys_add", emp_id.ToString()); string[] arr = txt.Split(':'); switch (arr[0]) { case "my": serchtxt += " and ID=" + emp_id; break; } } if (!string.IsNullOrEmpty(request["stext"])) { if (request["stext"] != "输入姓名搜索") { serchtxt += " and name like N'%" + PageValidate.InputText(request["stext"], 255) + "%'"; } } //权限 DataSet ds = emp.GetList(PageSize, PageIndex, serchtxt, sorttext, out Total); string dt = Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], Total); context.Response.Write(dt); } //表格json if (request["Action"] == "getRole") { int r_empid = int.Parse(request["empid"]); DataSet ds = emp.GetRole(r_empid); string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } //validate if (request["Action"] == "Exist") { string user_id = request["T_uid"]; string T_emp_id = request["emp_id"]; if (string.IsNullOrEmpty(T_emp_id) || T_emp_id == "null") { T_emp_id = "0"; } DataSet ds1 = emp.GetList(" uid='" + PageValidate.InputText(user_id, 250) + "' and ID!=" + int.Parse(T_emp_id)); context.Response.Write(ds1.Tables[0].Rows.Count > 0 ? "false" : "true"); } //Form JSON if (request["Action"] == "form") { string eid = PageValidate.InputText(request["id"], 50); if (eid == "epu") { eid = emp_id.ToString(); } DataSet ds = emp.GetList("id=" + int.Parse(eid)); string dt = Common.DataToJson.DataToJSON(ds); context.Response.Write(dt); } //save if (request["Action"] == "save") { model.uid = PageValidate.InputText(request["T_uid"], 255); model.email = PageValidate.InputText(request["T_email"], 255); model.name = PageValidate.InputText(request["T_name"], 255); model.birthday = PageValidate.InputText(request["T_birthday"], 255); model.sex = PageValidate.InputText(request["T_sex"], 255); model.idcard = PageValidate.InputText(request["T_idcard"], 255); model.tel = PageValidate.InputText(request["T_tel"], 255); model.status = PageValidate.InputText(request["T_status"], 255); model.EntryDate = PageValidate.InputText(request["T_entryDate"], 255); model.address = PageValidate.InputText(request["T_Adress"], 255); model.schools = PageValidate.InputText(request["T_school"], 255); model.education = PageValidate.InputText(request["T_edu"], 255); model.professional = PageValidate.InputText(request["T_professional"], 255); model.remarks = PageValidate.InputText(request["T_remarks"], 255); model.title = PageValidate.InputText(request["headurl"], 255); model.canlogin = int.Parse(request["canlogin"]); int empid; string id = PageValidate.InputText(request["id"], 50); if (!string.IsNullOrEmpty(id) && id != "null") { DataSet ds = emp.GetList(" ID=" + int.Parse(id)); DataRow dr = ds.Tables[0].Rows[0]; model.ID = int.Parse(id); empid = model.ID; emp.Update(model); C_Sys_log log = new C_Sys_log(); int UserID = emp_id; string UserName = empname; string IPStreet = request.UserHostAddress; string EventTitle = model.name; string EventType = "员工修改"; int EventID = model.ID; if (dr["email"].ToString() != request["T_email"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "邮箱", dr["email"].ToString(), request["T_email"]); } if (dr["name"].ToString() != request["T_name"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工姓名", dr["name"].ToString(), request["T_name"]); } if (dr["birthday"].ToString() != request["T_birthday"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工生日", dr["birthday"].ToString(), request["T_birthday"]); } if (dr["sex"].ToString() != request["T_sex"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工性别", dr["sex"].ToString(), request["T_sex"]); } if (dr["status"].ToString() != request["T_status"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "状态", dr["status"].ToString(), request["T_status"]); } if (dr["idcard"].ToString() != request["T_idcard"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "身份证", dr["idcard"].ToString(), request["T_idcard"]); } if (dr["tel"].ToString() != request["T_tel"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "手机", dr["tel"].ToString(), request["T_tel"]); } if (dr["EntryDate"].ToString() != request["T_entryDate"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "入职日期", dr["EntryDate"].ToString(), request["T_entryDate"]); } if (dr["address"].ToString() != request["T_Adress"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "地址", dr["address"].ToString(), request["T_Adress"]); } if (dr["schools"].ToString() != request["T_school"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "毕业学校", dr["schools"].ToString(), request["T_school"]); } if (dr["education"].ToString() != request["T_edu"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "学历", dr["education"].ToString(), request["T_edu"]); } if (dr["professional"].ToString() != request["T_professional"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "专业", dr["professional"].ToString(), request["T_professional"]); } if (dr["remarks"].ToString() != request["T_remarks"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "备注", dr["remarks"].ToString(), request["T_remarks"]); } if (dr["canlogin"].ToString() != request["canlogin"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "能否登录", dr["canlogin"].ToString(), request["canlogin"]); } context.Response.Write(id + "|" + model.name); } else { model.isDelete = 0; model.pwd = FormsAuthentication.HashPasswordForStoringInConfigFile("123456", "MD5"); empid = emp.Add(model); context.Response.Write("{success:success}"); } //post string json = request["PostData"].ToLower(); JavaScriptSerializer js = new JavaScriptSerializer(); PostData[] postdata; postdata = js.Deserialize <PostData[]>(json); BLL.hr_post hp = new BLL.hr_post(); Model.hr_post modelpost = new Model.hr_post(); modelpost.emp_id = empid; model.ID = empid; modelpost.emp_name = PageValidate.InputText(request["T_name"], 255); for (int i = 0; i < postdata.Length; i++) { modelpost.post_id = postdata[i].Post_id; modelpost.default_post = postdata[i].Default_post; if (postdata[i].Default_post == 1) { model.d_id = postdata[i].dep_id; model.dname = postdata[i].Depname; model.zhiwuid = postdata[i].Position_id; model.zhiwu = postdata[i].Position_name; model.postid = postdata[i].Post_id; model.post = postdata[i].Post_name; //context.Response.Write(postdata[i].Depname + "@"); //更新默认岗位 emp.UpdatePost(model); // 更新客户,订单,合同,收款,开票 人员 emp.UpdateCOCRI(model); //清除员工 hp.UpdatePostEmpbyEid(empid); } //设置员工 hp.UpdatePostEmp(modelpost); //context.Response.Write("{success:success}"); } } if (request["Action"] == "PersonalUpdate") { model.email = PageValidate.InputText(request["T_email"], 255); model.name = PageValidate.InputText(request["T_name"], 255); model.birthday = PageValidate.InputText(request["T_birthday"], 255); model.sex = PageValidate.InputText(request["T_sex"], 255); model.idcard = PageValidate.InputText(request["T_idcard"], 255); model.tel = PageValidate.InputText(request["T_tel"], 255); model.address = PageValidate.InputText(request["T_Adress"], 255); model.schools = PageValidate.InputText(request["T_school"], 255); model.education = PageValidate.InputText(request["T_edu"], 255); model.professional = PageValidate.InputText(request["T_professional"], 255); model.remarks = PageValidate.InputText(request["T_remarks"], 255); model.title = PageValidate.InputText(request["headurl"], 255); DataRow dr = dsemp.Tables[0].Rows[0]; model.ID = emp_id; bool isup = emp.PersonalUpdate(model); if (isup) { context.Response.Write("true"); } else { context.Response.Write("false"); } C_Sys_log log = new C_Sys_log(); int UserID = emp_id; string UserName = empname; string IPStreet = request.UserHostAddress; string EventTitle = model.name; string EventType = "个人信息修改"; int EventID = emp_id; if (dr["email"].ToString() != request["T_email"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "邮箱", dr["email"].ToString(), request["T_email"]); } if (dr["name"].ToString() != request["T_name"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工姓名", dr["name"].ToString(), request["T_name"]); } if (dr["birthday"].ToString() != request["T_birthday"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工生日", dr["birthday"].ToString(), request["T_birthday"]); } if (dr["sex"].ToString() != request["T_sex"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工性别", dr["sex"].ToString(), request["T_sex"]); } if (dr["idcard"].ToString() != request["T_idcard"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "身份证", dr["idcard"].ToString(), request["T_idcard"]); } if (dr["tel"].ToString() != request["T_tel"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "手机", dr["tel"].ToString(), request["T_tel"]); } if (dr["address"].ToString() != request["T_Adress"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "地址", dr["address"].ToString(), request["T_Adress"]); } if (dr["schools"].ToString() != request["T_school"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "毕业学校", dr["schools"].ToString(), request["T_school"]); } if (dr["education"].ToString() != request["T_edu"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "学历", dr["education"].ToString(), request["T_edu"]); } if (dr["professional"].ToString() != request["T_professional"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "专业", dr["professional"].ToString(), request["T_professional"]); } } //combo if (request["Action"] == "combo") { string serchtxt = " 1=1 "; string did = request["did"]; if (!string.IsNullOrEmpty(did) && did != null && did != "null") { serchtxt += " and d_id=" + int.Parse(did); } string authtxt = request["auth"]; if (authtxt == "1") { Data.GetDataAuth dataauth = new Data.GetDataAuth(); string txt = dataauth.GetDataAuthByid("1", "Sys_add", emp_id.ToString()); string[] arr = txt.Split(':'); switch (arr[0]) { case "my": serchtxt += " and ID=" + emp_id; break; } } DataSet ds = emp.GetList(serchtxt); StringBuilder str = new StringBuilder(); str.Append("["); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { str.Append("{id:" + ds.Tables[0].Rows[i]["id"].ToString() + ",text:'" + ds.Tables[0].Rows[i]["name"] + "'},"); } str.Replace(",", "", str.Length - 1, 1); str.Append("]"); context.Response.Write(str); } //init if (request["Action"] == "init") { DataSet ds = emp.GetList("and ID=" + emp_id); StringBuilder str = new StringBuilder(); if (ds.Tables[0].Rows.Count > 0) { str.Append(ds.Tables[0].Rows[0]["ID"].ToString() + "|" + ds.Tables[0].Rows[0]["d_id"]); } context.Response.Write(str); } //changepwd if (request["Action"] == "changepwd") { DataSet ds = emp.GetPWD(emp_id); string oldpwd = FormsAuthentication.HashPasswordForStoringInConfigFile(request["T_oldpwd"], "MD5"); string newpwd = FormsAuthentication.HashPasswordForStoringInConfigFile(request["T_newpwd"], "MD5"); if (ds.Tables[0].Rows[0]["pwd"].ToString() == oldpwd) { model.pwd = newpwd; model.ID = (emp_id); emp.changepwd(model); context.Response.Write("true"); } else { context.Response.Write("false"); } } //allchangepwd if (request["Action"] == "allchangepwd") { string empid = request["empid"]; string newpwd = FormsAuthentication.HashPasswordForStoringInConfigFile(request["T_newpwd"], "MD5"); model.pwd = newpwd; model.ID = int.Parse(empid); emp.changepwd(model); } //del if (request["Action"] == "del") { BLL.hr_post hp = new BLL.hr_post(); string empid = PageValidate.InputText(request["id"], 50); string EventType = "员工删除"; DataSet ds = emp.GetList(" id=" + int.Parse(empid)); BLL.CRM_Customer customer = new BLL.CRM_Customer(); int cc = customer.GetList("Employee_id=" + int.Parse(empid)).Tables[0].Rows.Count; if (cc > 0) { context.Response.Write("false:customer"); } else { bool isdel = false; isdel = emp.Delete(int.Parse(request["id"])); //update post hp.UpdatePostEmpbyEid(int.Parse(empid)); if (isdel) { int UserID = emp_id; string UserName = empname; string IPStreet = request.UserHostAddress; int EventID = int.Parse(empid); string EventTitle = ds.Tables[0].Rows[0]["name"].ToString(); string Original_txt = null; string Current_txt = null; C_Sys_log log = new C_Sys_log(); log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt); context.Response.Write("true"); } else { context.Response.Write("false"); } } } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpRequest request = context.Request; BLL.hr_employee emp = new BLL.hr_employee(); Model.hr_employee model = new Model.hr_employee(); int emp_id = int.Parse(request.Cookies["UserID"].Value.ToString()); DataSet dsemp = emp.GetList("id=" + emp_id); string empname = dsemp.Tables[0].Rows[0]["name"].ToString(); string uid = dsemp.Tables[0].Rows[0]["uid"].ToString(); if (request["Action"] == "grid") { int PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]); int PageSize = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]); string sortname = request["sortname"]; string sortorder = request["sortorder"]; if (string.IsNullOrEmpty(sortname)) sortname = " ID"; if (string.IsNullOrEmpty(sortorder)) sortorder = " desc"; string sorttext = " " + sortname + " " + sortorder; string Total; string serchtxt = "uid!='admin'"; string serchtype = request["isdel"]; if (serchtype == "1") { serchtxt += " and isDelete=1"; } else { serchtxt += " and isDelete=0 "; } if (!string.IsNullOrEmpty(request["stext"])) { if (request["stext"] != "输入姓名搜索") serchtxt += " and name like N'%" + PageValidate.InputText(request["stext"], 255) + "%'"; } //权限 DataSet ds = emp.GetList(PageSize, PageIndex, serchtxt, sorttext, out Total); string dt = Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], Total); context.Response.Write(dt); } //表格json if (request["Action"] == "getRole") { int r_empid = int.Parse(request["empid"]); DataSet ds = emp.GetRole(r_empid); string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } //validate if (request["Action"] == "Exist") { string user_id = request["T_uid"]; string T_emp_id = request["emp_id"]; if (string.IsNullOrEmpty(T_emp_id) || T_emp_id == "null") T_emp_id = "0"; DataSet ds1 = emp.GetList(" uid='" + PageValidate.InputText(user_id, 250) + "' and ID!=" + int.Parse(T_emp_id)); context.Response.Write(ds1.Tables[0].Rows.Count > 0 ? "false" : "true"); } //Form JSON if (request["Action"] == "form") { string eid = request["id"]; if (!string.IsNullOrEmpty(eid)) { DataSet ds = emp.GetList("id=" + (PageValidate.IsNumber(eid) ? eid : "-1")); string dt = Common.DataToJson.DataToJSON(ds); context.Response.Write(dt); } } //save if (request["Action"] == "save") { model.uid = PageValidate.InputText(request["T_uid"], 255); model.email = PageValidate.InputText(request["T_email"], 255); model.name = PageValidate.InputText(request["T_name"], 255); model.birthday = PageValidate.InputText(request["T_birthday"], 255); model.sex = PageValidate.InputText(request["T_sex"], 255); model.idcard = PageValidate.InputText(request["T_idcard"], 255); model.tel = PageValidate.InputText(request["T_tel"], 255); model.status = PageValidate.InputText(request["T_status"], 255); model.EntryDate = PageValidate.InputText(request["T_entryDate"], 255); model.address = PageValidate.InputText(request["T_Adress"], 255); model.schools = PageValidate.InputText(request["T_school"], 255); model.education = PageValidate.InputText(request["T_edu"], 255); model.professional = PageValidate.InputText(request["T_professional"], 255); model.remarks = PageValidate.InputText(request["T_remarks"], 255); model.title = PageValidate.InputText(request["headurl"], 255); model.canlogin = int.Parse(request["canlogin"]); int empid; string id = request["id"]; if (!string.IsNullOrEmpty(id) && id != "null") { DataSet ds = emp.GetList(" ID=" + int.Parse(id)); DataRow dr = ds.Tables[0].Rows[0]; model.ID = int.Parse(id); empid = model.ID; emp.Update(model); C_Sys_log log = new C_Sys_log(); int UserID = emp_id; string UserName = empname; string IPStreet = request.UserHostAddress; string EventTitle = model.name; string EventType = "员工修改"; int EventID = model.ID; if (dr["email"].ToString() != request["T_email"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "邮箱", dr["email"].ToString(), request["T_email"]); } if (dr["name"].ToString() != request["T_name"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工姓名", dr["name"].ToString(), request["T_name"]); } if (dr["birthday"].ToString() != request["T_birthday"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工生日", dr["birthday"].ToString(), request["T_birthday"]); } if (dr["sex"].ToString() != request["T_sex"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工性别", dr["sex"].ToString(), request["T_sex"]); } if (dr["status"].ToString() != request["T_status"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "状态", dr["status"].ToString(), request["T_status"]); } if (dr["idcard"].ToString() != request["T_idcard"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "身份证", dr["idcard"].ToString(), request["T_idcard"]); } if (dr["tel"].ToString() != request["T_tel"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "手机", dr["tel"].ToString(), request["T_tel"]); } if (dr["EntryDate"].ToString() != request["T_entryDate"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "入职日期", dr["EntryDate"].ToString(), request["T_entryDate"]); } if (dr["address"].ToString() != request["T_Adress"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "地址", dr["address"].ToString(), request["T_Adress"]); } if (dr["schools"].ToString() != request["T_school"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "毕业学校", dr["schools"].ToString(), request["T_school"]); } if (dr["education"].ToString() != request["T_edu"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "学历", dr["education"].ToString(), request["T_edu"]); } if (dr["professional"].ToString() != request["T_professional"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "专业", dr["professional"].ToString(), request["T_professional"]); } if (dr["remarks"].ToString() != request["T_remarks"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "备注", dr["remarks"].ToString(), request["T_remarks"]); } if (dr["canlogin"].ToString() != request["canlogin"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "能否登录", dr["canlogin"].ToString(), request["canlogin"]); } context.Response.Write(id + "|" + model.name); } else { model.isDelete = 0; model.pwd = FormsAuthentication.HashPasswordForStoringInConfigFile("123456", "MD5"); empid = emp.Add(model); context.Response.Write("{success:success}"); } //post string json = request["PostData"].ToLower(); JavaScriptSerializer js = new JavaScriptSerializer(); PostData[] postdata; postdata = js.Deserialize<PostData[]>(json); BLL.hr_post hp = new BLL.hr_post(); Model.hr_post modelpost = new Model.hr_post(); modelpost.emp_id = empid; model.ID = empid; modelpost.emp_name = PageValidate.InputText(request["T_name"], 255); for (int i = 0; i < postdata.Length; i++) { modelpost.post_id = postdata[i].Post_id; modelpost.default_post = postdata[i].Default_post; if (postdata[i].Default_post == 1) { model.d_id = postdata[i].dep_id; model.dname = postdata[i].Depname; model.zhiwuid = postdata[i].Position_id; model.zhiwu = postdata[i].Position_name; model.postid = postdata[i].Post_id; model.post = postdata[i].Post_name; //context.Response.Write(postdata[i].Depname + "@"); //更新默认岗位 emp.UpdatePost(model); //清除员工 hp.UpdatePostEmpbyEid(empid); } //设置员工 hp.UpdatePostEmp(modelpost); //context.Response.Write("{success:success}"); } } if (request["Action"] == "PersonalUpdate") { model.email = PageValidate.InputText(request["T_email"], 255); model.name = PageValidate.InputText(request["T_name"], 255); model.birthday = PageValidate.InputText(request["T_birthday"], 255); model.sex = PageValidate.InputText(request["T_sex"], 255); model.idcard = PageValidate.InputText(request["T_idcard"], 255); model.tel = PageValidate.InputText(request["T_tel"], 255); model.address = PageValidate.InputText(request["T_Adress"], 255); model.schools = PageValidate.InputText(request["T_school"], 255); model.education = PageValidate.InputText(request["T_edu"], 255); model.professional = PageValidate.InputText(request["T_professional"], 255); model.remarks = PageValidate.InputText(request["T_remarks"], 255); model.title = PageValidate.InputText(request["headurl"], 255); int empid; string id = request["id"]; if (!string.IsNullOrEmpty(id) && id != "null") { DataSet ds = emp.GetList(" ID=" + int.Parse(id)); DataRow dr = ds.Tables[0].Rows[0]; model.ID = int.Parse(id); empid = model.ID; emp.PersonalUpdate(model); C_Sys_log log = new C_Sys_log(); int UserID = emp_id; string UserName = empname; string IPStreet = request.UserHostAddress; string EventTitle = model.name; string EventType = "个人信息修改"; int EventID = model.ID; if (dr["email"].ToString() != request["T_email"]) log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "邮箱", dr["email"].ToString(), request["T_email"]); if (dr["name"].ToString() != request["T_name"]) log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工姓名", dr["name"].ToString(), request["T_name"]); if (dr["birthday"].ToString() != request["T_birthday"]) log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工生日", dr["birthday"].ToString(), request["T_birthday"]); if (dr["sex"].ToString() != request["T_sex"]) log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工性别", dr["sex"].ToString(), request["T_sex"]); if (dr["idcard"].ToString() != request["T_idcard"]) log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "身份证", dr["idcard"].ToString(), request["T_idcard"]); if (dr["tel"].ToString() != request["T_tel"]) log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "手机", dr["tel"].ToString(), request["T_tel"]); if (dr["address"].ToString() != request["T_Adress"]) log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "地址", dr["address"].ToString(), request["T_Adress"]); if (dr["schools"].ToString() != request["T_school"]) log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "毕业学校", dr["schools"].ToString(), request["T_school"]); if (dr["education"].ToString() != request["T_edu"]) log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "学历", dr["education"].ToString(), request["T_edu"]); if (dr["professional"].ToString() != request["T_professional"]) log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "专业", dr["professional"].ToString(), request["T_professional"]); context.Response.Write("true"); } else { context.Response.Write("false"); } } //combo if (request["Action"] == "combo") { string serchtxt = " isDelete=0 "; string did = request["did"]; if (!string.IsNullOrEmpty(did) && did != null && did != "null") serchtxt += " and d_id=" + int.Parse(did); string authtxt = request["auth"]; if (authtxt == "1") { Data.GetDataAuth dataauth = new Data.GetDataAuth(); string txt = dataauth.GetDataAuthByid("1", "Sys_add", emp_id.ToString()); string[] arr = txt.Split(':'); switch (arr[0]) { case "my": serchtxt += " and ID=" + emp_id; break; } } DataSet ds = emp.GetList(serchtxt); StringBuilder str = new StringBuilder(); str.Append("["); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { str.Append("{id:" + ds.Tables[0].Rows[i]["id"].ToString() + ",text:'" + ds.Tables[0].Rows[i]["name"] + "'},"); } str.Replace(",", "", str.Length - 1, 1); str.Append("]"); context.Response.Write(str); } //init if (request["Action"] == "init") { DataSet ds = emp.GetList(" isDelete=0 and ID=" + emp_id); StringBuilder str = new StringBuilder(); if (ds.Tables[0].Rows.Count > 0) { str.Append(ds.Tables[0].Rows[0]["ID"].ToString() + "|" + ds.Tables[0].Rows[0]["d_id"]); } context.Response.Write(str); } //changepwd if (request["Action"] == "changepwd") { DataSet ds = emp.GetPWD(emp_id); string oldpwd = FormsAuthentication.HashPasswordForStoringInConfigFile(request["T_oldpwd"], "MD5"); string newpwd = FormsAuthentication.HashPasswordForStoringInConfigFile(request["T_newpwd"], "MD5"); if (ds.Tables[0].Rows[0]["pwd"].ToString() == oldpwd) { model.pwd = newpwd; model.ID = int.Parse(request.Cookies["UserID"].Value); emp.changepwd(model); context.Response.Write("true"); } else { context.Response.Write("false"); } } //allchangepwd if (request["Action"] == "allchangepwd") { string empid = request["empid"]; string newpwd = FormsAuthentication.HashPasswordForStoringInConfigFile(request["T_newpwd"], "MD5"); model.pwd = newpwd; model.ID = int.Parse(empid); emp.changepwd(model); } //del if (request["Action"] == "AdvanceDelete") { BLL.hr_post hp = new BLL.hr_post(); string empid = request["id"]; string EventType = "员工预删除"; DataSet ds = emp.GetList(" id=" + int.Parse(empid)); BLL.CRM_Customer customer = new BLL.CRM_Customer(); int cc = customer.GetList("Employee_id=" + int.Parse(empid)).Tables[0].Rows.Count; if (cc > 0) { context.Response.Write("false:customer"); } else { bool isdel = false; isdel = emp.AdvanceDelete(int.Parse(request["id"]), 1, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); //update post hp.UpdatePostEmpbyEid(int.Parse(empid)); if (isdel) { int UserID = emp_id; string UserName = empname; string IPStreet = request.UserHostAddress; int EventID = int.Parse(empid); string EventTitle = ds.Tables[0].Rows[0]["name"].ToString(); string Original_txt = null; string Current_txt = null; C_Sys_log log = new C_Sys_log(); log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt); context.Response.Write("true"); } else { context.Response.Write("false"); } } } if (request["Action"] == "regain") { string idlist = PageValidate.InputText(request["idlist"], 100000); string[] arr = idlist.Split(','); DataSet ds = emp.GetList("ID in (" + idlist.Trim() + ")"); for (int i = 0; i < arr.Length; i++) { emp.AdvanceDelete(int.Parse(arr[i]), 0, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); } if (true) { //日志 string EventType = "恢复删除员工"; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int UserID = emp_id; string UserName = empname; int EventID = idlist[i]; string IPStreet = request.UserHostAddress; string EventTitle = ds.Tables[0].Rows[i]["name"].ToString(); string Original_txt = null; string Current_txt = null; C_Sys_log log = new C_Sys_log(); log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt); } context.Response.Write("true"); } else { context.Response.Write("false"); } } if (request["Action"] == "del") { bool canDel = false; if (dsemp.Tables[0].Rows.Count > 0) { if (dsemp.Tables[0].Rows[0]["uid"].ToString() == "admin") { canDel = true; } else { Data.GetAuthorityByUid getauth = new Data.GetAuthorityByUid(); string delauth = getauth.GetBtnAuthority(request.Cookies["UserID"].Value, "84"); if (delauth == "false") canDel = false; else canDel = true; } } if (canDel) { string idlist = PageValidate.InputText(request["idlist"], 100000); string[] arr = idlist.Split(','); string EventType = "彻底删除员工"; DataSet ds = emp.GetList("id in (" + idlist.Trim() + ")"); for (int i = 0; i < arr.Length; i++) { emp.Delete(int.Parse(arr[i])); } if (true) { //日志 for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int UserID = emp_id; string UserName = empname; string IPStreet = request.UserHostAddress; int EventID = idlist[i]; string EventTitle = ds.Tables[0].Rows[0]["name"].ToString(); string Original_txt = null; string Current_txt = null; C_Sys_log log = new C_Sys_log(); log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt); } context.Response.Write("true"); } } else { context.Response.Write("auth"); } } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpRequest request = context.Request; BLL.Param_City pc = new BLL.Param_City(); Model.Param_City model = new Model.Param_City(); if (request["Action"] == "treegrid") { DataSet ds = pc.GetAllList(); string dt = "{Rows:[" + GetTasksString(0, ds.Tables[0]) + "]}"; context.Response.Write(dt); } if (request["Action"] == "tree") { DataSet ds = pc.GetAllList(); StringBuilder str = new StringBuilder(); str.Append("["); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { str.Append("{id:" + ds.Tables[0].Rows[i]["id"].ToString() + ",pid:" + ds.Tables[0].Rows[i]["parentid"].ToString() + ",text:'" + ds.Tables[0].Rows[i]["City"] + "'},"); } str.Replace(",", "", str.Length - 1, 1); str.Append("]"); context.Response.Write(str); } //save if (request["Action"] == "save") { model.City = Common.PageValidate.InputText(request["T_City"], 255); string pid = request["T_Parent_val"]; if (string.IsNullOrEmpty(pid)) { pid = "0"; } model.parentid = int.Parse(pid); string id = PageValidate.InputText(request["id"], 50); if (!string.IsNullOrEmpty(id) && id != "null") { model.id = int.Parse(id); pc.Update(model); } else { pc.Add(model); } } //Form JSON if (request["Action"] == "form") { DataSet ds = pc.GetList("id=" + int.Parse(request["id"])); string dt = Common.DataToJson.DataToJSON(ds); context.Response.Write(dt); } //del if (request["Action"] == "del") { string c_id = PageValidate.InputText(request["id"], 50); DataSet ds = pc.GetList(" parentid=" + int.Parse(c_id)); BLL.CRM_Customer cus = new BLL.CRM_Customer(); DataSet ds1 = cus.GetList(string.Format("Provinces_id={0} or City_id={0}", int.Parse(c_id))); if (ds.Tables[0].Rows.Count > 0) { context.Response.Write("false:parent"); } else if (ds1.Tables[0].Rows.Count > 0) { context.Response.Write("false:customer"); } else { bool isdel = pc.Delete(int.Parse(c_id)); if (isdel) { context.Response.Write("true"); } else { context.Response.Write("false"); } } } if (request["Action"] == "combo") { DataSet ds = pc.GetList("parentid=0"); StringBuilder str = new StringBuilder(); str.Append("["); str.Append("{id:0,text:'无'},"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { str.Append("{id:" + ds.Tables[0].Rows[i]["id"].ToString() + ",text:'" + ds.Tables[0].Rows[i]["City"] + "'},"); } str.Replace(",", "", str.Length - 1, 1); str.Append("]"); context.Response.Write(str); } if (request["Action"] == "combo1") { DataSet ds = pc.GetList("parentid=0"); StringBuilder str = new StringBuilder(); str.Append("["); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { str.Append("{id:" + ds.Tables[0].Rows[i]["id"].ToString() + ",text:'" + ds.Tables[0].Rows[i]["City"] + "'},"); } str.Replace(",", "", str.Length - 1, 1); str.Append("]"); context.Response.Write(str); } if (request["Action"] == "combo2") { DataSet ds = pc.GetList("parentid=" + int.Parse(request["pid"])); StringBuilder str = new StringBuilder(); str.Append("["); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { str.Append("{id:" + ds.Tables[0].Rows[i]["id"].ToString() + ",text:'" + ds.Tables[0].Rows[i]["City"] + "'},"); } str.Replace(",", "", str.Length - 1, 1); str.Append("]"); context.Response.Write(str); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpRequest request = context.Request; BLL.CRM_Customer customer = new BLL.CRM_Customer(); Model.CRM_Customer model = new Model.CRM_Customer(); BLL.hr_employee emp = new BLL.hr_employee(); int emp_id = int.Parse(request.Cookies["UserID"].Value); DataSet dsemp = emp.GetList("id=" + emp_id); string empname = dsemp.Tables[0].Rows[0]["name"].ToString(); string uid = dsemp.Tables[0].Rows[0]["uid"].ToString(); //save if (request["Action"] == "save") { model.Customer = PageValidate.InputText(request["T_company"], 255); model.address = PageValidate.InputText(request["T_address"], 255); model.fax = PageValidate.InputText(request["T_fax"], 255); model.site = PageValidate.InputText(request["T_Website"], 255); model.tel = PageValidate.InputText(request["T_company_tel"], 255); model.industry = PageValidate.InputText(request["T_industry"], 255); string provincesid = request["T_Provinces_val"]; if (string.IsNullOrEmpty(provincesid)) { provincesid = "0"; } model.Provinces_id = int.Parse(provincesid); model.Provinces = PageValidate.InputText(request["T_Provinces"], 255); string cityid = request["T_City_val"]; if (string.IsNullOrEmpty(cityid)) { cityid = "0"; } model.City_id = int.Parse(cityid); model.City = PageValidate.InputText(request["T_City"], 255); string ctypeid = request["T_customertype_val"]; if (string.IsNullOrEmpty(ctypeid)) { ctypeid = "0"; } model.CustomerType_id = int.Parse(ctypeid); model.CustomerType = PageValidate.InputText(request["T_customertype"], 255); string clevelid = request["T_customerlevel_val"]; if (string.IsNullOrEmpty(clevelid)) { clevelid = "0"; } model.CustomerLevel_id = int.Parse(clevelid); model.CustomerLevel = PageValidate.InputText(request["T_customerlevel"], 255); string csourceid = request["T_CustomerSource_val"]; if (string.IsNullOrEmpty(csourceid)) { csourceid = "0"; } model.CustomerSource_id = int.Parse(csourceid); model.CustomerSource = PageValidate.InputText(request["T_CustomerSource"], 255); model.DesCripe = PageValidate.InputText(request["T_descript"], 4000); model.Remarks = PageValidate.InputText(request["T_remarks"], 4000); model.privatecustomer = PageValidate.InputText(request["T_private"], 255); string depid = request["T_department_val"]; if (string.IsNullOrEmpty(depid)) { depid = "0"; } model.Department_id = int.Parse(depid); model.Department = PageValidate.InputText(request["T_department"], 255); string empid = request["T_employee_val"]; if (string.IsNullOrEmpty(empid)) { empid = "0"; } model.Employee_id = int.Parse(empid); model.Employee = PageValidate.InputText(request["T_employee"], 255); string id = request["id"]; if (!string.IsNullOrEmpty(id) && id != "null") { DataSet ds = customer.GetList("id=" + int.Parse(id)); DataRow dr = ds.Tables[0].Rows[0]; model.Serialnumber = PageValidate.InputText(dr["Serialnumber"].ToString(), 255); model.id = int.Parse(id); customer.Update(model); //日志 C_Sys_log log = new C_Sys_log(); int UserID = emp_id; string UserName = empname; string IPStreet = request.UserHostAddress; string EventTitle = model.Customer; string EventType = "客户修改"; int EventID = model.id; if (dr["Customer"].ToString() != request["T_company"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "公司名", dr["Customer"].ToString(), request["T_company"].ToString()); } if (dr["address"].ToString() != request["T_address"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "地址", dr["address"].ToString(), request["T_address"].ToString()); } if (dr["fax"].ToString() != request["T_fax"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "传真", dr["fax"].ToString(), request["T_fax"].ToString()); } if (dr["site"].ToString() != request["T_Website"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "网址", dr["site"].ToString(), request["T_Website"].ToString()); } if (dr["industry"].ToString() != request["T_industry"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "行业", dr["industry"].ToString(), request["T_industry"].ToString()); } if (dr["Provinces"].ToString() != request["T_Provinces"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "省份", dr["Provinces"].ToString(), request["T_Provinces"].ToString()); } if (dr["City"].ToString() != request["T_City"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "城市", dr["City"].ToString(), request["T_City"].ToString()); } if (dr["CustomerType"].ToString() != request["T_customertype"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "客户类型", dr["CustomerType"].ToString(), request["T_customertype"].ToString()); } if (dr["CustomerLevel"].ToString() != request["T_customerlevel"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "客户级别", dr["CustomerLevel"].ToString(), request["T_customerlevel"].ToString()); } if (dr["CustomerSource"].ToString() != request["T_CustomerSource"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "客户来源", dr["CustomerSource"].ToString(), request["T_CustomerSource"].ToString()); } if (dr["DesCripe"].ToString() != request["T_descript"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "客户描述", dr["DesCripe"].ToString(), request["T_descript"].ToString()); } if (dr["Remarks"].ToString() != request["T_remarks"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "备注", dr["Remarks"].ToString(), request["T_remarks"].ToString()); } if (dr["privatecustomer"].ToString() != request["T_private"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "公私", dr["privatecustomer"].ToString(), request["T_private"].ToString()); } if (dr["Department"].ToString() != request["T_department"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "部门", dr["Department"].ToString(), request["T_department"].ToString()); } if (dr["Employee"].ToString() != request["T_employee"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工", dr["Employee"].ToString(), request["T_employee"].ToString()); } } else { DateTime nowtime = DateTime.Now; model.Create_date = nowtime; model.Serialnumber = nowtime.AddMilliseconds(3).ToString("yyyyMMddHHmmssfff").Trim(); model.lastfollow = nowtime; model.Create_id = int.Parse(request.Cookies["UserID"].Value); int customerid = customer.Add(model); BLL.CRM_Contact contact = new BLL.CRM_Contact(); Model.CRM_Contact modelcontact = new Model.CRM_Contact(); modelcontact.C_name = PageValidate.InputText(request["T_customername"], 255); modelcontact.C_sex = PageValidate.InputText(request["T_sex"], 255); modelcontact.C_department = PageValidate.InputText(request["T_dep"], 255); modelcontact.C_position = PageValidate.InputText(request["T_position"], 255); modelcontact.C_QQ = PageValidate.InputText(request["T_qq"], 255); modelcontact.C_tel = PageValidate.InputText(request["T_tel"], 255); modelcontact.C_mob = PageValidate.InputText(request["T_mobil"], 255); modelcontact.C_email = Common.PageValidate.InputText(request["T_email"], 255); modelcontact.C_customerid = customerid; modelcontact.C_customername = model.Customer; modelcontact.C_createId = emp_id; modelcontact.C_createDate = DateTime.Now; contact.Add(modelcontact); context.Response.Write("{success:success}"); } } if (request["Action"] == "grid") { int PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]); int PageSize = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]); string sortname = request["sortname"]; string sortorder = request["sortorder"]; if (string.IsNullOrEmpty(sortname)) { sortname = " Create_date"; } if (string.IsNullOrEmpty(sortorder)) { sortorder = "desc"; } string sorttext = " " + sortname + " " + sortorder; string Total; string serchtxt = null; string serchtype = request["isdel"]; if (serchtype == "1") { serchtxt += " ISNULL(isDelete,0)=1 "; } else { serchtxt += "ISNULL(isDelete,0)=0 "; } if (!string.IsNullOrEmpty(request["company"])) { serchtxt += " and Customer like N'%" + PageValidate.InputText(request["company"], 255) + "%'"; } if (!string.IsNullOrEmpty(request["address"])) { serchtxt += " and address like N'%" + PageValidate.InputText(request["address"], 255) + "%'"; } if (!string.IsNullOrEmpty(request["industry"])) { serchtxt += " and industry like N'%" + PageValidate.InputText(request["industry"], 255) + "%'"; } if (!string.IsNullOrEmpty(request["tel"])) { serchtxt += " and tel like N'%" + PageValidate.InputText(request["tel"], 255) + "%'"; } if (!string.IsNullOrEmpty(request["mobil"])) { serchtxt += " and mobil like N'%" + PageValidate.InputText(request["mobil"], 255) + "%'"; } if (!string.IsNullOrEmpty(request["qq"])) { serchtxt += " and QQ like N'%" + PageValidate.InputText(request["qq"], 255) + "%'"; } if (!string.IsNullOrEmpty(request["website"])) { serchtxt += " and site like N'%" + PageValidate.InputText(request["website"], 255) + "%'"; } if (!string.IsNullOrEmpty(request["customertype"])) { serchtxt += " and CustomerType_id = " + int.Parse(request["customertype_val"]); } if (!string.IsNullOrEmpty(request["customerlevel"])) { serchtxt += " and CustomerLevel_id = " + int.Parse(request["customerlevel_val"]); } if (!string.IsNullOrEmpty(request["T_Provinces"])) { serchtxt += " and Provinces_id = " + int.Parse(request["T_Provinces_val"]); } if (!string.IsNullOrEmpty(request["T_City"])) { serchtxt += " and City_id = " + int.Parse(request["T_City_val"]); } if (!string.IsNullOrEmpty(request["department"])) { serchtxt += " and Department_id = " + int.Parse(request["department_val"]); } if (!string.IsNullOrEmpty(request["employee"])) { serchtxt += " and Employee_id = " + int.Parse(request["employee_val"]); } if (!string.IsNullOrEmpty(request["startdate"])) { serchtxt += " and Create_date >= '" + PageValidate.InputText(request["startdate"], 255) + "'"; } if (!string.IsNullOrEmpty(request["enddate"])) { DateTime enddate = DateTime.Parse(request["enddate"]).AddHours(23).AddMinutes(59).AddSeconds(59); serchtxt += " and Create_date <= '" + enddate + "'"; } if (!string.IsNullOrEmpty(request["startdate_del"])) { serchtxt += " and Delete_time >= '" + PageValidate.InputText(request["startdate_del"], 255) + "'"; } if (!string.IsNullOrEmpty(request["enddate_del"])) { DateTime enddatedel = DateTime.Parse(request["enddate_del"]).AddHours(23).AddMinutes(59).AddSeconds(59); serchtxt += " and Delete_time <= '" + enddatedel + "'"; } if (!string.IsNullOrEmpty(request["startfollow"])) { serchtxt += " and lastfollow >= '" + PageValidate.InputText(request["startfollow"], 255) + "'"; } if (!string.IsNullOrEmpty(request["endfollow"])) { DateTime enddate = DateTime.Parse(request["endfollow"]).AddHours(23).AddMinutes(59).AddSeconds(59); serchtxt += " and lastfollow <= '" + enddate + "'"; } //权限 DataSet ds = customer.GetList(PageSize, PageIndex, serchtxt, sorttext, out Total); DataSet dsauth = DataAuth(ds, request.Cookies["UserID"].Value); string dt = Common.GetGridJSON.DataTableToJSON1(dsauth.Tables[0], Total); context.Response.Write(dt); } //Form JSON if (request["Action"] == "form") { DataSet ds = customer.GetList("id=" + int.Parse(request["cid"])); string dt = Common.DataToJson.DataToJSON(DataAuth(ds, emp_id.ToString())); context.Response.Write(dt); } //预删除 if (request["Action"] == "AdvanceDelete") { string id = request["id"]; if (!string.IsNullOrEmpty(id)) { id = Common.PageValidate.IsNumber(id) ? id : "-1"; } else { id = "-1"; } DataSet ds = customer.GetList("id=" + int.Parse(id)); BLL.CRM_Contact contact = new BLL.CRM_Contact(); BLL.CRM_contract contract = new BLL.CRM_contract(); BLL.CRM_Follow follow = new BLL.CRM_Follow(); if (follow.GetList(" Customer_id=" + int.Parse(id)).Tables[0].Rows.Count > 0) { //含有跟进信息,不能删除 context.Response.Write("false:follow"); } else if (contact.GetList(" C_customerid=" + int.Parse(id)).Tables[0].Rows.Count > 0) { //含联系人 context.Response.Write("false:contact"); } else if (contract.GetList(" Customer_id=" + int.Parse(id)).Tables[0].Rows.Count > 0) { //含订单 context.Response.Write("false:order"); } else { bool canedel = true; if (uid != "admin") { Data.GetDataAuth dataauth = new Data.GetDataAuth(); string txt = dataauth.GetDataAuthByid("1", "Sys_del", emp_id.ToString()); string[] arr = txt.Split(':'); switch (arr[0]) { case "none": canedel = false; break; case "my": for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["Employee_id"].ToString() == arr[1]) { canedel = true; } else { canedel = false; } } break; case "dep": for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["dep_id"].ToString() == arr[1]) { canedel = true; } else { canedel = false; } } break; case "all": canedel = true; break; } } if (canedel) { bool isdel = customer.AdvanceDelete(int.Parse(request["id"]), 1, DateTime.Now.ToString(StaticStr.yyyy_MM_dd_HH_mm_ss)); //context.Response.Write("{success:success}"); if (isdel) { //日志 string EventType = "客户预删除"; int UserID = emp_id; string UserName = empname; string IPStreet = request.UserHostAddress; int EventID = int.Parse(id); string EventTitle = ds.Tables[0].Rows[0]["Customer"].ToString(); string Original_txt = null; string Current_txt = null; C_Sys_log log = new C_Sys_log(); log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt); context.Response.Write("true"); } else { context.Response.Write("false"); } } else { context.Response.Write("delfalse"); } } } //regain if (request["Action"] == "regain") { string idlist = PageValidate.InputText(request["idlist"], 100000); string[] arr = idlist.Split(','); DataSet ds = customer.GetList("id in (" + idlist.Trim() + ")"); bool canedel = true; if (uid != "admin") { Data.GetDataAuth dataauth = new Data.GetDataAuth(); string txt = dataauth.GetDataAuthByid("1", "Sys_del", emp_id.ToString()); string[] arr1 = txt.Split(':'); switch (arr1[0]) { case "none": canedel = false; break; case "my": for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["Employee_id"].ToString() == arr1[1]) { canedel = true; } else { canedel = false; } } break; case "dep": for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["Department_id"].ToString() == arr1[1]) { canedel = true; } else { canedel = false; } } break; case "all": canedel = true; break; } } if (canedel) { for (int i = 0; i < arr.Length; i++) { customer.AdvanceDelete(int.Parse(arr[i]), 0, DateTime.Now.ToString(StaticStr.yyyy_MM_dd_HH_mm_ss)); } if (true) { //日志 string EventType = "恢复删除商家"; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int UserID = emp_id; string UserName = empname; int EventID = idlist[i]; string IPStreet = request.UserHostAddress; string EventTitle = ds.Tables[0].Rows[i]["Customer"].ToString(); string Original_txt = null; string Current_txt = null; C_Sys_log log = new C_Sys_log(); log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt); } context.Response.Write("true"); } } else { context.Response.Write("delfalse"); } } if (request.Params["Action"] == "del") { bool canDel = false; if (dsemp.Tables[0].Rows.Count > 0) { if (dsemp.Tables[0].Rows[0]["uid"].ToString() == "admin") { canDel = true; } else { Data.GetAuthorityByUid getauth = new Data.GetAuthorityByUid(); string delauth = getauth.GetBtnAuthority(request.Cookies["UserID"].Value, "60"); if (delauth == "false") { canDel = false; } else { canDel = true; } } } if (canDel) { string idlist = PageValidate.InputText(request["idlist"], 100000); string[] arr = idlist.Split(','); string EventType = "彻底删除商家"; DataSet ds = customer.GetList("id in (" + idlist.Trim() + ")"); bool canedel = true; if (uid != "admin") { Data.GetDataAuth dataauth = new Data.GetDataAuth(); string txt = dataauth.GetDataAuthByid("1", "Sys_del", emp_id.ToString()); string[] arr1 = txt.Split(':'); switch (arr1[0]) { case "none": canedel = false; break; case "my": for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["Employee_id"].ToString() == arr1[1]) { canedel = true; } else { canedel = false; } } break; case "dep": for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["dep_id"].ToString() == arr1[1]) { canedel = true; } else { canedel = false; } } break; case "all": canedel = true; break; } } if (canedel) { for (int i = 0; i < arr.Length; i++) { customer.Delete(int.Parse(arr[i])); } if (true) { //日志 for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int UserID = emp_id; string UserName = empname; string IPStreet = request.UserHostAddress; int EventID = idlist[i]; string EventTitle = ds.Tables[0].Rows[0]["Customer"].ToString(); string Original_txt = null; string Current_txt = null; C_Sys_log log = new C_Sys_log(); log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt); } context.Response.Write("true"); } } else { context.Response.Write("delfalse"); } } else { context.Response.Write("auth"); } } //validate website if (request["Action"] == "validate") { BLL.CRM_Customer cc = new BLL.CRM_Customer(); string website = request["T_Website"]; string customerid = request["T_cid"]; if (string.IsNullOrEmpty(customerid) || customerid == "null") { customerid = "0"; } string oldsite = urlstr(website); //context.Response.Write("oldsite:"+oldsite); DataSet ds = cc.GetList("site like N'%" + oldsite + "%' and id!=" + customerid); //context.Response.Write(" Count:" + ds.Tables[0].Rows.Count); bool b = true; if (ds.Tables[0].Rows.Count > 0) { //context.Response.Write(" newsite:"+urlstr(ds.Tables[0].Rows[0]["site"].ToString())); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (urlstr(ds.Tables[0].Rows[i]["site"].ToString()) == oldsite) { b = false; break; } } } if (b) { context.Response.Write("true"); } else { context.Response.Write("false"); } } if (request["Action"] == "Compared") { string dt1 = request["date1"]; string dt2 = request["date2"]; DataSet ds = customer.Compared(DateTime.Parse(dt1), DateTime.Parse(dt2)); string dt = GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } if (request["Action"] == "Compared_type") { string dt1 = request["date1"]; string dt2 = request["date2"]; DataSet ds = customer.Compared_type(DateTime.Parse(dt1), DateTime.Parse(dt2)); string dt = GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } if (request["Action"] == "Compared_level") { string dt1 = request["date1"]; string dt2 = request["date2"]; DataSet ds = customer.Compared_level(DateTime.Parse(dt1), DateTime.Parse(dt2)); string dt = GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } if (request["Action"] == "Compared_source") { string dt1 = request["date1"]; string dt2 = request["date2"]; DataSet ds = customer.Compared_source(DateTime.Parse(dt1), DateTime.Parse(dt2)); string dt = GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } if (request["Action"] == "Compared_empcusadd") { var idlist = PageValidate.InputText(request["idlist"].Replace(";", ",").Replace("-", ""), 100000); string dt1 = request["date1"]; string dt2 = request["date2"]; BLL.hr_post post = new BLL.hr_post(); DataSet dspost = post.GetList(" post_id in(" + idlist + ")"); string emplist = "("; for (int i = 0; i < dspost.Tables[0].Rows.Count - 1; i++) { emplist += dspost.Tables[0].Rows[i]["emp_id"] + ","; } emplist += dspost.Tables[0].Rows[dspost.Tables[0].Rows.Count - 1]["emp_id"] + ")"; //context.Response.Write(emplist); DataSet ds = customer.Compared_empcusadd(DateTime.Parse(dt1), DateTime.Parse(dt2), emplist); string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } if (request["Action"] == "emp_customer") { var idlist = PageValidate.InputText(request["idlist"].Replace(";", ",").Replace("-", ""), 100000); var syear = request["syear"]; BLL.hr_post post = new BLL.hr_post(); DataSet dspost = post.GetList("post_id in(" + idlist + ")"); string emplist = "("; for (int i = 0; i < dspost.Tables[0].Rows.Count - 1; i++) { emplist += dspost.Tables[0].Rows[i]["emp_id"] + ","; } emplist += dspost.Tables[0].Rows[dspost.Tables[0].Rows.Count - 1]["emp_id"] + ")"; //context.Response.Write(emplist); DataSet ds = customer.report_empcus(int.Parse(syear), emplist); string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpRequest request = context.Request; BLL.tool_batch batch = new BLL.tool_batch(); Model.tool_batch model = new Model.tool_batch(); var cookie = context.Request.Cookies[FormsAuthentication.FormsCookieName]; var ticket = FormsAuthentication.Decrypt(cookie.Value); string CoockiesID = ticket.UserData; BLL.hr_employee emp = new BLL.hr_employee(); int emp_id = int.Parse(CoockiesID); DataSet dsemp = emp.GetList("id=" + emp_id); string empname = dsemp.Tables[0].Rows[0]["name"].ToString(); string uid = dsemp.Tables[0].Rows[0]["uid"].ToString(); if (request["Action"] == "save") { model.batch_type = PageValidate.InputText(request["type"], 50); model.b_count = 0; model.o_dep_id = int.Parse(request["T_dep1_val"]); model.o_dep = PageValidate.InputText(request["T_dep1"], 250); model.o_emp_id = int.Parse(request["T_employee1_val"]); model.o_emp = PageValidate.InputText(request["T_employee11"], 250); model.c_dep_id = int.Parse(request["T_dep2_val"]); model.c_dep = PageValidate.InputText(request["T_dep2"], 250); model.c_emp_id = int.Parse(request["T_employee2_val"]); model.c_emp = PageValidate.InputText(request["T_employee22"], 250); model.create_id = emp_id; model.create_name = PageValidate.InputText(empname, 250); model.create_date = DateTime.Now; switch (model.batch_type) { case "customer": BLL.CRM_Customer customer = new BLL.CRM_Customer(); Model.CRM_Customer model_cus = new Model.CRM_Customer(); model.b_count = customer.GetList(string.Format("Employee_id={0}", model.o_emp_id)).Tables[0].Rows.Count; model_cus.Department_id = model.c_dep_id; model_cus.Department = model.c_dep; model_cus.Employee_id = model.c_emp_id; model_cus.Employee = model.c_emp; model_cus.Create_id = model.o_emp_id;// customer.Update_batch(model_cus); break; case "order": BLL.CRM_order order = new BLL.CRM_order(); Model.CRM_order model_order = new Model.CRM_order(); model.b_count = order.GetList(string.Format("F_emp_id={0}", model.o_emp_id)).Tables[0].Rows.Count; model_order.F_dep_id = model.c_dep_id; model_order.F_dep_name = model.c_dep; model_order.F_emp_id = model.c_emp_id; model_order.F_emp_name = model.c_emp; model_order.create_id = model.o_emp_id; order.Update_batch(model_order); break; } batch.Add(model); } if (request["Action"] == "grid") { int PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]); int PageSize = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]); string sortname = request["sortname"]; string sortorder = request["sortorder"]; if (string.IsNullOrEmpty(sortname)) { sortname = " id "; } if (string.IsNullOrEmpty(sortorder)) { sortorder = " desc"; } string sorttext = " " + sortname + " " + sortorder; string Total; string serchtxt = "1=1"; //context.Response.Write(serchtxt); DataSet ds = batch.GetList(PageSize, PageIndex, serchtxt, sorttext, out Total); string dt = Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], Total); context.Response.Write(dt); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpRequest request = context.Request; DataTable dt = new DataTable(); string msg = ""; string filename = request["T_filename"]; string path = "/img_crm/impfile/"; if (File.Exists(context.Server.MapPath(path + filename))) { dt = ExcelToDataTable(context.Server.MapPath(path + filename), "Sheet1"); if (dt.Rows.Count > 0) { StringBuilder sb = new StringBuilder(); BLL.CRM_Customer customer = new BLL.CRM_Customer(); Model.CRM_Customer model = new Model.CRM_Customer(); BLL.hr_employee emp = new BLL.hr_employee(); int u_id = int.Parse(request.Cookies["UserID"].Value); DataSet dsuser = emp.GetList("id=" + u_id); string uname = dsuser.Tables[0].Rows[0]["name"].ToString(); string uid = dsuser.Tables[0].Rows[0]["uid"].ToString(); string empid = request["T_employee_val"]; if (string.IsNullOrEmpty(empid)) empid = "0"; int emp_id = int.Parse(empid); DataSet dsemp = emp.GetList("id=" + emp_id); string depid = dsemp.Tables[0].Rows[0]["d_id"].ToString(); string depname = dsemp.Tables[0].Rows[0]["dname"].ToString(); string empname = dsemp.Tables[0].Rows[0]["name"].ToString(); int s = int.Parse(request["T_start"]); int e = int.Parse(request["T_end"]); if (e == 0) e = dt.Rows.Count; int suc_N = 0, fal_N = 0; for (int i = s; i <= e; i++) { model.Customer = PageValidate.InputText(dt.Rows[i][0].ToString(), 255); model.address = PageValidate.InputText(dt.Rows[i][1].ToString(), 255); model.fax = PageValidate.InputText(request["T_fax"], 255); model.site = PageValidate.InputText(request["T_Website"], 255); int ct = 0; string mobil = dt.Rows[i][2].ToString(); if (string.IsNullOrEmpty(mobil)) mobil = dt.Rows[i][4].ToString(); if (!string.IsNullOrEmpty(mobil)) { model.tel = PageValidate.InputText(mobil, 255); string industryid = request["T_industry_val"]; if (string.IsNullOrEmpty(industryid) || industryid == "null") industryid = "0"; model.industry_id = int.Parse(industryid); model.industry = PageValidate.InputText(request["T_industry"], 255); string provincesid = request["T_Provinces_val"]; if (string.IsNullOrEmpty(provincesid)) provincesid = "0"; model.Provinces_id = int.Parse(provincesid); model.Provinces = PageValidate.InputText(request["T_Provinces"], 255); string cityid = request["T_City_val"]; if (string.IsNullOrEmpty(cityid)) cityid = "0"; model.City_id = int.Parse(cityid); model.City = PageValidate.InputText(request["T_City"], 255); string ctypeid = request["T_customertype_val"]; if (string.IsNullOrEmpty(ctypeid)) ctypeid = "0"; model.CustomerType_id = int.Parse(ctypeid); model.CustomerType = PageValidate.InputText(request["T_customertype"], 255); string clevelid = request["T_customerlevel_val"]; if (string.IsNullOrEmpty(clevelid)) clevelid = "0"; model.CustomerLevel_id = int.Parse(clevelid); model.CustomerLevel = PageValidate.InputText(request["T_customerlevel"], 255); string csourceid = request["T_CustomerSource_val"]; if (string.IsNullOrEmpty(csourceid)) csourceid = "0"; model.CustomerSource_id = int.Parse(csourceid); model.CustomerSource = PageValidate.InputText(request["T_CustomerSource"], 255); model.DesCripe = PageValidate.InputText(request["T_descript"], 4000); model.Remarks = PageValidate.InputText(request["T_remarks"], 4000); //model.privatecustomer = PageValidate.InputText(request["T_private"], 255); model.privatecustomer = "私客"; //string depid = request["T_department_val"]; //if (string.IsNullOrEmpty(depid)) // depid = "0"; //model.Department_id = int.Parse(depid); //model.Department = PageValidate.InputText(request["T_department"], 255); model.Department_id = int.Parse(depid); model.Department = PageValidate.InputText(depname, 255); //string empid = request["T_employee_val"]; //if (string.IsNullOrEmpty(empid)) // empid = "0"; //model.Employee_id = int.Parse(empid); //model.Employee = PageValidate.InputText(request["T_employee"], 255); model.Employee_id = emp_id; model.Employee = PageValidate.InputText(empname, 255); model.isDelete = 0; DateTime nowtime = DateTime.Now; model.Create_date = nowtime; model.Serialnumber = nowtime.AddMilliseconds(3).ToString("yyyyMMddHHmmssfff").Trim(); model.Create_id = u_id; model.Create_name = Common.PageValidate.InputText(uname, 255); //string isread = "0"; model.isRead = 0; model.isImport = 1; int customerid = customer.Add(model); BLL.CRM_Contact contact = new BLL.CRM_Contact(); Model.CRM_Contact modelcontact = new Model.CRM_Contact(); modelcontact.isDelete = 0; modelcontact.C_name = PageValidate.InputText(dt.Rows[i][3].ToString(), 255); modelcontact.C_sex = "-"; modelcontact.C_department = PageValidate.InputText(request["T_dep"], 255); modelcontact.C_position = PageValidate.InputText(request["T_position"], 255); modelcontact.C_QQ = PageValidate.InputText(request["T_qq"], 255); modelcontact.C_tel = PageValidate.InputText(dt.Rows[i][4].ToString(), 255); modelcontact.C_mob = PageValidate.InputText(mobil, 255); modelcontact.C_email = Common.PageValidate.InputText(request["T_email"], 255); modelcontact.C_customerid = customerid; modelcontact.C_customername = model.Customer; modelcontact.C_createId = u_id; modelcontact.C_createDate = DateTime.Now; modelcontact.C_hobby = PageValidate.InputText(request["T_hobby"], 1000); modelcontact.C_remarks = PageValidate.InputText(request["T_contact_remarks"], 4000); ct = contact.Add(modelcontact); //context.Response.Write(ct); } if (ct > 0) { suc_N += 1; sb.Append(i + ". " + dt.Rows[i][3].ToString() + "(" + model.Customer + ") - 导入 成功 <br />"); } else { fal_N += 1; sb.Append(i + ". " + dt.Rows[i][3].ToString() + "(" + model.Customer + ") - 导入 <font color=#ff0000>失败</font> <br />"); } } msg = "导入情况:" + suc_N.ToString() + " 成功," + fal_N.ToString() + " 失败,共 " + (e - s + 1).ToString() + " <br />" + sb.ToString(); } else { msg = "文件里没有你所需要的数据!"; } } else { msg="文件不存在!"; } context.Response.Write(msg); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpRequest request = context.Request; BLL.Param_SysParam psp = new BLL.Param_SysParam(); Model.Param_SysParam model = new Model.Param_SysParam(); var cookie = context.Request.Cookies[FormsAuthentication.FormsCookieName]; var ticket = FormsAuthentication.Decrypt(cookie.Value); string CoockiesID = ticket.UserData; BLL.hr_employee emp = new BLL.hr_employee(); int emp_id = int.Parse(CoockiesID); DataSet dsemp = emp.GetList("id=" + emp_id); string empname = dsemp.Tables[0].Rows[0]["name"].ToString(); string uid = dsemp.Tables[0].Rows[0]["uid"].ToString(); if (request["Action"] == "GetApp") { BLL.Param_SysParam_Type cpst = new BLL.Param_SysParam_Type(); DataSet ds = cpst.GetList(0, "", "params_order"); StringBuilder str = new StringBuilder(); str.Append("["); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { str.Append("{id:" + ds.Tables[0].Rows[i]["id"].ToString() + ",pid:0,text:'" + ds.Tables[0].Rows[i]["params_name"] + "'},"); } str.Replace(",", "", str.Length - 1, 1); str.Append("]"); context.Response.Write(str); } if (request["Action"] == "GetParams") { string parentid = PageValidate.InputText(request["parentid"], 50); DataSet ds = psp.GetList(0, " parentid=" + int.Parse(parentid), "params_order"); string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } //combo if (request["Action"] == "combo") { string parentid = PageValidate.InputText(request["parentid"], 50); DataSet ds = psp.GetList(0, " parentid=" + int.Parse(parentid), "params_order"); StringBuilder str = new StringBuilder(); str.Append("["); //str.Append("{id:0,text:'无'},"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { str.Append("{id:" + ds.Tables[0].Rows[i]["id"].ToString() + ",text:'" + ds.Tables[0].Rows[i]["params_name"] + "'},"); } str.Replace(",", "", str.Length - 1, 1); str.Append("]"); context.Response.Write(str); } //Form JSON if (request["Action"] == "form") { DataSet ds = psp.GetList("id=" + int.Parse(request["paramid"])); string dt = Common.DataToJson.DataToJSON(ds); context.Response.Write(dt); } //save if (request["Action"] == "save") { model.params_name = PageValidate.InputText(request["T_param_name"], 255); model.params_order = int.Parse(request["T_param_order"]); string id = request["paramid"]; if (!string.IsNullOrEmpty(id) && id != "null") { DataSet ds = psp.GetList("id=" + int.Parse(id)); model.parentid = int.Parse(ds.Tables[0].Rows[0]["parentid"].ToString()); model.id = int.Parse(id); psp.Update(model); } else { model.parentid = int.Parse(request["parentid"]); psp.Add(model); } } //del if (request["Action"] == "del") { string parentid = request["parentid"]; string paramid = request["paramid"]; BLL.CRM_Customer customer = new BLL.CRM_Customer(); BLL.CRM_Follow follow = new BLL.CRM_Follow(); BLL.CRM_order order = new BLL.CRM_order(); BLL.CRM_invoice invoice = new BLL.CRM_invoice(); BLL.CRM_receive receive = new BLL.CRM_receive(); DataSet ds = null; switch (int.Parse(parentid)) { case 8: ds = customer.GetList("industry_id=" + int.Parse(paramid)); break; case 1: ds = customer.GetList("CustomerType_id=" + int.Parse(paramid)); break; case 2: ds = customer.GetList("CustomerLevel_id=" + int.Parse(paramid)); break; case 3: ds = customer.GetList("CustomerSource_id=" + int.Parse(paramid)); break; case 4: ds = follow.GetList("Follow_Type_id=" + int.Parse(paramid)); break; case 5: ds = order.GetList("pay_type_id=" + int.Parse(paramid)); if (ds.Tables[0].Rows.Count == 0) { ds = receive.GetList("Pay_type_id=" + int.Parse(paramid)); } break; case 6: ds = order.GetList("Order_status_id=" + int.Parse(paramid)); break; case 7: ds = invoice.GetList("invoice_type_id=" + int.Parse(paramid)); break; } if (ds.Tables[0].Rows.Count > 0) { context.Response.Write("false:data"); return; } bool isdel = psp.Delete(int.Parse(paramid)); if (isdel) { context.Response.Write("true"); } else { context.Response.Write("false"); } } if (request["Action"] == "validate") { string param_name = PageValidate.InputText(request["T_param_name"], 50); string parentid = PageValidate.InputText(request["parentid"], 50); string cid = PageValidate.InputText(request["T_cid"], 50); if (string.IsNullOrEmpty(cid) || cid == "null") { cid = "0"; } DataSet ds = psp.GetList(string.Format(" params_name='{0}' and parentid={1} and id!={2} ", param_name, parentid, cid)); //context.Response.Write(" Count:" + ds.Tables[0].Rows.Count); if (ds.Tables[0].Rows.Count > 0) { context.Response.Write("false"); } else { context.Response.Write("true"); } } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpRequest request = context.Request; BLL.CRM_Follow follow = new BLL.CRM_Follow(); Model.CRM_Follow model = new Model.CRM_Follow(); var cookie = context.Request.Cookies[FormsAuthentication.FormsCookieName]; var ticket = FormsAuthentication.Decrypt(cookie.Value); string CoockiesID = ticket.UserData; BLL.hr_employee emp = new BLL.hr_employee(); int emp_id = int.Parse(CoockiesID); DataSet dsemp = emp.GetList("id=" + emp_id); string empname = dsemp.Tables[0].Rows[0]["name"].ToString(); string uid = dsemp.Tables[0].Rows[0]["uid"].ToString(); if (request["Action"] == "save") { model.Customer_id = int.Parse(request["cid"]); BLL.CRM_Customer ccc = new BLL.CRM_Customer(); string cname = ccc.GetList("id=" + model.Customer_id).Tables[0].Rows[0]["Customer"].ToString(); model.Customer_name = PageValidate.InputText(cname, 250); model.Follow = PageValidate.InputText(request["T_follow"], 4000); model.Follow_Type_id = int.Parse(request["T_followtype_val"]); model.Follow_Type = PageValidate.InputText(request["T_followtype"], 255); string fid = PageValidate.InputText(request["fid"], 50); if (!string.IsNullOrEmpty(fid) && fid != "null") { DataSet ds = follow.GetList("id=" + int.Parse(fid)); DataRow dr = ds.Tables[0].Rows[0]; model.id = int.Parse(fid); follow.Update(model); //最后跟进 ccc.UpdateLastFollow(model.Customer_id.ToString()); //日志 C_Sys_log log = new C_Sys_log(); int UserID = emp_id; string UserName = empname; string IPStreet = request.UserHostAddress; string EventTitle = model.Customer_name; string EventType = "客户跟进修改"; int EventID = model.id; if (dr["Follow"].ToString() != request["T_follow"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "跟进内容", "跟进内容被修改", "跟进内容被修改"); } if (dr["Follow_Type"].ToString() != request["T_followtype"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "跟进类型", dr["Follow_Type"].ToString(), request["T_followtype"]); } } else { model.isDelete = 0; DataRow dr1 = dsemp.Tables[0].Rows[0]; model.employee_id = int.Parse(dr1["ID"].ToString()); model.employee_name = dr1["name"].ToString(); string depid = dr1["d_id"].ToString(); if (string.IsNullOrEmpty(depid)) { depid = "0"; } model.department_id = int.Parse(depid); model.department_name = dr1["dname"].ToString(); model.Follow_date = DateTime.Now; int customerid = follow.Add(model); //最后跟进 ccc.UpdateLastFollow(model.Customer_id.ToString()); } if (!string.IsNullOrEmpty(request["T_content"])) { BLL.Personal_Calendar calendar = new BLL.Personal_Calendar(); Model.Personal_Calendar modelcalendar = new Model.Personal_Calendar(); int clientzone = 8; int serverzone = GetTimeZone(); var zonediff = serverzone - clientzone; modelcalendar.StartTime = DateTime.Parse(request["T_starttime"]).AddHours(zonediff); modelcalendar.EndTime = DateTime.Parse(request["T_endtime"]).AddHours(zonediff); modelcalendar.Subject = PageValidate.InputText("【" + cname + "】" + request["T_content"], 4000); modelcalendar.emp_id = emp_id; modelcalendar.UPAccount = emp_id.ToString(); modelcalendar.UPTime = DateTime.Now; modelcalendar.MasterId = clientzone; modelcalendar.CalendarType = 1; modelcalendar.Category = "4";//跟进提醒 modelcalendar.companyid = model.Customer_id; modelcalendar.InstanceType = 0; modelcalendar.IsAllDayEvent = PageValidate.InputText(request["allday"], 255) == "True" ? true : false; calendar.Add(modelcalendar); } } if (request["Action"] == "form") { DataSet ds = follow.GetList("id=" + int.Parse(request["fid"]) + DataAuth(emp_id.ToString())); string dt = Common.DataToJson.DataToJSON(ds); context.Response.Write(dt); } //del if (request["Action"] == "del") { string id = request["id"]; DataSet ds = follow.GetList("id=" + int.Parse(id)); bool canedel = true; if (uid != "admin") { Data.GetDataAuth dataauth = new Data.GetDataAuth(); string txt = dataauth.GetDataAuthByid("2", "Sys_del", emp_id.ToString()); string[] arr = txt.Split(':'); switch (arr[0]) { case "none": canedel = false; break; case "my": for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["employee_id"].ToString() == arr[1]) { canedel = true; } else { canedel = false; } } break; case "dep": for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["dep_id"].ToString() == arr[1]) { canedel = true; } else { canedel = false; } } break; case "all": canedel = true; break; } } if (canedel) { bool isdel = follow.Delete(int.Parse(request["id"])); //context.Response.Write("{success:success}"); if (isdel) { //日志 string EventType = "跟进删除"; int UserID = emp_id; string UserName = empname; string IPStreet = request.UserHostAddress; int EventID = int.Parse(id); string EventTitle = ds.Tables[0].Rows[0]["Customer_name"].ToString(); string Original_txt = ds.Tables[0].Rows[0]["Follow"].ToString(); string Current_txt = null; C_Sys_log log = new C_Sys_log(); log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "跟进", Original_txt, Current_txt); context.Response.Write("true"); } else { context.Response.Write("false"); } } else { context.Response.Write("delfalse"); } } //serch if (request["Action"] == "grid") { int PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]); int PageSize = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]); string sortname = request["sortname"]; string sortorder = request["sortorder"]; if (string.IsNullOrEmpty(sortname)) { sortname = " id "; } if (string.IsNullOrEmpty(sortorder)) { sortorder = " desc"; } string sorttext = " " + sortname + " " + sortorder; string Total; string serchtxt = "1=1"; if (!string.IsNullOrEmpty(request["customer_id"])) { serchtxt += " and Customer_id=" + int.Parse(request["customer_id"]); } if (!string.IsNullOrEmpty(request["company"])) { serchtxt += " and Customer_name like N'%" + PageValidate.InputText(request["company"], 255) + "%'"; } if (!string.IsNullOrEmpty(request["department"])) { serchtxt += " and department_id = " + int.Parse(request["department_val"]); } if (!string.IsNullOrEmpty(request["employee"])) { serchtxt += " and employee_id = " + int.Parse(request["employee_val"]); } if (!string.IsNullOrEmpty(request["followtype"])) { serchtxt += " and Follow_Type_id = " + int.Parse(request["followtype_val"]); } if (!string.IsNullOrEmpty(request["startdate"])) { serchtxt += " and Follow_date >= '" + PageValidate.InputText(request["startdate"], 255) + "'"; } if (!string.IsNullOrEmpty(request["enddate"])) { DateTime enddate = DateTime.Parse(request["enddate"]).AddHours(23).AddMinutes(59).AddSeconds(59); serchtxt += " and Follow_date <= '" + enddate + "'"; } if (!string.IsNullOrEmpty(request["startdate_del"])) { serchtxt += " and Delete_time >= '" + PageValidate.InputText(request["startdate_del"], 255) + "'"; } if (!string.IsNullOrEmpty(request["enddate_del"])) { DateTime enddate = DateTime.Parse(request["enddate_del"]).AddHours(23).AddMinutes(59).AddSeconds(59); serchtxt += " and Delete_time <= '" + enddate + "'"; } if (!string.IsNullOrEmpty(request["T_smart"])) { if (request["T_smart"] != "输入关键词智能搜索跟进内容") { serchtxt += " and Follow like N'%" + PageValidate.InputText(request["T_smart"], 255) + "%'"; } } //权限 serchtxt += DataAuth(emp_id.ToString()); DataSet ds = follow.GetList(PageSize, PageIndex, serchtxt, sorttext, out Total); string dt = Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], Total); context.Response.Write(dt); } if (request["Action"] == "Compared_follow") { string dt1 = request["date1"]; string dt2 = request["date2"]; DataSet ds = follow.Compared_follow(DateTime.Parse(dt1), DateTime.Parse(dt2)); string dt = GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } if (request["Action"] == "Compared_empcusfollow") { var idlist = PageValidate.InputText(request["idlist"].Replace(";", ",").Replace("-", ""), int.MaxValue); string dt1 = request["date1"]; string dt2 = request["date2"]; BLL.hr_post post = new BLL.hr_post(); DataSet dspost = post.GetList("post_id in(" + idlist + ")"); string emplist = "("; for (int i = 0; i < dspost.Tables[0].Rows.Count - 1; i++) { emplist += dspost.Tables[0].Rows[i]["emp_id"] + ","; } emplist += dspost.Tables[0].Rows[dspost.Tables[0].Rows.Count - 1]["emp_id"] + ")"; //context.Response.Write(emplist); DataSet ds = follow.Compared_empcusfollow(DateTime.Parse(dt1), DateTime.Parse(dt2), emplist); string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } if (request["Action"] == "emp_cusfollow") { var idlist = PageValidate.InputText(request["idlist"].Replace(";", ",").Replace("-", ""), int.MaxValue); var syear = request["syear"]; BLL.hr_post post = new BLL.hr_post(); DataSet dspost = post.GetList("post_id in(" + idlist + ")"); string emplist = "("; for (int i = 0; i < dspost.Tables[0].Rows.Count - 1; i++) { emplist += dspost.Tables[0].Rows[i]["emp_id"] + ","; } emplist += dspost.Tables[0].Rows[dspost.Tables[0].Rows.Count - 1]["emp_id"] + ")"; //context.Response.Write(emplist); DataSet ds = follow.report_empfollow(int.Parse(syear), emplist); string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpRequest request = context.Request; BLL.Sys_data_authority auth = new BLL.Sys_data_authority(); Model.Sys_data_authority model = new Model.Sys_data_authority(); if (request["Action"] == "get") { DataSet ds = auth.GetList("Role_id=" + request["Role_id"]); if (ds.Tables[0].Rows.Count == 4) { context.Response.Write(Common.GetGridJSON.DataTableToJSON(ds.Tables[0])); } else { string datatxt = ""; datatxt += "{Rows: ["; datatxt += " { '__status': null, 'option_id': 1, 'Sys_option': '客户管理', 'Sys_view': 1, 'Sys_add': 1, 'Sys_edit': 1, 'Sys_del': 1 },"; datatxt += " { '__status': null, 'option_id': 2, 'Sys_option': '跟进管理', 'Sys_view': 1, 'Sys_add': 1, 'Sys_edit': 1, 'Sys_del': 1 },"; datatxt += " { '__status': null, 'option_id': 3, 'Sys_option': '订单管理', 'Sys_view': 1, 'Sys_add': 1, 'Sys_edit': 1, 'Sys_del': 1 },"; datatxt += " { '__status': null, 'option_id': 4, 'Sys_option': '合同管理', 'Sys_view': 1, 'Sys_add': 1, 'Sys_edit': 1, 'Sys_del': 1 }"; datatxt += " ],Total: 4 }"; context.Response.Write(datatxt); } } if (request["Action"] == "save") { string rid = request["rid"]; string savestring = request["savestring"]; model.Role_id = int.Parse(rid); auth.Delete("Role_id=" + int.Parse(rid)); JavaScriptSerializer json = new JavaScriptSerializer(); List <AuthData> _list = json.Deserialize <List <AuthData> >(savestring); foreach (AuthData authdata in _list) { model.option_id = authdata.option_id; model.Sys_view = authdata.Sys_view; model.Sys_add = authdata.Sys_add; model.Sys_edit = authdata.Sys_edit; model.Sys_del = authdata.Sys_del; model.Sys_option = authdata.Sys_option; auth.Add(model); } context.Response.Write("true"); } if (request["Action"] == "getauth") { string crmid = request["crmid"]; if (string.IsNullOrEmpty(crmid)) { crmid = "0"; } DataSet ds = null; string authtype = request["authtype"]; string authid = request["authid"]; if (authid == "1") { BLL.CRM_Customer crm = new BLL.CRM_Customer(); ds = crm.GetList("id=" + crmid); } if (authid == "2") { BLL.CRM_Follow follow = new BLL.CRM_Follow(); ds = follow.GetList("id=" + crmid); } //权限 Data.GetDataAuth dataauth = new Data.GetDataAuth(); string txt = dataauth.GetDataAuthByid(authid, authtype, context.Request.Cookies["UserID"].Value); string[] arr = txt.Split(':'); switch (arr[0]) { case "all": context.Response.Write("true"); break; case "none": context.Response.Write("false"); break; case "my": if (ds.Tables[0].Rows[0]["Employee_id"].ToString() == context.Request.Cookies["UserID"].Value) { context.Response.Write("true"); } else { context.Response.Write("false"); } break; case "dep": BLL.hr_employee emp = new BLL.hr_employee(); DataSet ds1 = emp.GetList("id=" + context.Request.Cookies["UserID"].Value); if (ds.Tables[0].Rows[0]["Department_id"].ToString() == arr[1]) { context.Response.Write("true"); } else { context.Response.Write("false"); } break; } } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpRequest request = context.Request; BLL.CRM_Customer customer = new BLL.CRM_Customer(); Model.CRM_Customer model = new Model.CRM_Customer(); BLL.hr_employee emp = new BLL.hr_employee(); int emp_id = int.Parse(request.Cookies["UserID"].Value); DataSet dsemp = emp.GetList("id=" + emp_id); string empname = dsemp.Tables[0].Rows[0]["name"].ToString(); string uid = dsemp.Tables[0].Rows[0]["uid"].ToString(); //save if (request["Action"] == "save") { model.Customer = PageValidate.InputText(request["T_company"], 255); model.address = PageValidate.InputText(request["T_address"], 255); model.fax = PageValidate.InputText(request["T_fax"], 255); model.site = PageValidate.InputText(request["T_Website"], 255); model.tel = PageValidate.InputText(request["T_company_tel"], 255); string industryid = request["T_industry_val"]; if (string.IsNullOrEmpty(industryid) || industryid == "null") industryid = "0"; model.industry_id = int.Parse(industryid); model.industry = PageValidate.InputText(request["T_industry"], 255); string provincesid = request["T_Provinces_val"]; if (string.IsNullOrEmpty(provincesid)) provincesid = "0"; model.Provinces_id = int.Parse(provincesid); model.Provinces = PageValidate.InputText(request["T_Provinces"], 255); string cityid = request["T_City_val"]; if (string.IsNullOrEmpty(cityid)) cityid = "0"; model.City_id = int.Parse(cityid); model.City = PageValidate.InputText(request["T_City"], 255); string ctypeid = request["T_customertype_val"]; if (string.IsNullOrEmpty(ctypeid)) ctypeid = "0"; model.CustomerType_id = int.Parse(ctypeid); model.CustomerType = PageValidate.InputText(request["T_customertype"], 255); string clevelid = request["T_customerlevel_val"]; if (string.IsNullOrEmpty(clevelid)) clevelid = "0"; model.CustomerLevel_id = int.Parse(clevelid); model.CustomerLevel = PageValidate.InputText(request["T_customerlevel"], 255); string csourceid = request["T_CustomerSource_val"]; if (string.IsNullOrEmpty(csourceid)) csourceid = "0"; model.CustomerSource_id = int.Parse(csourceid); model.CustomerSource = PageValidate.InputText(request["T_CustomerSource"], 255); model.DesCripe = PageValidate.InputText(request["T_descript"], 4000); model.Remarks = PageValidate.InputText(request["T_remarks"], 4000); model.privatecustomer = PageValidate.InputText(request["T_private"], 255); string depid = request["T_department_val"]; if (string.IsNullOrEmpty(depid)) depid = "0"; model.Department_id = int.Parse(depid); model.Department = PageValidate.InputText(request["T_department"], 255); string empid = request["T_employee_val"]; if (string.IsNullOrEmpty(empid)) empid = "0"; model.Employee_id = int.Parse(empid); model.Employee = PageValidate.InputText(request["T_employee"], 255); string id = request["id"]; if (!string.IsNullOrEmpty(id) && id != "null") { DataSet ds = customer.GetList("id=" + int.Parse(id)); DataRow dr = ds.Tables[0].Rows[0]; model.Serialnumber = PageValidate.InputText(dr["Serialnumber"].ToString(), 255); model.id = int.Parse(id); customer.Update(model); //日志 C_Sys_log log = new C_Sys_log(); int UserID = emp_id; string UserName = empname; string IPStreet = request.UserHostAddress; string EventTitle = model.Customer; string EventType = "客户修改"; int EventID = model.id; if (dr["Customer"].ToString() != request["T_company"]) log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "公司名", dr["Customer"].ToString(), request["T_company"].ToString()); if (dr["address"].ToString() != request["T_address"]) log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "地址", dr["address"].ToString(), request["T_address"].ToString()); if (dr["fax"].ToString() != request["T_fax"]) log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "传真", dr["fax"].ToString(), request["T_fax"].ToString()); if (dr["site"].ToString() != request["T_Website"]) log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "网址", dr["site"].ToString(), request["T_Website"].ToString()); if (dr["industry"].ToString() != request["T_industry"]) log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "行业", dr["industry"].ToString(), request["T_industry"].ToString()); if (dr["Provinces"].ToString() != request["T_Provinces"]) log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "省份", dr["Provinces"].ToString(), request["T_Provinces"].ToString()); if (dr["City"].ToString() != request["T_City"]) log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "城市", dr["City"].ToString(), request["T_City"].ToString()); if (dr["CustomerType"].ToString() != request["T_customertype"]) log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "客户类型", dr["CustomerType"].ToString(), request["T_customertype"].ToString()); if (dr["CustomerLevel"].ToString() != request["T_customerlevel"]) log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "客户级别", dr["CustomerLevel"].ToString(), request["T_customerlevel"].ToString()); if (dr["CustomerSource"].ToString() != request["T_CustomerSource"]) log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "客户来源", dr["CustomerSource"].ToString(), request["T_CustomerSource"].ToString()); if (dr["DesCripe"].ToString() != request["T_descript"]) log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "客户描述", dr["DesCripe"].ToString(), request["T_descript"].ToString()); if (dr["Remarks"].ToString() != request["T_remarks"]) log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "备注", dr["Remarks"].ToString(), request["T_remarks"].ToString()); if (dr["privatecustomer"].ToString() != request["T_private"]) log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "公私", dr["privatecustomer"].ToString(), request["T_private"].ToString()); if (dr["Department"].ToString() != request["T_department"]) log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "部门", dr["Department"].ToString(), request["T_department"].ToString()); if (dr["Employee"].ToString() != request["T_employee"]) log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工", dr["Employee"].ToString(), request["T_employee"].ToString()); } else { model.isDelete = 0; DateTime nowtime = DateTime.Now; model.Create_date = nowtime; model.Serialnumber = nowtime.AddMilliseconds(3).ToString("yyyyMMddHHmmssfff").Trim(); model.Create_id = int.Parse(request.Cookies["UserID"].Value); model.Create_name = Common.PageValidate.InputText(empname, 255); string isread = "0"; if (int.Parse(request.Cookies["UserID"].Value) != int.Parse(empid)) isread = "1"; model.isRead = int.Parse(isread); int customerid = customer.Add(model); BLL.CRM_Contact contact = new BLL.CRM_Contact(); Model.CRM_Contact modelcontact = new Model.CRM_Contact(); modelcontact.isDelete = 0; modelcontact.C_name = PageValidate.InputText(request["T_customername"], 255); modelcontact.C_sex = PageValidate.InputText(request["T_sex"], 255); modelcontact.C_department = PageValidate.InputText(request["T_dep"], 255); modelcontact.C_position = PageValidate.InputText(request["T_position"], 255); modelcontact.C_QQ = PageValidate.InputText(request["T_qq"], 255); modelcontact.C_tel = PageValidate.InputText(request["T_tel"], 255); modelcontact.C_mob = PageValidate.InputText(request["T_mobil"], 255); modelcontact.C_email = Common.PageValidate.InputText(request["T_email"], 255); modelcontact.C_customerid = customerid; modelcontact.C_customername = model.Customer; modelcontact.C_createId = emp_id; modelcontact.C_createDate = DateTime.Now; modelcontact.C_hobby = PageValidate.InputText(request["T_hobby"], 1000); modelcontact.C_remarks = PageValidate.InputText(request["T_contact_remarks"], 4000); int ct = contact.Add(modelcontact); context.Response.Write(ct); } } if (request["Action"] == "grid") { int PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]); int PageSize = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]); string sortname = request["sortname"]; string sortorder = request["sortorder"]; if (string.IsNullOrEmpty(sortname)) sortname = " id"; if (string.IsNullOrEmpty(sortorder)) sortorder = " desc"; string sorttext = " " + sortname + " " + sortorder; string Total; string serchtxt = null; string serchtype = request["isdel"]; if (serchtype == "1") serchtxt += " isDelete=1 "; else serchtxt += " isDelete=0 "; string serchstr = null; if (!string.IsNullOrEmpty(request["companyid"])) serchstr += " and id =" + int.Parse(request["companyid"]); if (!string.IsNullOrEmpty(request["company"])) serchstr += " and Customer like N'%" + PageValidate.InputText(request["company"], 255) + "%'"; if (!string.IsNullOrEmpty(request["address"])) serchstr += " and address like N'%" + PageValidate.InputText(request["address"], 255) + "%'"; if (!string.IsNullOrEmpty(request["industry"])) serchstr += " and industry like N'%" + PageValidate.InputText(request["industry"], 255) + "%'"; if (!string.IsNullOrEmpty(request["tel"])) serchstr += " and tel like N'%" + PageValidate.InputText(request["tel"], 255) + "%'"; if (!string.IsNullOrEmpty(request["mobil"])) serchstr += " and mobil like N'%" + PageValidate.InputText(request["mobil"], 255) + "%'"; if (!string.IsNullOrEmpty(request["qq"])) serchstr += " and QQ like N'%" + PageValidate.InputText(request["qq"], 255) + "%'"; if (!string.IsNullOrEmpty(request["website"])) serchstr += " and site like N'%" + PageValidate.InputText(request["website"], 255) + "%'"; if (!string.IsNullOrEmpty(request["customertype"])) serchstr += " and CustomerType_id = " + int.Parse(request["customertype_val"]); if (!string.IsNullOrEmpty(request["customerlevel"])) serchstr += " and CustomerLevel_id = " + int.Parse(request["customerlevel_val"]); if (!string.IsNullOrEmpty(request["T_Provinces"])) serchstr += " and Provinces_id = " + int.Parse(request["T_Provinces_val"]); if (!string.IsNullOrEmpty(request["T_City"])) serchstr += " and City_id = " + int.Parse(request["T_City_val"]); if (!string.IsNullOrEmpty(request["department"])) serchstr += " and Department_id = " + int.Parse(request["department_val"]); if (!string.IsNullOrEmpty(request["employee"])) serchstr += " and Employee_id = " + int.Parse(request["employee_val"]); if (!string.IsNullOrEmpty(request["startdate"])) serchstr += " and Create_date >= '" + PageValidate.InputText(request["startdate"], 255) + "'"; if (!string.IsNullOrEmpty(request["enddate"])) { DateTime enddate = DateTime.Parse(request["enddate"]).AddHours(23).AddMinutes(59).AddSeconds(59); serchstr += " and Create_date <= '" + enddate + "'"; } if (!string.IsNullOrEmpty(request["startdate_del"])) serchstr += " and Delete_time >= '" + PageValidate.InputText(request["startdate_del"], 255) + "'"; if (!string.IsNullOrEmpty(request["enddate_del"])) { DateTime enddatedel = DateTime.Parse(request["enddate_del"]).AddHours(23).AddMinutes(59).AddSeconds(59); serchstr += " and Delete_time <= '" + enddatedel + "'"; } if (!string.IsNullOrEmpty(request["startfollow"])) serchstr += " and lastfollow >= '" + PageValidate.InputText(request["startfollow"], 255) + "'"; if (!string.IsNullOrEmpty(request["endfollow"])) { DateTime enddate = DateTime.Parse(request["endfollow"]).AddHours(23).AddMinutes(59).AddSeconds(59); serchstr += " and lastfollow <= '" + enddate + "'"; } if (!string.IsNullOrEmpty(request["C_employee"])) serchstr += " and Create_id = " + int.Parse(request["C_employee_val"]); else { //权限 serchtxt += DataAuth(request.Cookies["UserID"].Value); } serchtxt += serchstr; if (string.IsNullOrEmpty(serchstr)) { //创建者 if (!string.IsNullOrEmpty(serchtxt)) serchtxt = "(" + serchtxt + ")"; serchtxt += " or Create_id=" + int.Parse(request.Cookies["UserID"].Value); } //context.Response.Write(serchtxt); DataSet ds = customer.GetList(PageSize, PageIndex, serchtxt, sorttext, out Total); string dt = Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], Total); context.Response.Write(dt); } if (request["Action"] == "continue") { } //Form JSON if (request["Action"] == "form") { string id = request["cid"]; DataSet ds = customer.GetList("id=" + int.Parse(id) + DataAuth(request.Cookies["UserID"].Value)); bool isRead = customer.SetRead(int.Parse(id), int.Parse(request.Cookies["UserID"].Value)); string dt = Common.DataToJson.DataToJSON(ds); context.Response.Write(dt); } if (request["Action"] == "read") { string UserID = request["u"]; DataSet ds = customer.GetListTotal("Employee_id=" + UserID.ToString() + " And isRead=0"); string dt = Common.DataToJson.DataToJSON(ds); context.Response.Write(dt); } if (request["Action"] == "setread") { bool isRead = customer.SetRead(int.Parse(request["customer_id"]), int.Parse(request.Cookies["UserID"].Value)); if (isRead) { context.Response.Write("true"); } else { context.Response.Write("false"); } } if (request["Action"] == "count") { string id = request["id"]; DataSet ds = customer.GetList("id=" + int.Parse(id)); BLL.CRM_Contact contact = new BLL.CRM_Contact(); BLL.CRM_contract contract = new BLL.CRM_contract(); BLL.CRM_order order = new BLL.CRM_order(); BLL.CRM_Follow follow = new BLL.CRM_Follow(); int contactcount = 0, contractcount = 0, followcount = 0, ordercount = 0; contractcount = contract.GetList(" Customer_id=" + int.Parse(id)).Tables[0].Rows.Count; contactcount = contact.GetList(" C_customerid=" + int.Parse(id)).Tables[0].Rows.Count; followcount = follow.GetList(" Customer_id=" + int.Parse(id)).Tables[0].Rows.Count; ordercount = order.GetList(" Customer_id=" + int.Parse(id)).Tables[0].Rows.Count; context.Response.Write(string.Format("{0}联系人, {2}跟进, {3}订单,{1}合同 ", contactcount, contractcount, followcount, ordercount)); } //预删除 if (request["Action"] == "AdvanceDelete") { string id = request["id"]; DataSet ds = customer.GetList("id=" + int.Parse(id)); bool canedel = true; if (uid != "admin") { Data.GetDataAuth dataauth = new Data.GetDataAuth(); string txt = dataauth.GetDataAuthByid("1", "Sys_del", emp_id.ToString()); string[] arr = txt.Split(':'); switch (arr[0]) { case "none": canedel = false; break; case "my": for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["Employee_id"].ToString() == arr[1]) canedel = true; else canedel = false; } break; case "dep": for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["Department_id"].ToString() == arr[1]) canedel = true; else canedel = false; } break; case "all": canedel = true; break; } } if (canedel) { bool isdel = customer.AdvanceDelete(int.Parse(request["id"]), 1, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); if (isdel) { //日志 string EventType = "客户预删除"; int UserID = emp_id; string UserName = empname; string IPStreet = request.UserHostAddress; int EventID = int.Parse(id); string EventTitle = ds.Tables[0].Rows[0]["Customer"].ToString(); string Original_txt = null; string Current_txt = null; C_Sys_log log = new C_Sys_log(); log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt); context.Response.Write("true"); } else { context.Response.Write("false"); } } else { context.Response.Write("delfalse"); } } //regain if (request["Action"] == "regain") { string idlist = PageValidate.InputText(request["idlist"], 100000); string[] arr = idlist.Split(','); DataSet ds = customer.GetList("id in (" + idlist.Trim() + ")"); //日志 string EventType = "恢复删除商家"; int UserID = emp_id; string UserName = empname; string IPStreet = request.UserHostAddress; string Original_txt = null; string Current_txt = null; int success = 0, failure = 0; //计数 for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { bool isregain = customer.AdvanceDelete(int.Parse(arr[i]), 0, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); if (isregain) { C_Sys_log log = new C_Sys_log(); int EventID = int.Parse(ds.Tables[0].Rows[i]["id"].ToString()); string EventTitle = ds.Tables[0].Rows[i]["Customer"].ToString(); log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt); success++; } else { failure++; } } context.Response.Write(string.Format("{0}恢复成功,{1}失败", success, failure)); } if (request.Params["Action"] == "del") { bool canDel = false; if (dsemp.Tables[0].Rows.Count > 0) { if (dsemp.Tables[0].Rows[0]["uid"].ToString() == "admin") { canDel = true; } else { Data.GetAuthorityByUid getauth = new Data.GetAuthorityByUid(); string delauth = getauth.GetBtnAuthority(request.Cookies["UserID"].Value, "60"); if (delauth == "false") canDel = false; else canDel = true; } } if (canDel) { string idlist = PageValidate.InputText(request["idlist"], 100000); string[] arr = idlist.Split(','); string EventType = "彻底删除客户"; DataSet ds = customer.GetList("id in (" + idlist.Trim() + ")"); bool canedel = true; if (uid != "admin") { Data.GetDataAuth dataauth = new Data.GetDataAuth(); string txt = dataauth.GetDataAuthByid("1", "Sys_del", emp_id.ToString()); string[] arr1 = txt.Split(':'); switch (arr1[0]) { case "none": canedel = false; break; case "my": for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["Employee_id"].ToString() == arr1[1]) canedel = true; else canedel = false; } break; case "dep": for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["Department_id"].ToString() == arr1[1]) canedel = true; else canedel = false; } break; case "all": canedel = true; break; } } if (canedel) { BLL.CRM_Contact contact = new BLL.CRM_Contact(); BLL.CRM_contract contract = new BLL.CRM_contract(); BLL.CRM_order order = new BLL.CRM_order(); BLL.CRM_Follow follow = new BLL.CRM_Follow(); int contactcount = 0, contractcount = 0, followcount = 0, ordercount = 0, success = 0, failure = 0; //日志 for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string cid = ds.Tables[0].Rows[i]["id"].ToString(); contractcount = contract.GetList(" Customer_id=" + int.Parse(cid)).Tables[0].Rows.Count; contactcount = contact.GetList(" C_customerid=" + int.Parse(cid)).Tables[0].Rows.Count; followcount = follow.GetList(" Customer_id=" + int.Parse(cid)).Tables[0].Rows.Count; ordercount = order.GetList(" Customer_id=" + int.Parse(cid)).Tables[0].Rows.Count; //context.Response.Write( string.Format("{0}联系人, {2}跟进, {3}订单,{1}合同 ", contactcount, contractcount, followcount, ordercount)+":"+(contactcount > 0 || contractcount > 0 || followcount > 0 || ordercount > 0)+" "); if (contactcount > 0 || contractcount > 0 || followcount > 0 || ordercount > 0) { failure++; } else { bool isdel = customer.Delete(int.Parse(cid)); if (isdel) { success++; int UserID = emp_id; string UserName = empname; string IPStreet = request.UserHostAddress; int EventID = int.Parse(cid); string EventTitle = ds.Tables[0].Rows[i]["Customer"].ToString(); string Original_txt = null; string Current_txt = null; C_Sys_log log = new C_Sys_log(); log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt); } else { failure++; } } } context.Response.Write(string.Format("{0}条数据成功删除,{1}条失败。|{1}", success, failure)); } else { context.Response.Write("delfalse"); } } else { context.Response.Write("auth"); } } //validate website if (request["Action"] == "validate") { string company = request["T_company"]; string customerid = request["T_cid"]; if (string.IsNullOrEmpty(customerid) || customerid == "null") customerid = "0"; DataSet ds = customer.GetList("Customer = N'" + Common.PageValidate.InputText(company, 255) + "' and id!=" + int.Parse(customerid)); //context.Response.Write(" Count:" + ds.Tables[0].Rows.Count); if (ds.Tables[0].Rows.Count > 0) { context.Response.Write("false"); } else { context.Response.Write("true"); } } if (request["Action"] == "mobile") { string company = request["T_mobil"]; string customerid = request["T_cid"]; if (string.IsNullOrEmpty(customerid) || customerid == "null") customerid = "0"; DataSet ds = customer.GetList("T_mobil = N'" + Common.PageValidate.InputText(company, 255) + "' and id!=" + int.Parse(customerid)); //context.Response.Write(" Count:" + ds.Tables[0].Rows.Count); if (ds.Tables[0].Rows.Count > 0) { context.Response.Write("false"); } else { context.Response.Write("true"); } } if (request["Action"] == "Compared") { string dt1 = request["date1"]; string dt2 = request["date2"]; DataSet ds = customer.Compared(DateTime.Parse(dt1), DateTime.Parse(dt2)); string dt = GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } if (request["Action"] == "Compared_type") { string dt1 = request["date1"]; string dt2 = request["date2"]; DataSet ds = customer.Compared_type(DateTime.Parse(dt1), DateTime.Parse(dt2)); string dt = GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } if (request["Action"] == "Compared_level") { string dt1 = request["date1"]; string dt2 = request["date2"]; DataSet ds = customer.Compared_level(DateTime.Parse(dt1), DateTime.Parse(dt2)); string dt = GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } if (request["Action"] == "Compared_source") { string dt1 = request["date1"]; string dt2 = request["date2"]; DataSet ds = customer.Compared_source(DateTime.Parse(dt1), DateTime.Parse(dt2)); string dt = GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } if (request["Action"] == "Compared_empcusadd") { var idlist = PageValidate.InputText(request["idlist"].Replace(";", ",").Replace("-", ""), 100000); string dt1 = request["date1"]; string dt2 = request["date2"]; BLL.hr_post post = new BLL.hr_post(); DataSet dspost = post.GetList(" post_id in(" + idlist + ")"); string emplist = "("; for (int i = 0; i < dspost.Tables[0].Rows.Count - 1; i++) { emplist += dspost.Tables[0].Rows[i]["emp_id"] + ","; } emplist += dspost.Tables[0].Rows[dspost.Tables[0].Rows.Count - 1]["emp_id"] + ")"; //context.Response.Write(emplist); DataSet ds = customer.Compared_empcusadd(DateTime.Parse(dt1), DateTime.Parse(dt2), emplist); string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } if (request["Action"] == "emp_customer") { var idlist = PageValidate.InputText(request["idlist"].Replace(";", ",").Replace("-", ""), 100000); var syear = request["syear"]; BLL.hr_post post = new BLL.hr_post(); DataSet dspost = post.GetList("post_id in(" + idlist + ")"); string emplist = "("; for (int i = 0; i < dspost.Tables[0].Rows.Count - 1; i++) { emplist += dspost.Tables[0].Rows[i]["emp_id"] + ","; } emplist += dspost.Tables[0].Rows[dspost.Tables[0].Rows.Count - 1]["emp_id"] + ")"; //context.Response.Write(emplist); DataSet ds = customer.report_empcus(int.Parse(syear), emplist); string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpRequest request = context.Request; BLL.CRM_Follow follow = new BLL.CRM_Follow(); Model.CRM_Follow model = new Model.CRM_Follow(); BLL.hr_employee emp = new BLL.hr_employee(); int emp_id = int.Parse(request.Cookies["UserID"].Value); DataSet dsemp = emp.GetList("id=" + emp_id); string empname = dsemp.Tables[0].Rows[0]["name"].ToString(); string uid = dsemp.Tables[0].Rows[0]["uid"].ToString(); if (request["Action"] == "save") { model.Customer_id = int.Parse(request["cid"]); BLL.CRM_Customer ccc = new BLL.CRM_Customer(); string cname = ccc.GetList("id=" + model.Customer_id).Tables[0].Rows[0]["Customer"].ToString(); model.Customer_name = PageValidate.InputText(cname, 250); model.Follow = PageValidate.InputText(request["T_follow"], 4000); model.Follow_Type_id = int.Parse(request["T_followtype_val"]); model.Follow_Type = PageValidate.InputText(request["T_followtype"], 255); string fid = request["fid"]; if (!string.IsNullOrEmpty(fid) && fid != "null") { DataSet ds = follow.GetList("id=" + int.Parse(fid)); DataRow dr = ds.Tables[0].Rows[0]; model.employee_id = int.Parse(dr["employee_id"].ToString()); model.employee_name = dr["employee_name"].ToString(); model.department_id = int.Parse(dr["department_id"].ToString()); model.department_name = dr["department_name"].ToString(); model.Follow_date = DateTime.Parse(dr["Follow_date"].ToString()); model.id = int.Parse(fid); follow.Update(model); //最后跟进 ccc.UpdateLastFollow(model.Customer_id.ToString()); //日志 C_Sys_log log = new C_Sys_log(); int UserID = emp_id; string UserName = empname; string IPStreet = request.UserHostAddress; string EventTitle = model.Customer_name; string EventType = "客户跟进修改"; int EventID = model.id; if (dr["Follow"].ToString() != request["T_follow"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "跟进内容", "跟进内容被修改", "跟进内容被修改"); } if (dr["Follow_Type"].ToString() != request["T_followtype"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "跟进类型", dr["Follow_Type"].ToString(), request["T_followtype"]); } } else { model.isDelete = 0; DataRow dr1 = dsemp.Tables[0].Rows[0]; model.employee_id = int.Parse(dr1["ID"].ToString()); model.employee_name = dr1["name"].ToString(); string depid = dr1["d_id"].ToString(); if (string.IsNullOrEmpty(depid)) depid = "0"; model.department_id = int.Parse(depid); model.department_name = dr1["dname"].ToString(); model.Follow_date = DateTime.Now; int customerid = follow.Add(model); //最后跟进 ccc.UpdateLastFollow(model.Customer_id.ToString()); } if (!string.IsNullOrEmpty(request["T_content"])) { BLL.Personal_Calendar calendar = new BLL.Personal_Calendar(); Model.Personal_Calendar modelcalendar = new Model.Personal_Calendar(); int clientzone = 8; int serverzone = GetTimeZone(); var zonediff = serverzone - clientzone; modelcalendar.StartTime = DateTime.Parse(request["T_starttime"]).AddHours(zonediff); modelcalendar.EndTime = DateTime.Parse(request["T_endtime"]).AddHours(zonediff); modelcalendar.Subject = PageValidate.InputText("【" + cname + "】" + request["T_content"], 4000); modelcalendar.emp_id = int.Parse(request.Cookies["UserID"].Value); modelcalendar.UPAccount = request.Cookies["UserID"].Value; modelcalendar.UPTime = DateTime.Now; modelcalendar.MasterId = clientzone; modelcalendar.CalendarType = 1; modelcalendar.Category = "4";//跟进提醒 modelcalendar.companyid = model.Customer_id; modelcalendar.InstanceType = 0; modelcalendar.IsAllDayEvent = PageValidate.InputText(request["allday"], 255) == "True" ? true : false; calendar.Add(modelcalendar); } } if (request["Action"] == "form") { DataSet ds = follow.GetList("id=" + int.Parse(request["fid"]) + DataAuth(request.Cookies["UserID"].Value)); string dt = Common.DataToJson.DataToJSON(ds); context.Response.Write(dt); } //del if (request["Action"] == "AdvanceDelete") { string id = request["id"]; DataSet ds = follow.GetList("id=" + int.Parse(id)); bool canedel = true; if (uid != "admin") { Data.GetDataAuth dataauth = new Data.GetDataAuth(); string txt = dataauth.GetDataAuthByid("2", "Sys_del", emp_id.ToString()); string[] arr = txt.Split(':'); switch (arr[0]) { case "none": canedel = false; break; case "my": for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["employee_id"].ToString() == arr[1]) canedel = true; else canedel = false; } break; case "dep": for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["dep_id"].ToString() == arr[1]) canedel = true; else canedel = false; } break; case "all": canedel = true; break; } } if (canedel) { bool isdel = follow.AdvanceDelete(int.Parse(request["id"]), 1, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); //context.Response.Write("{success:success}"); if (isdel) { //日志 string EventType = "跟进预删除"; int UserID = emp_id; string UserName = empname; string IPStreet = request.UserHostAddress; int EventID = int.Parse(id); string EventTitle = ds.Tables[0].Rows[0]["Customer_name"].ToString(); string Original_txt = null; string Current_txt = null; C_Sys_log log = new C_Sys_log(); log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt); context.Response.Write("true"); } else { context.Response.Write("false"); } } else { context.Response.Write("delfalse"); } } //del if (request["Action"] == "del") { bool canDel = false; if (dsemp.Tables[0].Rows.Count > 0) { if (dsemp.Tables[0].Rows[0]["uid"].ToString() == "admin") { canDel = true; } else { Data.GetAuthorityByUid getauth = new Data.GetAuthorityByUid(); string delauth = getauth.GetBtnAuthority(request.Cookies["UserID"].Value, "64"); if (delauth == "false") canDel = false; else canDel = true; } } if (canDel) { string idlist = PageValidate.InputText(request["idlist"], 100000); string[] arr = idlist.Split(','); DataSet ds = follow.GetList("id in (" + idlist.Trim() + ")"); for (int i = 0; i < arr.Length; i++) { follow.Delete(int.Parse(arr[i])); } if (true) { string EventType = "彻底删除跟进"; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int UserID = emp_id; string UserName = empname; int EventID = idlist[i]; string IPStreet = request.UserHostAddress; string EventTitle = ds.Tables[0].Rows[i]["Customer_name"].ToString(); string Original_txt = null; string Current_txt = null; C_Sys_log log = new C_Sys_log(); log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt); } context.Response.Write("true"); } } else { context.Response.Write("auth"); } } //regain //需要加2 if (request["Action"] == "regain") { string idlist = PageValidate.InputText(request["idlist"], 10000); string[] arr = idlist.Split(','); DataSet ds = follow.GetList("id in (" + idlist.Trim() + ")"); bool canedel = true; if (uid != "admin") { Data.GetDataAuth dataauth = new Data.GetDataAuth(); string txt = dataauth.GetDataAuthByid("2", "Sys_del", emp_id.ToString()); string[] arr1 = txt.Split(':'); switch (arr1[0]) { case "none": canedel = false; break; case "my": for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["employee_id"].ToString() == arr1[1]) canedel = true; else canedel = false; } break; case "dep": for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["department_id"].ToString() == arr1[1]) canedel = true; else canedel = false; } break; case "all": canedel = true; break; } } if (canedel) { for (int i = 0; i < arr.Length; i++) { follow.AdvanceDelete(int.Parse(arr[i]), 0, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); } if (true) { //日志 string EventType = "恢复删除跟进"; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int UserID = emp_id; string UserName = empname; int EventID = idlist[i]; string IPStreet = request.UserHostAddress; string EventTitle = ds.Tables[0].Rows[i]["Customer_name"].ToString(); string Original_txt = null; string Current_txt = null; C_Sys_log log = new C_Sys_log(); log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt); } context.Response.Write("true"); } } else { context.Response.Write("delfalse"); } } //serch if (request["Action"] == "grid") { int PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]); int PageSize = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]); string sortname = request["sortname"]; string sortorder = request["sortorder"]; if (string.IsNullOrEmpty(sortname)) sortname = " id "; if (string.IsNullOrEmpty(sortorder)) sortorder = " desc"; string sorttext = " " + sortname + " " + sortorder; string Total; string serchtxt = null; //is delete ? if (request["isdel"] == "1") serchtxt += " isDelete=1 "; else serchtxt += " isDelete=0 "; if (!string.IsNullOrEmpty(request["customer_id"])) serchtxt += " and Customer_id=" + int.Parse(request["customer_id"]); if (!string.IsNullOrEmpty(request["company"])) serchtxt += " and Customer_name like N'%" + PageValidate.InputText(request["company"], 255) + "%'"; if (!string.IsNullOrEmpty(request["department"])) serchtxt += " and department_id = " + int.Parse(request["department_val"]); if (!string.IsNullOrEmpty(request["employee"])) serchtxt += " and employee_id = " + int.Parse(request["employee_val"]); if (!string.IsNullOrEmpty(request["followtype"])) serchtxt += " and Follow_Type_id = " + int.Parse(request["followtype_val"]); if (!string.IsNullOrEmpty(request["startdate"])) serchtxt += " and Follow_date >= '" + PageValidate.InputText(request["startdate"], 255) + "'"; if (!string.IsNullOrEmpty(request["enddate"])) { DateTime enddate = DateTime.Parse(request["enddate"]).AddHours(23).AddMinutes(59).AddSeconds(59); serchtxt += " and Follow_date <= '" + enddate + "'"; } if (!string.IsNullOrEmpty(request["startdate_del"])) serchtxt += " and Delete_time >= '" + PageValidate.InputText(request["startdate_del"], 255) + "'"; if (!string.IsNullOrEmpty(request["enddate_del"])) { DateTime enddate = DateTime.Parse(request["enddate_del"]).AddHours(23).AddMinutes(59).AddSeconds(59); serchtxt += " and Delete_time <= '" + enddate + "'"; } if (!string.IsNullOrEmpty(request["T_smart"])) { if (request["T_smart"] != "输入关键词智能搜索跟进内容") serchtxt += " and Follow like N'%" + PageValidate.InputText(request["T_smart"], 255) + "%'"; } //权限 //serchtxt += DataAuth(request.Cookies["UserID"].Value); DataSet ds = follow.GetList(PageSize, PageIndex, serchtxt, sorttext, out Total); string dt = Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], Total); context.Response.Write(dt); } if (request["Action"] == "Compared_follow") { string dt1 = request["date1"]; string dt2 = request["date2"]; DataSet ds = follow.Compared_follow(DateTime.Parse(dt1), DateTime.Parse(dt2)); string dt = GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } if (request["Action"] == "Compared_empcusfollow") { var idlist = PageValidate.InputText(request["idlist"].Replace(";", ",").Replace("-", ""), 100000); string dt1 = request["date1"]; string dt2 = request["date2"]; BLL.hr_post post = new BLL.hr_post(); DataSet dspost = post.GetList("post_id in(" + idlist + ")"); string emplist = "("; for (int i = 0; i < dspost.Tables[0].Rows.Count - 1; i++) { emplist += dspost.Tables[0].Rows[i]["emp_id"] + ","; } emplist += dspost.Tables[0].Rows[dspost.Tables[0].Rows.Count - 1]["emp_id"] + ")"; //context.Response.Write(emplist); DataSet ds = follow.Compared_empcusfollow(DateTime.Parse(dt1), DateTime.Parse(dt2), emplist); string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } if (request["Action"] == "emp_cusfollow") { var idlist = PageValidate.InputText(request["idlist"].Replace(";", ",").Replace("-", ""), 1000000); var syear = request["syear"]; BLL.hr_post post = new BLL.hr_post(); DataSet dspost = post.GetList("post_id in(" + idlist + ")"); string emplist = "("; for (int i = 0; i < dspost.Tables[0].Rows.Count - 1; i++) { emplist += dspost.Tables[0].Rows[i]["emp_id"] + ","; } emplist += dspost.Tables[0].Rows[dspost.Tables[0].Rows.Count - 1]["emp_id"] + ")"; //context.Response.Write(emplist); DataSet ds = follow.report_empfollow(int.Parse(syear), emplist); string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpRequest request = context.Request; BLL.hr_post post = new BLL.hr_post(); Model.hr_post model = new Model.hr_post(); BLL.hr_employee emp = new BLL.hr_employee(); Model.hr_employee modelemp = new Model.hr_employee(); int emp_id = int.Parse(request.Cookies["UserID"].Value.ToString()); DataSet dsemp = emp.GetList("id=" + emp_id); string empname = dsemp.Tables[0].Rows[0]["name"].ToString(); string uid = dsemp.Tables[0].Rows[0]["uid"].ToString(); if (request["Action"] == "grid") { string depid = request["depid"]; string emps = request["empstatus"]; int empstuats = 0; if (!string.IsNullOrEmpty(emps)) { empstuats = Common.PageValidate.IsNumber(request["empstatus"]) ? int.Parse(request["empstatus"]) : 0; } string serchtxt = ""; switch (empstuats) { case 0: serchtxt += "1=1 "; break; case 1: serchtxt += "emp_id=-1 "; break; case 2: serchtxt += "emp_id!=-1 "; break; } if (!string.IsNullOrEmpty(depid) && depid != "null") serchtxt += " and dep_id=" + int.Parse(depid); string serchtype = request["isdel"]; if (serchtype == "1") serchtxt += " and isDelete=1"; else serchtxt += " and isDelete=0 "; DataSet ds = post.GetList(0, serchtxt, " convert(int,[position_order])"); string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } if (request["Action"] == "save") { //dep model.dep_id = int.Parse(request["T_depname_val"]); model.depname = Common.PageValidate.InputText(request["T_depname"], 250); //name model.post_name = Common.PageValidate.InputText(request["T_postname"], 250); //position model.position_id = int.Parse(request["T_position_val"]); model.position_name = Common.PageValidate.InputText(request["T_position"], 250); model.position_order = Common.PageValidate.InputText(request["T_position_leavel"], 50); //emp int empid = Common.PageValidate.IsNumber(request["T_emp_val"]) ? int.Parse(request["T_emp_val"]) : -1; model.emp_id = empid; model.emp_name = Common.PageValidate.InputText(request["T_emp"], 250); //note model.note = Common.PageValidate.InputText(request["T_descript"], 4000); //更新员工岗位 modelemp.d_id = model.dep_id; modelemp.dname = model.depname; modelemp.post = model.post_name; modelemp.zhiwuid = model.position_id; modelemp.zhiwu = model.position_name; modelemp.ID = empid; string postid = request["postid"]; if (!string.IsNullOrEmpty(postid) && postid != "null") { model.post_id = int.Parse(postid); DataSet ds = post.GetList(" post_id=" + int.Parse(postid)); DataRow dr = null; if (ds.Tables[0].Rows.Count > 0) { dr = ds.Tables[0].Rows[0]; //判断默认岗位 if (model.emp_id == -1) { model.default_post = 0; } else { DataSet ds1 = post.GetList(string.Format("default_post=1 and emp_id={0} and post_id!={1}", model.emp_id, int.Parse(postid))); if (ds1.Tables[0].Rows.Count > 0) model.default_post = 0; //此员工有默认岗位 else { model.default_post = 1; //设置此岗位为此员工默认岗位 //更新员工岗位 modelemp.postid = model.post_id; emp.UpdatePost(modelemp); } } } post.Update(model); //日志 C_Sys_log log = new C_Sys_log(); int UserID = emp_id; string UserName = empname; string IPStreet = request.UserHostAddress; string EventTitle = model.position_name; string EventType = "岗位修改"; int EventID = model.post_id; if (dr["post_name"].ToString() != request["T_postname"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "岗位名称", dr["post_name"].ToString(), request["T_postname"]); } if (dr["position_name"].ToString() != request["T_position"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "岗位级别", dr["position_name"].ToString(), request["T_position"]); } if (dr["emp_name"].ToString() != request["T_emp"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "岗位员工", dr["emp_name"].ToString(), request["T_emp"]); } if (dr["note"].ToString() != request["T_descript"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "描述", dr["note"].ToString(), request["T_descript"]); } } else { model.isDelete = 0; postid= post.Add(model).ToString(); //判断默认岗位 if (model.emp_id == -1) { model.default_post = 0; } else { DataSet ds1 = post.GetList(string.Format("default_post=1 and emp_id={0} and post_id!={1}", model.emp_id, int.Parse(postid))); if (ds1.Tables[0].Rows.Count > 0) model.default_post = 0; //此员工有默认岗位 else { model.default_post = 1; //设置此岗位为此员工默认岗位 //更新员工岗位 modelemp.postid = int.Parse(postid); emp.UpdatePost(modelemp); } } post.UpdatePostEmp(model); } BLL.CRM_Customer customer = new BLL.CRM_Customer(); Model.CRM_Customer cmodel = new Model.CRM_Customer(); cmodel.Department_id = model.dep_id; cmodel.Department = model.depname; cmodel.Employee_id = model.emp_id; customer.UpdateToPost(cmodel); } //Form JSON if (request["Action"] == "form") { int postid = int.Parse(request["postid"]); BLL.hr_post hp = new BLL.hr_post(); DataSet ds = hp.GetList("post_id=" + postid); string dt = Common.DataToJson.DataToJSON(ds); context.Response.Write(dt); } //del if (request["Action"] == "AdvanceDelete") { string postid = request["id"]; string EventType = "岗位预删除"; DataSet ds = post.GetList(" post_id=" + int.Parse(postid)); if (ds.Tables[0].Rows[0]["emp_id"].ToString()!="-1") { //含有员工信息不能删除 context.Response.Write("false:emp"); } else { bool isdel = post.AdvanceDelete(int.Parse(postid), 1, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); if (isdel) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int UserID = emp_id; string UserName = empname; string IPStreet = request.UserHostAddress; int EventID = int.Parse(postid); string EventTitle = ds.Tables[0].Rows[i]["post_name"].ToString(); string Original_txt = null; string Current_txt = null; C_Sys_log log = new C_Sys_log(); log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt); } context.Response.Write("true"); } else { context.Response.Write("false"); } } } if (request["Action"] == "regain") { string idlist = Common.PageValidate.InputText(request["idlist"], 100000); string[] arr = idlist.Split(','); DataSet ds = post.GetList("post_id in (" + idlist.Trim() + ")"); for (int i = 0; i < arr.Length; i++) { post.AdvanceDelete(int.Parse(arr[i]), 0, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); } if (true) { //日志 string EventType = "恢复删除岗位"; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int UserID = emp_id; string UserName = empname; int EventID = idlist[i]; string IPStreet = request.UserHostAddress; string EventTitle = ds.Tables[0].Rows[i]["post_name"].ToString(); string Original_txt = null; string Current_txt = null; C_Sys_log log = new C_Sys_log(); log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt); } context.Response.Write("true"); } } if (request["Action"] == "del") { bool canDel = false; if (dsemp.Tables[0].Rows.Count > 0) { if (dsemp.Tables[0].Rows[0]["uid"].ToString() == "admin") { canDel = true; } else { Data.GetAuthorityByUid getauth = new Data.GetAuthorityByUid(); string delauth = getauth.GetBtnAuthority(request.Cookies["UserID"].Value, "82"); if (delauth == "false") canDel = false; else canDel = true; } } if (canDel) { string idlist = Common.PageValidate.InputText(request["idlist"], 1000000); string[] arr = idlist.Split(','); string EventType = "彻底删除岗位"; DataSet ds = post.GetList("post_id in (" + idlist.Trim() + ")"); for (int i = 0; i < arr.Length; i++) { post.Delete(int.Parse(arr[i])); } if (true) { //日志 for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int UserID = emp_id; string UserName = empname; string IPStreet = request.UserHostAddress; int EventID = idlist[i]; string EventTitle = ds.Tables[0].Rows[0]["post_name"].ToString(); string Original_txt = null; string Current_txt = null; C_Sys_log log = new C_Sys_log(); log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt); } context.Response.Write("true"); } } else { context.Response.Write("auth"); } } //get post by empid if (request["Action"] == "getpostbyempid") { BLL.hr_post hp = new BLL.hr_post(); int empid = int.Parse(request["empid"]); DataSet ds = hp.GetList(" isDelete=0 and emp_id=" + empid); if (ds.Tables[0].Rows.Count > 0) { string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } } //serch if (request["Action"] == "serch") { BLL.hr_post hp = new BLL.hr_post(); string serchtxt = Common.PageValidate.InputText(request["Serchtext"], 255); DataSet ds = hp.GetList(" isDelete=0 and post_name like N'%" + serchtxt + "%'"); if (ds.Tables[0].Rows.Count > 0) { string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } else { context.Response.Write("post_name like N'%" + serchtxt + "%'"); } } //post_emp if (request["Action"] == "postemp") { string json = request["PostData"].ToLower(); JavaScriptSerializer js = new JavaScriptSerializer(); PostData[] postdata; postdata = js.Deserialize<PostData[]>(json); BLL.hr_post hp = new BLL.hr_post(); string empid = request["empid"]; int Eid = -1; if (!string.IsNullOrEmpty(empid)) { Eid = Common.PageValidate.IsNumber(empid) ? int.Parse(empid) : -1; } model.emp_id = Eid; modelemp.ID = Eid; model.emp_name = Common.PageValidate.InputText(request["emp_name"], 255); for (int i = 0; i < postdata.Length; i++) { model.post_id = postdata[i].Post_id; model.default_post = postdata[i].Default_post; if (postdata[i].Default_post == 1) { modelemp.d_id = postdata[i].Dep_id; modelemp.dname = postdata[i].Depname; modelemp.zhiwuid = postdata[i].Position_id; modelemp.zhiwu = postdata[i].Position_name; modelemp.postid = postdata[i].Post_id; modelemp.post = postdata[i].Post_name; //context.Response.Write(postdata[i].Depname + "@"); emp.UpdatePost(modelemp); } hp.UpdatePostEmp(model); } } //combo if (request["Action"] == "combo") { int postid = int.Parse(request["postid"]); DataSet ds = post.GetList(" isDelete=0 and dep_id=" + postid); StringBuilder str = new StringBuilder(); str.Append("["); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { str.Append("{id:" + ds.Tables[0].Rows[i]["post_id"].ToString() + ",text:'" + ds.Tables[0].Rows[i]["post_name"] + "'},"); } str.Replace(",", "", str.Length - 1, 1); str.Append("]"); context.Response.Write(str); } }