Пример #1
0
 public void editAddButton_Click(object sender, EventArgs e)
 {
     try
     {
         if (editNameTextbox.Text != "" && editNumTextbox.Text != "")
         {
             mainForm.insert_updateTool("update add_user set name ='" + editNameTextbox.Text + "',phone_num ='" + editNumTextbox.Text + "',job ='" + editJobTextbox.Text + "',email='" + editEmailTextbox.Text + "',memo='" + editMemoTextbox.Text + "'where name ='" + mainForm.name + "'");
             mainForm.dataLoad();
             MessageBox.Show("수정 완료!");
         }
         else if (editNameTextbox.Text == "")
         {
             MessageBox.Show("이름을 입력해주세요!");
         }
         else if (editNumTextbox.Text == "")
         {
             MessageBox.Show("전화번호를 입력해주세요!");
         }
     }
     catch
     {
         MessageBox.Show("연락처 변경 실패 - 정보를 정확히 입력해주세요!");
     }
     this.Close();
 }
Пример #2
0
        public void addAddButton_Click(object sender, EventArgs e)
        {
            int number = 0;

            /* DB에 연락처 저장 */
            if (mainForm.count < 100)
            {
                string date       = DateTime.Now.ToString("yyyyMMdd");
                string addNumText = addNumberTextbox.Text;
                //int callnum = 0;
                try
                {
                    if (addNameTextbox.Text == "")
                    {
                        MessageBox.Show("이름을 입력해주세요!");
                    }

                    else if (int.TryParse(addNumberTextbox.Text, out number) == true)
                    {
                        conn.Open();
                        if (addNumText.Substring(0, 1) == "0")
                        {
                            String       sql = "INSERT INTO add_user(name,phone_num,job,email,memo)" + "VALUES ('" + addNameTextbox.Text + "','" + "0" + number.ToString() + "','" + addJobTextbox.Text + "','" + addEmailTextbox.Text + "','" + addMemoTextbox.Text + "')";
                            MySqlCommand cmd = new MySqlCommand(sql, conn);
                            cmd.ExecuteNonQuery();
                        }
                        else
                        {
                            String       sql = "INSERT INTO add_user(name,phone_num,job,email,memo)" + "VALUES ('" + addNameTextbox.Text + "','" + number.ToString() + "','" + addJobTextbox.Text + "','" + addEmailTextbox.Text + "','" + addMemoTextbox.Text + "')";
                            MySqlCommand cmd = new MySqlCommand(sql, conn);
                            cmd.ExecuteNonQuery();
                        }
                        conn.Close();
                        mainForm.dataLoad();
                        mainForm.phone_num();
                    }
                    else
                    {
                        MessageBox.Show("전화번호는 숫자로 입력해주세요!");
                    }
                }
                catch { MessageBox.Show("같은 데이터가 존재하거나 문자를 잘못 입력하셨어요!"); }
            }
            else
            {
                MessageBox.Show("전화번호부가 가득 찼어요!");
            }
            this.Close();
        }