Example #1
0
        protected void btnSave_Click(object sender, ImageClickEventArgs e)
        {
            if (action == "new")
            {
                UserProfileBLL  bll = new UserProfileBLL();
                UserProfileInfo up  = GetUserInfo();

                if (!bll.IsExist(up))
                {
                    if (bll.CreateUserProfile(up))
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "", "<script>AlertAndNewLoad('添加成功');</script>");
                    }
                    else
                    {
                        ExecAlertScritp("添加失败!");
                    }
                }
                else
                {
                    ExecAlertScritp("用户已存在");
                }
            }
            else if (action == "edit")
            {
                UserProfileBLL  bll = new UserProfileBLL();
                UserProfileInfo up  = bll.GetUserProfile(UserCode);
                UserProfileInfo upi = GetUserInfo();
                upi.ID = up.ID;

                bll.UpdateUserProfile(up);


                using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope())
                {
                    //添加扩展属性值
                    for (int i = 0; i < dlExtendInfo.Items.Count; i++)
                    {
                        HiddenField hfId     = dlExtendInfo.Items[i].FindControl("hfPropertyID") as HiddenField;
                        TextBox     txtValue = dlExtendInfo.Items[i].FindControl("txtPropertyValue") as TextBox;
                        if (hfId != null && txtValue != null)
                        {
                            //DBManager.AddExtValue(hfId.Value, txtValue.Text, UserCode);
                            bll.AddExtValue(hfId.Value, txtValue.Text, UserCode);
                        }
                    }
                    ts.Complete();  //提交事务
                }


                if (ddlMainDept.SelectedItem != null)
                {
                    if (bll.UpdateMainDepartment(UserCode, ddlMainDept.SelectedItem.Value))
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "", "<script>AlertAndNewLoad('操作成功');</script>");
                    }
                    else
                    {
                        ExecAlertScritp("操作失败!");
                    }
                }
            }
        }