Пример #1
0
        public CounselMemo(object v1)
        {
            if (v1 != null)
            {
                this.id = ((Counsel_table)v1).ID;
                mind    = new MindController();
                Crypt crypt = mind.GetCrypt();

                InitializeComponent();

                this.counsel_Table = mind.GetCounsel_Table(id);
                this.client        = mind.GetMember(counsel_Table.ClientID);
                this.counselor     = mind.GetMember(counsel_Table.MemberID);

                // 피내담자(고객)
                this.txt_clientID.Text    = client.GetID().ToString();
                this.txt_clientName.Text  = client.GetName().ToString();
                this.txt_clientPhone.Text = client.GetPhone().ToString();

                // 상담자
                this.txt_counselorID.Text    = counselor.GetID().ToString();
                this.txt_counselorName.Text  = counselor.GetName().ToString();
                this.txt_counselorPhone.Text = counselor.GetPhone().ToString();

                // 내용
                this.txt_clientSubject.Text = counsel_Table.Subject;
                this.txt_clientMemo.Text    = counsel_Table.Memo;
                this.lbl_firstdate.Text     = counsel_Table.Firstdate.ToString();

                // 코멘트
                this.txt_Comment.Text = crypt.Decrypt(counsel_Table.Comment.ToString());
                this.lbl_comdate.Text = counsel_Table.Comdate.ToString();
            }
        }
Пример #2
0
        private void Btn_counselMemo_Click(object sender, EventArgs e)
        {
            Boolean state  = true;
            Crypt   crypt  = mind.GetCrypt();
            string  passwd = crypt.Encrypt(txt_strPasswd.Text);

            Counsel_table counsel_Table = new Counsel_table();

            counsel_Table.ID = int.Parse(dataGridView.Rows[dataGridView.CurrentCellAddress.Y].Cells[0].Value.ToString());

            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;
            }

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

            // state가 true일 때
            if (state == true)
            {
                counselMemoFrm       = new CounselMemo((object)counsel_Table);
                counselMemoFrm.Owner = this;
                counselMemoFrm.ShowDialog();
            }
        }
Пример #3
0
        public Counsel_table GetCounsel_Table(int id)
        {
            Counsel_table   counsel_Table = new Counsel_table();
            MySqlConnection conn;
            string          strconn = GetStrConn();
            string          query   = "select * from counsel_table where id = @id";

            // MySQL = 스타일1
            conn = new MySqlConnection(strconn);
            conn.Open();

            //본인의 DB이름
            MySqlCommand cmd = new MySqlCommand
            {
                Connection  = conn,
                CommandText = query
            };

            cmd.Parameters.Add("@id", MySqlDbType.Int32);
            cmd.Parameters[0].Value = id;

            MySqlDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                counsel_Table.ID        = int.Parse(rdr["id"].ToString());
                counsel_Table.Subject   = rdr["subject"].ToString();
                counsel_Table.Memo      = crypt.Decrypt(rdr["memo"].ToString()); // 암호 해독
                counsel_Table.Firstdate = (DateTime)rdr["firstdate"];
                counsel_Table.Comment   = rdr["comment"].ToString();

                try
                {
                    counsel_Table.Comdate = (DateTime)rdr["comdate"];
                }
                catch (Exception e)
                {
                    e.Message.ToString();
                }
                counsel_Table.ClientID = int.Parse(rdr["clientID"].ToString());
                counsel_Table.MemberID = int.Parse(rdr["memberID"].ToString());
            }

            conn.Close();

            return(counsel_Table);
        }
Пример #4
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();
            }
        }
Пример #5
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();
            }
        }