public ActionResult UserBinding(FormCollection collection) { WechatUserInfo CurrentWechatUserInfo = Session["WechatUserInfo"] as WechatUserInfo; string LastUser = ""; if (CurrentWechatUserInfo != null) { LastUser = CurrentWechatUserInfo.openid; } else { return(Content("长时间未操作,系统已自动退出,请从微信公众号菜单重新进入!")); } try { // Save BindingInfo User user = new User(); user.UserID = CurrentWechatUserInfo.UserID; user.EmpNo = collection.GetValue("EmpNo").AttemptedValue.Trim(); user.CompanyID = collection.GetValue("CompanyID").AttemptedValue.Trim(); user.StoreID = collection.GetValue("StoreID").AttemptedValue.Trim(); user.Active = "1"; //is exists if (string.IsNullOrEmpty(user.EmpNo) || user.EmpNo == "") { return(Content("请填写工号!")); } if (string.IsNullOrEmpty(user.CompanyID) || user.CompanyID == "") { return(Content("请选择公司!")); } if (string.IsNullOrEmpty(user.StoreID) || user.StoreID == "") { return(Content("请选择所在!")); } DataAPI.BasicDataController dtc = new DataAPI.BasicDataController(); string checkBinding = ""; checkBinding = dtc.CheckBindingUser(user); if (checkBinding == "1") { return(Content("该工号已被绑定,请检查!")); } if (checkBinding == "2") { return(Content("查不到该工号的信息,无法绑定,请联系系统管理员!")); } if (dtc.AddBindingUser(user, LastUser) == "1") { return(Content("1")); } else { return(Content("绑定失败!")); } } catch { return(Content("-1")); } }
public ActionResult UserBinding(FormCollection bindingInfo) { string LastUser = ""; if (CurrentWechatUserInfo != null) { LastUser = CurrentWechatUserInfo.openid; } else { return(Content("长时间未操作,系统已自动退出,请从微信公众号菜单重新进入!")); } try { // Save Cusotmer User bindUser = new User(); bindUser.CompanyID = bindingInfo.GetValue("CompanyID").AttemptedValue.Trim(); bindUser.StoreID = bindingInfo.GetValue("StoreID").AttemptedValue.Trim(); bindUser.EmpNo = bindingInfo.GetValue("EmpNo").AttemptedValue.Trim(); bindUser.UserID = CurrentWechatUserInfo.UserID; if (string.IsNullOrEmpty(bindUser.CompanyID) || bindUser.CompanyID == "") { return(Content("请选择你要绑定的公司!")); } if (string.IsNullOrEmpty(bindUser.StoreID) || bindUser.StoreID == "") { return(Content("请选择绑定的分部!")); } if (string.IsNullOrEmpty(bindUser.EmpNo) || bindUser.EmpNo == "") { return(Content("请输入你的工号!")); } DataAPI.BasicDataController dtc = new DataAPI.BasicDataController(); //获取导入绑定基础信息,由用户维护。 if (dtc.CheckBindingUser(bindUser.CompanyID, bindUser.EmpNo) == false) { return(Content("改工号已被绑定,请检查!")); } if (dtc.BindUser(bindUser, LastUser) == "1") { return(Content("1")); } else { return(Content("保存失败!")); } } catch { return(Content("-1")); } }