Esempio n. 1
0
        /// <summary>
        /// 修改联系电话
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private ResponeDataEntity SetContact(HttpContext context, JObject ob)
        {
            string            snumber      = ob["sNumber"].ToString();
            string            password     = ob["password"].ToString();
            string            cPhone       = ob["cPhone"].ToString();
            string            cPhoneName   = ob["cPhoneName"].ToString();
            string            cPhone2      = ob["cPhone2"].ToString();
            string            cPhone3      = ob["cPhone3"].ToString();
            string            cPhone4      = ob["cPhone4"].ToString();
            ResponeDataEntity resultEntity = new ResponeDataEntity();

            logHelper.logInfo(" SetContact params:sNumber:" + snumber + " cPhone:" + cPhone + " cPhone2:" + cPhone2 + "cPhone3:" + cPhone3 + " cPhone4:" + cPhone4);
            //获取学生对象
            Daiv_OA.Entity.StudentEntity stuEntity = stubll.GetEntityByNumber(snumber);
            if (stuEntity == null)
            {
                return new ResponeDataEntity()
                       {
                           Status = 0, Msg = snumber + "学生学号无效!"
                       }
            }
            ;
            string uid = new Daiv_OA.BLL.UserBLL().Existslongin(snumber, Daiv_OA.Utils.MD5.Lower32(password));

            if (string.IsNullOrEmpty(uid))
            {
                return(new ResponeDataEntity()
                {
                    Status = 0, Msg = snumber + "输入密码无效!"
                });
            }
            //Daiv_OA.Entity.ContactEntity ctEntity = ctbll.GetEntityBySid(stuEntity.Sid);

            //电话号码验证
            //if (!string.IsNullOrEmpty(cPhone) && !Validator.IsMobileNum(cPhone)) { resultEntity.Msg = cPhone+"电话号码无效!"; return resultEntity; };
            //if (!string.IsNullOrEmpty(cPhone2) && !Validator.IsMobileNum(cPhone2)) { resultEntity.Msg = cPhone2 + "电话号码无效!"; return resultEntity; };
            //if (!string.IsNullOrEmpty(cPhone3) && !Validator.IsMobileNum(cPhone3)) { resultEntity.Msg = cPhone3 + "电话号码无效!"; return resultEntity; };
            //if (!string.IsNullOrEmpty(cPhone4) && !Validator.IsMobileNum(cPhone4)) { resultEntity.Msg = cPhone4 + "电话号码无效!"; return resultEntity; };
            ////保存数据
            //if (ctEntity == null)
            //{
            //    ctEntity = new ContactEntity() { Sid = stuEntity.Sid };
            //    ctEntity.Cphone = cPhone;
            //    ctEntity.Cphone2 = cPhone2;
            //    ctEntity.Cphone3 = cPhone3;
            //    ctEntity.Cphone4 = cPhone4;
            //    ctbll.Add(ctEntity);
            //    return new ResponeDataEntity() { Status = 1, Msg = snumber + "修改成功!" };
            //}
            //ctEntity.Cphone = cPhone;
            //ctEntity.Cphone2 = cPhone2;
            //ctEntity.Cphone3 = cPhone3;
            //ctEntity.Cphone4 = cPhone4;
            //ctbll.Update(ctEntity);
            string[] cPhoneArr  = cPhone.Split(',');
            string[] cPhonenArr = cPhoneName.Split(',');
            List <Entity.ContactEntity> contactList = new List <Entity.ContactEntity>();

            for (int i = 0; i < cPhoneArr.Length; i++)
            {
                if (string.IsNullOrEmpty(cPhoneArr[i]) || string.IsNullOrEmpty(cPhoneArr[i]))
                {
                    continue;
                }
                //验证电话号码
                if (!string.IsNullOrEmpty(cPhoneArr[i]) && !Validator.IsMobileNum(cPhoneArr[i]))
                {
                    resultEntity.Msg = cPhoneArr[i] + "电话号码无效!"; return(resultEntity);
                }
                ;
                contactList.Add(new Entity.ContactEntity()
                {
                    Cphone = cPhoneArr[i], CPhoneName = cPhonenArr[i]
                });
            }
            //ctbll.DeleteBySid(stuEntity.Sid);
            ////联系电话实体添加
            //foreach (var item in contactList)
            //{
            //    item.Sid = stuEntity.Sid;
            //    ctbll.Add(item);
            //}
            ctbll.AddBatch(contactList, stuEntity.Sid);
            return(new ResponeDataEntity()
            {
                Status = 1, Msg = snumber + "修改成功!"
            });
        }