예제 #1
0
        public void add(ParentBindInfoModel parentbindinfo)
        {
            SqlConnection cn = null;
            SqlTransaction tc = null;
            try
            {
                cn = DbHelperSQL.getConnection();
                tc = DbHelperSQL.startTransaction(cn);

                //执行新增写进数据库
                parentbindinfoDal.add(cn, tc, parentbindinfo);

                DbCacheHelper.UpdateCache<StudentParentDto>("StudentParentV", cn, tc);

                DbHelperSQL.commitTransaction(tc);
            }
            catch (Exception dalEx)
            {
                DbHelperSQL.rollBackTransaction(tc);
                throw new MakeException(ExpSort.数据库, dalEx.Message);
            }
            finally
            {
                DbHelperSQL.closeConnection(cn);
            }
        }
예제 #2
0
 public bool update(SqlConnection cn, SqlTransaction tc, ParentBindInfoModel model)
 {
     return DbHelperSQL.updateModel<ParentBindInfoModel>(model, "ParentBindInfo", "OpenId", model.OpenId, "'", cn, tc);
 }
예제 #3
0
 public bool add(SqlConnection cn, SqlTransaction tc, ParentBindInfoModel model)
 {
     return DbHelperSQL.insertModel<ParentBindInfoModel>(model, "ParentBindInfo", cn, tc);
 }
예제 #4
0
    protected void ParentBindClick(object sender, EventArgs e)
    {
        IList<QueryModel> qmList = new List<QueryModel>();
        var parentPhone = MakeUtil.getStringFromRequestByName(Request, "ParentPhone", -1);
        var studentName = MakeUtil.getStringFromRequestByName(Request, "StudentName", -1);
        var identityName = MakeUtil.getStringFromRequestByName(Request, "IdentityName", -1);

        //        if (ParentBindInfoModel.OpenId.Length > 0)
        //        {
        //            Script.alertMsg("绑定失败!你的公众号已经绑定了一个手机号码,不能重复绑定", Page);
        //            return;
        //        }
        if (identityName.Trim() == "")
        {
            Script.alertMsg("请输入您的称呼", Page);
            return;
        }
        if (ParentBindInfoModels.Any(p => p.DS_Name == studentName))
        {
            Script.alertMsg(string.Format("绑定失败!你的公众号已经绑定了{0},不能重复绑定", studentName), Page);
            return;
        }
        //家长的绑定是先用家长的电话检测一下是否存在了学生信息
        qmList.Add(MakeUtil.getQueryModel("DS_Tele", "'", SqlWhere.WhereOperator.Equal, parentPhone));
        qmList.Add(MakeUtil.getQueryModel("DS_Name", "'", SqlWhere.WhereOperator.Equal, studentName));
        var stus = _isjDepartStaffEbi.getModelList(qmList, -1);
        if (stus.Count == 0)
        {
            //如果不存在则绑定失败
            Script.alertMsg("绑定失败!查找不到相关的学生信息,请仔细确认所填写的手机号码和学生姓名", Page);
            return;
        }

        var student = stus.FirstOrDefault();
        qmList.Clear();
        qmList.Add(MakeUtil.getQueryModel("StuentUId", "'", SqlWhere.WhereOperator.Equal, student.DS_UID));
        qmList.Add(MakeUtil.getQueryModel("IdentityName", "'", SqlWhere.WhereOperator.Equal, identityName));
        if (_parentBindInfoEbi.getModelList(qmList, 1).Count > 0)
        {
            //如果存在则绑定失败
            Script.alertMsg(string.Format("绑定失败!{0}同学的{1}称呼已被注册,请选择其他的称呼", studentName, identityName), Page);
            return;
        }

        //如果存在便将家长的电话与openid保存在BingingInformation(暂定)表中
        var pbim = new ParentBindInfoModel();
        pbim.OpenId = OpenId;
        pbim.Phone = parentPhone;
        pbim.StuentUId = student.DS_UID;
        try
        {
            _parentBindInfoEbi.add(pbim);
            DbCacheHelper.UpdateCache<StudentParentDto>("StudentParentV");
            MakeUtil.addOperationNote(Request.UserHostAddress, "微信前台", "家长微信绑定", OpenId + ":" + parentPhone);
            Script.alertMsg("绑定成功", Page);
            Script.scriptRedirect(Request.RawUrl, Page);
        }
        catch (Exception ex)
        {
            Script.alertMsg(ex.Message, Page);
            return;
        }
    }