Exemple #1
0
        //------------------------------------------------------------
        // 검색 버튼
        //------------------------------------------------------------
        private void btnSearch_Click(object sender, System.EventArgs e)
        {
            try
            {
                LocalConn.Open();

                string sql = "select * from AddrBook ";
                sql += " where name like '%" + txtSearchName.Text + "%'";

                OleDbDataReader myReader = Common_DB.DataSelect(sql, LocalConn);

                if (myReader != null)
                {
                    DataLoad(myReader);
                    myReader.Close();
                }
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.ToString());
                Log.WriteLine("FrmListView", e1.ToString());
            }
            finally
            {
                LocalConn.Close();
            }
        }
Exemple #2
0
        //--------------------------------------------------------
        // 메인화면 로딩시 처리되는 부분
        //--------------------------------------------------------

        private void FrmListView_Load(object sender, EventArgs e)
        {
            OleDbDataReader myReader = null;

            try
            {
                //--------------------------------------------
                LocalConn = Common_DB.DBConnection();
                //--------------------------------------------
                LocalConn.Open();
                myReader = Common_DB.DataSelect("select * from AddrBook ", LocalConn);
                DataLoad(myReader);

                //Combo Box 채우기
                comSex.Items.Add("남자");
                comSex.Items.Add("여자");
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.ToString());
                Log.WriteLine("FrmListView", e1.ToString());
            }
            finally
            {
                if (!myReader.IsClosed)
                {
                    myReader.Close();
                    myReader = null;
                }
                LocalConn.Close();
            }
        }
Exemple #3
0
        //-----------------------------
        //DataGridView에 데이터 채우기
        //-----------------------------
        private void LoadData()
        {
            try
            {
                string sql = "select * from addrbook";

                LocalConn = Common_DB.DBConnection();
                LocalConn.Open();
                adapter = new OleDbDataAdapter(sql, LocalConn);
                cb      = new OleDbCommandBuilder(adapter);

                adapter.DeleteCommand = cb.GetDeleteCommand();
                adapter.InsertCommand = cb.GetInsertCommand();
                adapter.UpdateCommand = cb.GetUpdateCommand();

                ds = new DataSet();
                adapter.Fill(ds, "ADDRBOOK");

                dataGrid1.DataSource = ds.Tables["ADDRBOOK"];
            }
            catch (Exception e1)
            {
                MessageBox.Show("주소록 저장 오류~" + e1.ToString());
                Log.WriteLine("FrmDataGridView", e1.ToString());
            }
            finally
            {
                LocalConn.Close();
            }
        }
Exemple #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            OleDbDataReader myReader;
            string          sql = null;

            try
            {
                LocalConn = Common_DB.DBConnection();
                LocalConn.Open();

                if (txtID.Text == "" || txtPWD.Text == "")
                {
                    MessageBox.Show("ID 또는 Password를 입력 하세요...");
                    return;
                }

                sql  = "select pwd from member ";
                sql += " where id = " + "'" + txtID.Text + "'";

                myReader = Common_DB.DataSelect(sql, LocalConn);

                if (myReader.Read())
                {
                    if (txtPWD.Text != myReader["pwd"].ToString())
                    {
                        MessageBox.Show("Password가 맞지 않습니다...");
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("등록되지 않은 ID 입니다.");
                    return;
                }

                //----------- ID가 PWD가 맞는 경우
                FrmMDIMain m = new FrmMDIMain();
                m.Show();
                //m.Owner = this;
                //---------------------------------
                this.Hide();
                Log.WriteLine("FrmLogin", "[로그인 :" + txtID.Text + "]");
            }
            catch (Exception e1)
            {
                Log.WriteLine("FrmLogin", e1.ToString());
                Log.WriteLine("FrmLogin", sql);
                MessageBox.Show("FrmLogin", "로그인 오류! " + sql);
            }
        }
Exemple #5
0
        //-------------------------------------------------------------
        // 입력 버튼
        //-------------------------------------------------------------
        private void btnInput_Click(object sender, System.EventArgs e)
        {
            if (txtName.Text == "" || txtTel.Text == "")
            {
                MessageBox.Show("성명, 전화번호는 필수 입력사항 입니다.");
                txtName.Focus();
                return;
            }

            string gubun;

            if (comSex.Text == "남자")
            {
                gubun = "M";
            }
            else
            {
                gubun = "F";
            }

            try
            {
                LocalConn.Open();

                string sql = "Insert Into AddrBook (Name, Sex, Addr, Tel) values(";
                sql += "'" + txtName.Text + "'" + ",";
                sql += "'" + gubun + "'" + ",";
                sql += "'" + txtAddr.Text + "'" + ",";
                sql += "'" + txtTel.Text + "'" + ")";

                if (Common_DB.DataManupulation(sql, LocalConn))
                {
                    OleDbDataReader myReader = Common_DB.DataSelect("select * from AddrBook", LocalConn);
                    DataLoad(myReader);
                    Log.WriteLine("FrmListView", "데이터 한건 입력(" + txtName + "," + txtTel + ")");
                    MessageBox.Show("정상적으로 입력 되었습니다...");
                }
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.ToString());
                Log.WriteLine("FrmListView", e1.ToString());
            }
            finally
            {
                LocalConn.Close();
            }
        }
Exemple #6
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            OleDbDataReader myReader;
            string          sql = null;

            try
            {
                localConn = Common_DB.DBConnection();
                localConn.Open();

                if (txtID.Text == "" || txtPWD.Text == "")
                {
                    MessageBox.Show("ID 또는 PWD를 입력하세요");
                }

                sql  = "select pwd from member";
                sql += " where id=" + "'" + txtID.Text + "'";

                myReader = Common_DB.DataSelect(sql, localConn);

                if (myReader.Read())
                {
                    if (txtPWD.Text != myReader["pwd"].ToString())
                    {
                        MessageBox.Show("pwd가 맞지 않습니다");
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("ID가 맞지 않습니다");
                    return;
                }

                FrmMDIMain m = new FrmMDIMain();
                m.Show();

                this.Hide();
                Log.WriteLine("frmlogin", "[login :"******"]");
            }
            catch (Exception e1)
            {
                Log.WriteLine("frmlogin", e1.ToString());
                Log.WriteLine("frmlogin", sql);
                MessageBox.Show("frmlogin", "로그인 오류 : " + sql);
            }
        }
Exemple #7
0
        //-------------------------------------------------------------
        // 수정 버튼 클릭시 DB에 Update 하는 부분
        //-------------------------------------------------------------
        private void btnUpdate_Click(object sender, System.EventArgs e)
        {
            if (txtName.Text == "" || txtTel.Text == "")
            {
                MessageBox.Show("성명, 전화번호는 필수 입력사항 입니다.");
                txtName.Focus();
                return;
            }

            string gubun;

            if (comSex.Text == "남자")
            {
                gubun = "M";
            }
            else
            {
                gubun = "F";
            }

            try
            {
                LocalConn.Open();
                string myExecuteQuery = "Update AddrBook set Name='" + txtName.Text + "'" + ",";
                myExecuteQuery += " Addr = '" + txtAddr.Text + "'" + ",";
                myExecuteQuery += " Sex = '" + gubun + "'" + ",";
                myExecuteQuery += " Tel = '" + txtTel.Text + "'";
                myExecuteQuery += " where Name = " + "'" + txtName.Text + "'";

                if (Common_DB.DataManupulation(myExecuteQuery, LocalConn))
                {
                    OleDbDataReader myReader = Common_DB.DataSelect("select * from AddrBook", LocalConn);
                    DataLoad(myReader);
                    MessageBox.Show(" 정상적으로 수정 되었습니다...");
                }
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.ToString());
                Log.WriteLine("FrmListView", e1.ToString());
            }
            finally
            {
                LocalConn.Close();
            }
        }
Exemple #8
0
        //------------------------------------------------------
        // Refresh 버튼
        //------------------------------------------------------
        private void btnRefresh_Click(object sender, System.EventArgs e)
        {
            try
            {
                LocalConn.Open();

                OleDbDataReader myReader = Common_DB.DataSelect("select * from AddrBook", LocalConn);
                DataLoad(myReader);
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.ToString());
                Log.WriteLine("FrmListView", e1.ToString());
            }
            finally
            {
                LocalConn.Close();
            }
        }
Exemple #9
0
        //-------------------------------------------------------------
        // 삭제 버튼 클릭시 DB에 Update 하는 부분
        //-------------------------------------------------------------
        private void btnDelete_Click(object sender, System.EventArgs e)
        {
            OleDbDataReader myReader = null;

            if (txtName.Text == "" || txtTel.Text == "")
            {
                MessageBox.Show("성명, 전화번호는 필수 입력사항 입니다.");
                txtName.Focus();
                return;
            }

            //-------------------------------- 삭제 확인
            if (MessageBox.Show("정말 삭제 하시겠습니까?", "삭제확인",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                != DialogResult.Yes)
            {
                return;
            }

            try
            {
                LocalConn.Open();
                string myExecuteQuery = "Delete AddrBook ";
                myExecuteQuery += " where Name = " + "'" + txtName.Text + "'";

                if (Common_DB.DataManupulation(myExecuteQuery, LocalConn))
                {
                    myReader = Common_DB.DataSelect("select * from AddrBook", LocalConn);
                    DataLoad(myReader);
                    MessageBox.Show(" 정상적으로 삭제 되었습니다...");
                }
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.ToString());
                Log.WriteLine("FrmListView", e1.ToString());
            }
            finally
            {
                LocalConn.Close();
            }
        }