Exemplo n.º 1
0
        /// <summary>
        /// 保存教师信息
        /// </summary>
        /// <param name="isContinueAdd">isContinueAdd=true:连续保存</param>
        private void DoSave(bool isContinueAdd)
        {
            if (!NetUtil.CheckNetWork(CurrActivity))
            {
                ToastUtil.ShowWarningToast(CurrActivity, "网络未连接!");
                return;
            }
            try
            {
                var tcode  = et_teachercode.Text.Trim();
                var tname  = et_teachername.Text.Trim();
                var temail = et_teacheramount.Text.Trim();
                if (string.IsNullOrEmpty(tcode))
                {
                    ToastUtil.ShowWarningToast(this, "请输入教师编码");
                    et_teachercode.RequestFocus();
                    return;
                }
                if (string.IsNullOrEmpty(temail))
                {
                    ToastUtil.ShowWarningToast(this, "请输入登录账号");
                    et_teacheramount.RequestFocus();
                    return;
                }
                if (!CheckUtil.IsValidEmail(temail))
                {
                    ToastUtil.ShowWarningToast(this, "登录账号应为邮箱");
                    et_teacheramount.RequestFocus();
                    return;
                }
                if (string.IsNullOrEmpty(tname))
                {
                    ToastUtil.ShowWarningToast(this, "请输入姓名");
                    et_teachername.RequestFocus();
                    return;
                }
                if (tScopeCode == 0)
                {
                    ToastUtil.ShowWarningToast(this, "请选择教研组");
                    return;
                }
                if (tType == 0)
                {
                    ToastUtil.ShowWarningToast(this, "请选择角色");
                    return;
                }


                LoadingDialogUtil.ShowLoadingDialog(this, "保存中...");

                new Thread(new ThreadStart(() =>
                {
                    //新增操作
                    var model      = new ManagerUserInfo();
                    model.Code     = tcode;
                    model.Email    = temail;
                    model.Name     = tname;
                    model.UserType = tType;
                    if (model.UserType == (int)UserType.TeacherDirector || model.UserType == (int)UserType.TeacherArea)
                    {
                        model.IsCanLogin = true;
                    }
                    else
                    {
                        model.IsCanLogin = false;
                    }
                    model.SchoolId = CurrUserInfo.SchoolId;
                    model.Creator  = CurrUserInfo.Name;
                    model.Modifier = CurrUserInfo.Name;

                    DataEntity.Result resultData;

                    if (isNewAdd)
                    {
                        resultData = _meService.AddManagerUser(model, "", "", tScopeCode);
                    }
                    else
                    {
                        resultData = _meService.UpdateManagerUser(model, "", "", tScopeCode);
                    }

                    RunOnUiThread(() =>
                    {
                        LoadingDialogUtil.DismissLoadingDialog();
                        if (resultData.State == 1)
                        {
                            ToastUtil.ShowSuccessToast(this, "操作成功");

                            currTeacher.Name      = tname;
                            currTeacher.Email     = temail;
                            currTeacher.Code      = tcode;
                            currTeacher.ScopeCode = tScopeCode;
                            currTeacher.Type      = tType;
                            if (BaseApplication.GetInstance().teacherList != null)
                            {
                                if (isNewAdd)
                                {
                                    BaseApplication.GetInstance().teacherList.Add(currTeacher);
                                }
                                else
                                {
                                    if (scopeName != currTeacher.ScopeName)
                                    {
                                        BaseApplication.GetInstance().teacherList.Remove(currTeacher);
                                    }
                                }
                            }


                            //保存并继续添加爱
                            if (isContinueAdd)
                            {
                                currTeacher           = new TeacherListModel();
                                et_teachercode.Text   = "";
                                et_teachername.Text   = "";
                                et_teacheramount.Text = "";
                                tvRoleLabel.Text      = "未设置";
                                tvRoleLabel.SetTextColor(new Color(ContextCompat.GetColor(CurrActivity, Resource.Color.textColorSecond)));
                                tvScoleLabel.Text = "未设置";
                                tvScoleLabel.SetTextColor(new Color(ContextCompat.GetColor(CurrActivity, Resource.Color.textColorSecond)));
                            }
                            //完成
                            else
                            {
                                new Handler().PostDelayed(() =>
                                {
                                    Finish();
                                    OverridePendingTransition(Resource.Animation.left_in, Resource.Animation.right_out);
                                }, 1000);
                            }
                        }
                        else
                        {
                            ToastUtil.ShowErrorToast(this, (string.IsNullOrEmpty(resultData.Error) ? "操作失败" : resultData.Error));
                        }
                    });
                })).Start();
            }
            catch (Exception ex)
            {
                var msg = ex.Message.ToString();
                ToastUtil.ShowErrorToast(this, "操作失败");
                LoadingDialogUtil.DismissLoadingDialog();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 保存教师信息
        /// </summary>
        /// <param name="isContinueAdd">isContinueAdd=true:连续保存</param>
        private void DoSave(bool isContinueAdd)
        {
            if (!NetUtil.CheckNetWork(CurrActivity))
            {
                ToastUtil.ShowWarningToast(CurrActivity, "网络未连接!");
                return;
            }
            try
            {
                currAssistant.Name   = etName.Text.Trim();
                currAssistant.Mobile = etAmount.Text.Trim();
                if (string.IsNullOrEmpty(currAssistant.Name))
                {
                    ToastUtil.ShowWarningToast(this, "请输入姓名");
                    etName.RequestFocus();
                    return;
                }

                if (!Helper.IsMobile(currAssistant.Mobile))
                {
                    ToastUtil.ShowWarningToast(this, "请输入正确的手机号");
                    etAmount.RequestFocus();
                    return;
                }
                if (string.IsNullOrEmpty(currAssistant.AreaCode))
                {
                    ToastUtil.ShowWarningToast(this, "请选择教学区");
                    etAmount.RequestFocus();
                    return;
                }

                LoadingDialogUtil.ShowLoadingDialog(this, "保存中...");

                new Thread(new ThreadStart(() =>
                {
                    //新增操作
                    var model        = new ManagerUserInfo();
                    model.Mobile     = currAssistant.Mobile;
                    model.Name       = currAssistant.Name;
                    model.IsCanLogin = false;
                    model.UserType   = (int)UserType.AssistantLeader;
                    model.SchoolId   = CurrUserInfo.SchoolId;
                    model.Creator    = CurrUserInfo.Name;
                    model.Modifier   = CurrUserInfo.Name;
                    var resultData   = _meService.AddManagerUser(model, currAssistant.AreaCode, currAssistant.AreaName, 0);

                    RunOnUiThread(() =>
                    {
                        LoadingDialogUtil.DismissLoadingDialog();
                        if (resultData.State == 1)
                        {
                            ToastUtil.ShowSuccessToast(this, "操作成功");
                            //保存并继续添加爱
                            if (isContinueAdd)
                            {
                                currAssistant = new AstLeaderListModel();
                                etName.Text   = "";
                                etAmount.Text = "";
                                tvArea.Text   = "未设置";
                                tvArea.SetTextColor(new Color(ContextCompat.GetColor(CurrActivity, Resource.Color.textColorSecond)));
                            }
                            //完成
                            else
                            {
                                new Handler().PostDelayed(() =>
                                {
                                    Finish();
                                    OverridePendingTransition(Resource.Animation.left_in, Resource.Animation.right_out);
                                }, 1000);
                            }
                        }
                        else
                        {
                            ToastUtil.ShowErrorToast(this, (string.IsNullOrEmpty(resultData.Error) ? "操作失败" : resultData.Error));
                        }
                    });
                })).Start();
            }
            catch (Exception ex)
            {
                var msg = ex.Message.ToString();
                ToastUtil.ShowErrorToast(this, "操作失败");
            }
            finally
            {
                LoadingDialogUtil.DismissLoadingDialog();
            }
        }