Exemplo n.º 1
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();
            }
        }
Exemplo n.º 2
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();
            }
        }
Exemplo n.º 3
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();
            }
        }