Exemple #1
0
 private void BindData()
 {
     var newmodel = PersonManager.GetPersonByPerId(Convert.ToInt32(Cookie.getCookie("PerId")));
     if (newmodel != null)
     {
         model = newmodel;
     }
 }
 private void BindData()
 {
     int perId = -1;
     if(!Int32.TryParse(Request["id"],out perId)){
         Response.Redirect("AdComp.aspx");
     }
     perId = Convert.ToInt32(Request["id"]);
     //读取企业信息
     model = PersonManager.GetPersonByPerId(perId);
     if (model == null)
     {
         Response.Redirect("AdComp.aspx");
     }
     if (model.PerAudit != 1)
     {
         Response.Redirect("AdComp.aspx");
     }
 }
Exemple #3
0
 private string UpdatePerComp()
 {
     if (string.IsNullOrEmpty(Request["perId"]))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ParaError), "参数错误");
     }
     var perComp = Request["perComp"];
     if (string.IsNullOrEmpty(perComp))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写企业名称");
     }
     if (!Validator.IsStringLength(perComp, 0, 100))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "企业名称有误");
     }
     var perType = Request["perType"];
     if (string.IsNullOrEmpty(perType))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请选择养殖品种");
     }
     var perName = Request["perName"];
     if (string.IsNullOrEmpty(perName))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写联系人");
     }
     if (!Validator.IsStringLength(perComp, 0, 30))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "联系人有误");
     }
     var perTel = Request["perTel"];
     if (string.IsNullOrEmpty(perTel))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写联系电话");
     }
     if (perTel.Length < 3 || perTel.Length > 40)
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "联系电话格式错误");
     }
     var perMail = Request["perMail"];
     if (!string.IsNullOrEmpty(perMail) && !Validator.IsEmail(perMail))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "电子邮箱格式错误");
     }
     var perAddr = Request["perAddr"];
     if (string.IsNullOrEmpty(perAddr))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写经营地点");
     }
     var perUser = Request["perUser"];
     if (string.IsNullOrEmpty(perUser))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写用户名");
     }
     var perLimit = Request["perLimit"];
     if (!Validator.IsNumber(perLimit))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请选择禁限养区");
     }
     var perLsmj = Request["perLsmj"];
     if (string.IsNullOrEmpty(perLsmj))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写栏舍面积");
     }
     if (!Validator.IsNumber(perLsmj))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "栏舍面积必须填写数字");
     }
     var perXntd = Request["perXntd"];
     if (string.IsNullOrEmpty(perXntd))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写消纳土地");
     }
     if (!Validator.IsNumber(perXntd))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "消纳土地必须填写数字");
     }
     var perZqc = Request["perZqc"];
     if (string.IsNullOrEmpty(perZqc))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写沼气池");
     }
     if (!Validator.IsNumber(perZqc))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "沼气池必须填写数字");
     }
     var perCdc = Request["perCdc"];
     if (string.IsNullOrEmpty(perCdc))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写沉淀池");
     }
     if (!Validator.IsNumber(perCdc))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "沉淀池必须填写数字");
     }
     var perGfdj = Request["perGfdj"];
     if (string.IsNullOrEmpty(perGfdj))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写干粪堆积");
     }
     if (!string.IsNullOrEmpty(perGfdj) && !Validator.IsNumber(perGfdj))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "干粪堆积必须填写数字");
     }
     var perPwd = Request["perPwd"];
     if(!string.IsNullOrEmpty(perPwd)){
         if (!Validator.IsStringLength(perPwd, 6, 16))
         {
             return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请输入6-16位的密码");
         }
         if (perUser.ToLower().Equals(perPwd.ToLower()))
         {
             return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "用户名和密码不能相同");
         }
         perPwd=HashEncode.MD5(perPwd);
     }
     Person model = new Person()
     {
         PerId = Convert.ToInt32(Request["perId"]),
         PerComp = StrUtils.SqlFilterStr(StrUtils.RemoveHtml(perComp)),
         PerType = perType,
         PerName = StrUtils.SqlFilterStr(StrUtils.RemoveHtml(perName)),
         PerTel = perTel,
         PerMail = perMail,
         PerAddr = StrUtils.SqlFilterStr(StrUtils.RemoveHtml(perAddr)),
         PerUser =StrUtils.SqlFilterStr(StrUtils.RemoveHtml(perUser)),
         PerPwd = perPwd,
         PerLimit = Convert.ToByte(perLimit),
         PerLsmj = Convert.ToDouble(perLsmj),
         PerXntd = Convert.ToDouble(perXntd),
         PerZqc = Convert.ToDouble(perZqc),
         PerCdc = Convert.ToDouble(perCdc),
         PerGfdj = Convert.ToDouble(perGfdj)
     };
     try
     {
         PersonManager.UpdatePerson(model);
     }
     catch (Exception)
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.Fail), "更新企业信息失败");
     }
     return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.Success), "更新企业信息成功");
 }
Exemple #4
0
        /// <summary>
        /// 添加企业信息 2015.10.11 cbl
        /// </summary>
        /// <returns></returns>
        private string UpdatePerComp()
        {
            var perComp = Request["perComp"];
            if (string.IsNullOrEmpty(perComp))
            {
                return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写企业名称");
            }
            if (!Validator.IsStringLength(perComp, 0, 100))
            {
                return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "企业名称有误");
            }
            var perType = Request["perType"];
            if (string.IsNullOrEmpty(perType))
            {
                return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请选择养殖品种");
            }
            var perName = Request["perName"];
            if (string.IsNullOrEmpty(perName))
            {
                return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写联系人");
            }
            if (!Validator.IsStringLength(perComp, 0, 30))
            {
                return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "联系人有误");
            }
            var perTel = Request["perTel"];
            if (string.IsNullOrEmpty(perTel))
            {
                return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写联系电话");
            }
            if (perTel.Length < 3 || perTel.Length > 40)
            {
                return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "联系电话格式错误");
            }
            //if (!Validator.IsPhoneNumber(perTel))
            //{
            //    return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "联系电话格式错误");
            //}
            var perMail = Request["perMail"];
            if (!string.IsNullOrEmpty(perMail)&&!Validator.IsEmail(perMail))
            {
                return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "电子邮箱格式错误");
            }
            var perAddr = Request["perAddr"];
            if (string.IsNullOrEmpty(perAddr))
            {
                return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写经营地点");
            }
            var perLimit = Request["perLimit"];
            if (!Validator.IsNumber(perLimit))
            {
                return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError),"请选择禁限养区");
            }
            var perLsmj = Request["perLsmj"];
            if (string.IsNullOrEmpty(perLsmj))
            {
                return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写栏舍面积");
            }
            if (!Validator.IsNumber(perLsmj))
            {
                return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "栏舍面积必须填写数字");
            }
            var perXntd = Request["perXntd"];
            if (string.IsNullOrEmpty(perXntd))
            {
                return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写消纳土地");
            }
            if (!Validator.IsNumber(perXntd))
            {
                return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "消纳土地必须填写数字");
            }
            var perZqc = Request["perZqc"];
            if (string.IsNullOrEmpty(perZqc))
            {
                return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写沼气池");
            }
            if (!Validator.IsNumber(perZqc))
            {
                return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "沼气池必须填写数字");
            }
            var perCdc = Request["perCdc"];
            if (string.IsNullOrEmpty(perCdc))
            {
                return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写沉淀池");
            }
            if (!Validator.IsNumber(perCdc))
            {
                return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "沉淀池必须填写数字");
            }
            var perGfdj = Request["perGfdj"];
            if (string.IsNullOrEmpty(perGfdj))
            {
                return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写干粪堆积");
            }
            if (!string.IsNullOrEmpty(perGfdj) && !Validator.IsNumber(perGfdj))
            {
                return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "干粪堆积必须填写数字");
            }

            Person model = new Person()
            {
                PerId = Convert.ToInt32(Cookie.getCookie("PerId")),
                PerComp = StrUtils.SqlFilterStr(StrUtils.RemoveHtml(perComp)),
                PerType=perType,
                PerName=StrUtils.SqlFilterStr(StrUtils.RemoveHtml(perName)),
                PerTel = perTel,
                PerMail = perMail,
                PerAddr = perAddr,
                PerLimit = Convert.ToByte(perLimit),
                PerLsmj = Convert.ToDouble(perLsmj),
                PerXntd = Convert.ToDouble(perXntd),
                PerZqc = Convert.ToDouble(perZqc),
                PerCdc = Convert.ToDouble(perCdc),
                PerGfdj = Convert.ToDouble(perGfdj)
            };
            try
            {
                PersonManager.UpdatePerson(model);
                SetCookieUser(model.PerId.ToString(),model.PerComp,model.PerName,model.PerUser);
            }
            catch (Exception)
            {
                return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.Fail), "更新企业信息失败");
            }
            return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.Success), "更新企业信息成功");
        }
Exemple #5
0
 /// <summary>
 /// 用户注册
 /// </summary>
 /// <returns></returns>
 private string RegisterPerMgr()
 {
     var perUser = Request["perUser"];
     if (string.IsNullOrEmpty(perUser))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请输入用户名");
     }
     if (!Validator.IsStringLength(perUser,4, 16))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请输入4-16位的用户名");
     }
     var perPwd = Request["perPwd"];
     if (string.IsNullOrEmpty(perPwd))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请输入密码");
     }
     if (!Validator.IsStringLength(perPwd, 6, 16))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请输入6-16位的密码");
     }
     if (perUser.ToLower().Equals(perPwd.ToLower()))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "用户名和密码不能相同");
     }
     var imgCode = Request["imgCode"];
     if (string.IsNullOrEmpty(imgCode))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请输入验证码");
     }
     if (!imgCode.ToLower().Equals(Session["ImgCheckCode"]))
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "验证码有误");
     }
     var date=DateTime.Now;
     Person model = new Person()
     {
         PerUser=StrUtils.SqlFilterStr(StrUtils.RemoveHtml(perUser)),
         PerPwd = HashEncode.MD5(perPwd),
         PerRTime = date,
         PerUTime=date,
         PerLTime=date,
         PerClass="pig"
     };
     string msg = "用户注册失败";
     try
     {
         if (PersonManager.InsertPerson(model,out msg))
         {
             SetCookieUser(model.PerId.ToString(), model.PerComp, model.PerName,model.PerUser);
             return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.Success), "用户注册成功");
         }
     }
     catch (Exception)
     {
         return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.Fail), "用户注册失败");
     }
     return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.Fail), msg);
 }