コード例 #1
0
        private void sb_ok_Click(object sender, EventArgs e)
        {
            //数据校验
            string s_uc002   = txtedit_uc002.Text;
            string s_uc003   = txtedit_uc003.Text;
            string s_uc004   = txtedit_pwd.Text;
            string s_uc004_2 = txtedit_pwd2.Text;

            if (String.IsNullOrEmpty(s_uc002))
            {
                txtedit_uc002.ErrorImageOptions.Alignment = ErrorIconAlignment.MiddleRight;
                txtedit_uc002.ErrorText = "登录代码必须输入!";
                txtedit_uc002.Focus();
                return;
            }

            if (String.IsNullOrEmpty(s_uc003))
            {
                txtedit_uc003.ErrorImageOptions.Alignment = ErrorIconAlignment.MiddleRight;
                txtedit_uc003.ErrorText = "姓名必须输入!";
                txtedit_uc003.Focus();
                return;
            }

            if (this.swapdata["action"].ToString() == "add")
            {
                if (String.IsNullOrEmpty(s_uc004))
                {
                    txtedit_pwd.ErrorImageOptions.Alignment = ErrorIconAlignment.MiddleRight;
                    txtedit_pwd.ErrorText = "密码必须输入!";
                    txtedit_pwd.Focus();
                    return;
                }
                else if (!String.Equals(s_uc004, s_uc004_2))
                {
                    txtedit_pwd2.ErrorImageOptions.Alignment = ErrorIconAlignment.MiddleRight;
                    txtedit_pwd2.ErrorText = "密码不一致!";
                    txtedit_pwd2.Focus();
                    return;
                }
            }


            /////// 保存过程 ///////
            uc01.uc002 = txtedit_uc002.Text;
            uc01.uc003 = txtedit_uc003.Text;

            List <string> ro001_list = new List <string>();

            foreach (DataRowView item in clbx_roles.CheckedItems)
            {
                ro001_list.Add(item["ro001"].ToString());
            }

            if (this.swapdata["action"].ToString() == "add")
            {
                uc01.uc001 = MiscAction.GetEntityPK("UC01");
                uc01.uc004 = Tools.EncryptWithMD5(s_uc004);
                if (MiscAction.CreateOperator(uc01, ro001_list.ToArray()) > 0)
                {
                    Tools.msg(MessageBoxIcon.Information, "提示", "保存成功!");
                    DialogResult = DialogResult.OK;
                    this.Close();
                }
            }
            else
            {
                if (MiscAction.UpdateOperator(uc01, ro001_list.ToArray()) > 0)
                {
                    Tools.msg(MessageBoxIcon.Information, "提示", "保存成功!");
                    DialogResult = DialogResult.OK;
                    this.Close();
                }
            }
        }