예제 #1
0
        public Message InsertOrUpdateManager(MANAGER_VO mv)
        {
            try
            {
                string  sql = "SP_SaveUser";
                AESSalt aes = new AESSalt();
                using (SqlConnection conn = new SqlConnection(this.ConnectionString))
                {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand(sql, conn))
                    {
                        cmd.CommandType = System.Data.CommandType.StoredProcedure;
                        //cmd.Parameters.AddWithValue("@P_MANAGER_ID", mv.MANAGER_ID);
                        cmd.Parameters.AddWithValue("@P_MANAGER_NAME", mv.MANAGER_NAME);
                        cmd.Parameters.AddWithValue("@P_MANAGER_PSWD", aes.Encrypt(mv.MANAGER_PSWD));
                        cmd.Parameters.AddWithValue("@P_MANAGER_EML", mv.MANAGER_EML);
                        cmd.Parameters.AddWithValue("@P_MANAGER_DEP", mv.MANAGER_DEP);

                        cmd.Parameters.Add(new SqlParameter("@P_MANAGER_ID", System.Data.SqlDbType.NVarChar, 20));
                        cmd.Parameters["@P_MANAGER_ID"].Value     = mv.MANAGER_ID;
                        cmd.Parameters["@P_MANAGER_ID"].Direction = System.Data.ParameterDirection.Input;
                        cmd.Parameters.Add(new SqlParameter("@P_ReturnCode", System.Data.SqlDbType.NVarChar, 5));
                        cmd.Parameters["@P_ReturnCode"].Direction = System.Data.ParameterDirection.Output;
                        cmd.ExecuteNonQuery();
                        conn.Close();

                        string result = cmd.Parameters["@P_ReturnCode"].Value.ToString();

                        Message message = new Message();
                        if (result == "M01")
                        {
                            message.IsSuccess     = true;
                            message.ResultMessage = "성공적으로 등록되었습니다.";
                        }
                        else if (result == "M02")
                        {
                            message.IsSuccess     = true;
                            message.ResultMessage = "성공적으로 수정되었습니다.";
                        }
                        else if (result == "M03")
                        {
                            message.IsSuccess     = false;
                            message.ResultMessage = "이미 등록된 ID 입니다.";
                        }
                        else if (result == "M04")
                        {
                            message.IsSuccess     = false;
                            message.ResultMessage = "이미 등록된 EMAIL 입니다.";
                        }

                        return(message);
                    }
                }
            }
            catch (Exception err)
            {
                return(new Message(err));
            }
        }
예제 #2
0
        public Message InsertOrUpdateManager(MANAGER_VO mv)
        {
            LoginDAC dac = new LoginDAC();

            return(dac.InsertOrUpdateManager(mv));
        }
예제 #3
0
        /// <summary>
        /// 회원 등록 버튼 클릭시 발생하는 이벤트
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            //ID중복검사여부 확인
            if (!bIDCheck)
            {
                MessageBox.Show("ID의 유효성 검사는 필수입니다.", "ID 중복검사", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            //값 입력 확인
            bool          isemptyTextExist = false;
            StringBuilder sb = new StringBuilder();

            foreach (var item in pnlContents.Controls)
            {
                if (item is TextBox)
                {
                    TextBox tb = item as TextBox;
                    if (tb.Text.Trim().Length < 1)
                    {
                        isemptyTextExist = true;
                        sb.AppendFormat($"<{tb.Tag.ToString()}>");
                    }
                }
            }
            if (isemptyTextExist)
            {
                MessageBox.Show(sb.ToString() + "항목을 입력해주세요.");
                return;
            }


            bool bPwdCheck  = ValidCheck.VaildText(ValidCheck.ContentTypes.Password, txtPwd.Text.Trim());
            bool bPwd2Check = (txtPwd.Text == txtPwdCheck.Text);
            bool bNameCheck = ValidCheck.VaildText(ValidCheck.ContentTypes.이름, txtName.Text.Trim());
            bool bEMLCheck  = ValidCheck.VaildText(ValidCheck.ContentTypes.Email, txtEML.Text.Trim());

            if (bIDCheck && bPwdCheck && bPwd2Check && bNameCheck && bEMLCheck)
            {
                MANAGER_VO mv = new MANAGER_VO
                {
                    MANAGER_ID = txtID.Text.Trim()
                    ,
                    MANAGER_NAME = txtName.Text.Trim()
                    ,
                    MANAGER_PSWD = txtPwd.Text.Trim()
                    ,
                    MANAGER_EML = txtEML.Text.Trim()
                    ,
                    MANAGER_DEP = cboDept.Text
                };

                //서비스호출
                LoginService service = new LoginService();
                Message      msg     = service.InsertOrUpdateManager(mv);
                if (msg.IsSuccess)
                {
                    MessageBox.Show(msg.ResultMessage);
                    this.Close();
                }
                else
                {
                    MessageBox.Show(msg.ResultMessage);
                    return;
                }
            }
            else
            {
                MessageBox.Show("유효한 값이 아닙니다. 입력항목들을 확인해주세요.", "입력값 확인", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
        }