Ejemplo n.º 1
0
        private void Btn_counselUpdate_Click(object sender, EventArgs e)
        {
            Boolean       state  = true;
            Counsel_table usrTbl = new Counsel_table();
            Crypt         crypt  = mind.GetCrypt();
            string        passwd = crypt.Encrypt(txt_counselorPasswd.Text);

            usrTbl.ID       = id;
            usrTbl.Subject  = txt_clientSubject.Text;
            usrTbl.Memo     = crypt.Encrypt(txt_clientMemo.Text);
            usrTbl.Comment  = txt_Comment.Text;
            usrTbl.Comdate  = DateTime.Now;
            usrTbl.MemberID = int.Parse(txt_counselorID.Text);

            if (txt_clientSubject.Text.Length == 0)
            {
                MessageBox.Show("제목을 입력하세요\r(Enter the subject)", "알림(Alert)", MessageBoxButtons.OK, MessageBoxIcon.Information);
                state = false;
            }

            if (txt_clientMemo.Text.Length == 0 &&
                state == true)
            {
                MessageBox.Show("내용을 입력하세요\r(Enter the memo)", "알림(Alert)", MessageBoxButtons.OK, MessageBoxIcon.Information);
                state = false;
            }

            if (txt_counselorPasswd.Text.Length == 0 &&
                state == true)
            {
                MessageBox.Show("상담자 비밀번호를 입력하세요\r(Enter the counselor password)", "알림(Alert)", MessageBoxButtons.OK, MessageBoxIcon.Information);
                state = false;
            }

            if (mind.CheckPassword(passwd) == false &&
                state == true)
            {
                MessageBox.Show("비밀번호가 일치하지 않습니다.\r(Mismatch password.)", "알림(Alert)", MessageBoxButtons.OK, MessageBoxIcon.Information);
                state = false;
            }

            // 추가 Query
            if (state == true)
            {
                string query = "UPDATE counsel_table set subject = @subject, " +
                               "memo = @memo, comment = @comment, comdate = @comdate where id = @id";

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = query;
                cmd.Parameters.Add("@subject", MySqlDbType.VarChar, 50);
                cmd.Parameters.Add("@memo", MySqlDbType.Text);
                cmd.Parameters.Add("@comment", MySqlDbType.Text);
                cmd.Parameters.Add("@comdate", MySqlDbType.DateTime);
                cmd.Parameters.Add("@id", MySqlDbType.Int32, 11);

                cmd.Parameters[0].Value = usrTbl.Subject;
                cmd.Parameters[1].Value = usrTbl.Memo;
                cmd.Parameters[2].Value = crypt.Encrypt(usrTbl.Comment);
                cmd.Parameters[3].Value = DateTime.Now;
                cmd.Parameters[4].Value = counsel_Table.ID;

                mind.InsertUpdate(cmd);
                MessageBox.Show("성공적으로 수정되었습니다.\r(Successfully updated.)",
                                "알림(Alert)", MessageBoxButtons.OK, MessageBoxIcon.Information);


                this.Close();
                var myParent = (DetailShowFrm)this.Owner;
                myParent.ParentMethod();
            }
        }
Ejemplo n.º 2
0
        private void Btn_counselSubmit_Click(object sender, EventArgs e)
        {
            Boolean state  = true;
            Crypt   crypt  = mind.GetCrypt();
            string  passwd = crypt.Encrypt(txt_counselorPasswd.Text);

            Counsel_table counsel_Table = new Counsel_table();

            counsel_Table.Subject   = this.txt_clientSubject.Text;
            counsel_Table.Memo      = crypt.Encrypt(this.txt_clientMemo.Text);
            counsel_Table.Firstdate = DateTime.Now;
            counsel_Table.ClientID  = int.Parse(txt_clientID.Text);
            counsel_Table.MemberID  = int.Parse(txt_counselorID.Text);

            //MessageBox.Show(passwd);
            //MessageBox.Show( mind.CheckPassword(passwd).ToString() );

            if (txt_clientSubject.Text.Length == 0)
            {
                MessageBox.Show("제목을 입력하세요\r(Enter the subject)", "알림(Alert)", MessageBoxButtons.OK, MessageBoxIcon.Information);
                state = false;
            }

            if (txt_clientMemo.Text.Length == 0 &&
                state == true)
            {
                MessageBox.Show("내용을 입력하세요\r(Enter the memo)", "알림(Alert)", MessageBoxButtons.OK, MessageBoxIcon.Information);
                state = false;
            }

            if (txt_counselorPasswd.Text.Length == 0 &&
                state == true)
            {
                MessageBox.Show("상담자 비밀번호를 입력하세요\r(Enter the counselor password)", "알림(Alert)", MessageBoxButtons.OK, MessageBoxIcon.Information);
                state = false;
            }

            if (mind.CheckPassword(passwd) == false &&
                state == true)
            {
                MessageBox.Show("비밀번호가 일치하지 않습니다.\r(Mismatch password.)", "알림(Alert)", MessageBoxButtons.OK, MessageBoxIcon.Information);
                state = false;
            }

            // 추가 Query
            if (state == true)
            {
                string query = "INSERT INTO counsel_table(subject, memo, " +
                               "firstdate, comment, comdate, clientID, memberID) VALUES(" +
                               "@subject, @memo, @firstdate, @comment, @comdate, @clientID, @memberID)";

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = query;
                cmd.Parameters.Add("@subject", MySqlDbType.VarChar, 50);
                cmd.Parameters.Add("@memo", MySqlDbType.Text);
                cmd.Parameters.Add("@firstdate", MySqlDbType.DateTime);
                cmd.Parameters.Add("@comment", MySqlDbType.Text);
                cmd.Parameters.Add("@comdate", MySqlDbType.DateTime);
                cmd.Parameters.Add("@clientID", MySqlDbType.Int32, 11);
                cmd.Parameters.Add("@memberID", MySqlDbType.Int32, 11);

                cmd.Parameters[0].Value = counsel_Table.Subject;
                cmd.Parameters[1].Value = counsel_Table.Memo;
                cmd.Parameters[2].Value = counsel_Table.Firstdate;
                cmd.Parameters[3].Value = null;
                cmd.Parameters[4].Value = null;
                cmd.Parameters[5].Value = counsel_Table.ClientID;
                cmd.Parameters[6].Value = counsel_Table.MemberID;

                mind.InsertUpdate(cmd);
                MessageBox.Show("성공적으로 등록되었습니다.\r(Successfully registered.)",
                                "알림(Alert)", MessageBoxButtons.OK, MessageBoxIcon.Information);

                this.Close();

                var myParent = (MainFrm)this.Owner;
                myParent.ParentMethod();
            }
        }
Ejemplo n.º 3
0
        private void Btn_Update_Click(object sender, EventArgs e)
        {
            Boolean state  = true;
            Crypt   crypt  = mind.GetCrypt();
            string  passwd = crypt.Encrypt(txt_strPasswd.Text);

            Member member = new Member();

            member.SetName(txt_Name.Text);
            member.SetEmail(txt_Email.Text);
            member.SetBirthDate(dtp_birthdate.Value);
            member.SetPhone(txt_Phone.Text);
            member.SetFamilytype(cmb_familyType.GetItemText(this.cmb_familyType.SelectedItem));

            if (member.GetName().Length == 0)
            {
                MessageBox.Show("이름을 입력하세요\r(Enter the userName)", "알림(Alert)", MessageBoxButtons.OK, MessageBoxIcon.Information);
                state = false;
            }

            if (member.GetEmail().Length == 0 && state == true)
            {
                MessageBox.Show("이메일을 입력하세요\r(Enter the email)", "알림(Alert)", MessageBoxButtons.OK, MessageBoxIcon.Information);
                state = false;
            }

            if (txt_strPasswd.Text.Length == 0 &&
                state == true)
            {
                MessageBox.Show("상담자 비밀번호를 입력하세요\r(Enter the counselor password)", "알림(Alert)", MessageBoxButtons.OK, MessageBoxIcon.Information);
                state = false;
            }

            if (mind.CheckPassword(passwd) == false &&
                state == true)
            {
                MessageBox.Show("비밀번호가 일치하지 않습니다.\r(Mismatch password.)", "알림(Alert)", MessageBoxButtons.OK, MessageBoxIcon.Information);
                state = false;
            }

            if (state == true)
            {
                string query = "Update member set name = @name, " +
                               "email = @email, " +
                               "birthdate = @birthdate, phone = @phone, " +
                               "type = @type where id = @id and password = @password";

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = query;

                cmd.Parameters.Add("@name", MySqlDbType.VarChar, 50);
                cmd.Parameters.Add("@email", MySqlDbType.VarChar, 100);
                cmd.Parameters.Add("@birthdate", MySqlDbType.DateTime);
                cmd.Parameters.Add("@phone", MySqlDbType.VarChar, 20);
                cmd.Parameters.Add("@type", MySqlDbType.VarChar, 20);
                cmd.Parameters.Add("@id", MySqlDbType.Int32, 11);
                cmd.Parameters.Add("@password", MySqlDbType.Text);

                cmd.Parameters[0].Value = member.GetName();
                cmd.Parameters[1].Value = member.GetEmail();
                cmd.Parameters[2].Value = member.GetBirthDate();
                cmd.Parameters[3].Value = member.GetPhone();
                cmd.Parameters[4].Value = member.GetFamilytype();
                cmd.Parameters[5].Value = member.GetID();
                cmd.Parameters[6].Value = member.GetPasswd();

                mind.InsertUpdate(cmd);
                MessageBox.Show("성공적으로 수정되었습니다.\r(It has been successfully modified.)",
                                "알림(Alert)", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }