コード例 #1
0
        private void btn_delete_Click(object sender, EventArgs e)
        {
            int count = dataGridView1.SelectedRows.Count;

            if (count != 0)
            {
                int result = Convert.ToInt32(MessageBox.Show("آیا  مطمئن هستید", "توجه", MessageBoxButtons.YesNo));
                try
                {
                    if (result == 6)
                    {
                        foroushande = new Foroushande();
                        while (count != 0)
                        {
                            id = Int32.Parse(dataGridView1.SelectedRows[--count].Cells[0].Value.ToString());
                            foroushande.delete(id);
                        }
                        showData();
                        txt_name.Text              = "";
                        txt_family.Text            = "";
                        txt_shomareShenasname.Text = "";
                        txt_birthday.Text          = "";
                        txt_email.Text             = "";
                        txt_tel.Text      = "";
                        txt_mobile.Text   = "";
                        txt_userName.Text = "";
                        txt_password.Text = "";
                        txt_adress.Text   = "";
                    }
                }
                catch { MessageBox.Show("خطا در حذف "); }
            }
        }
コード例 #2
0
        private void btn_add_Click(object sender, EventArgs e)
        {
            bool error = false;

            try
            {
                gender = comboBox1.SelectedItem.ToString();
            }
            catch
            {
                MessageBox.Show("جنسیت را درست وارد کنید");
                error = true;
            }

            if (txt_userName.Text == "")
            {
                txt_userName.Text = txt_email.Text;
            }
            ;
            if (txt_password.Text != txt_password2.Text)
            {
                MessageBox.Show("رمز های عبور مطابقت ندارند");
                error = true;
            }

            if (!error && (txt_name.Text == "" || txt_family.Text == ""))
            {
                MessageBox.Show("فیلد ها را پر کنید");
                error = true;
            }
            if (!error)
            {
                name              = txt_name.Text;
                lastName          = txt_family.Text;
                shomareShenasname = txt_shomareShenasname.Text;
                birthday          = txt_birthday.Text;
                email             = txt_email.Text;
                telephoneSabet    = txt_tel.Text;
                telephoneHamrah   = txt_mobile.Text;
                address           = txt_adress.Text;

                userName    = txt_userName.Text;
                password    = txt_password.Text;
                foroushande = new Foroushande();
                foroushande.add(name, lastName, shomareShenasname, birthday, gender, email, telephoneSabet, telephoneHamrah, userName, password, address);
                showData();
                txt_name.Text              = "";
                txt_family.Text            = "";
                txt_shomareShenasname.Text = "";
                txt_birthday.Text          = "";
                txt_email.Text             = "";
                txt_tel.Text       = "";
                txt_mobile.Text    = "";
                txt_userName.Text  = "";
                txt_password.Text  = "";
                txt_password2.Text = "";
                txt_adress.Text    = "";
            }
        }
コード例 #3
0
        private void btn_update_Click(object sender, EventArgs e)
        {
            bool error = false;

            try
            {
                if (dataGridView1.SelectedRows.Count > 0)
                {
                    try
                    {
                        gender = comboBox1.SelectedItem.ToString();
                    }
                    catch
                    {
                        MessageBox.Show("جنسیت را درست وارد کنید");
                        error = true;
                    }

                    if (txt_userName.Text == "")
                    {
                        txt_userName.Text = txt_email.Text;
                    }
                    ;
                    if (txt_password.Text != txt_password2.Text)
                    {
                        MessageBox.Show("رمز های عبور مطابقت ندارند");
                        error = true;
                    }


                    if (!error && (txt_name.Text == "" || txt_family.Text == ""))
                    {
                        MessageBox.Show("فیلد ها را پر کنید");
                        error = true;
                    }
                    if (!error)
                    {
                        foroushande       = new Foroushande();
                        id                = Int32.Parse(dataGridView1.SelectedRows[0].Cells[0].Value.ToString());
                        name              = txt_name.Text;
                        lastName          = txt_family.Text;
                        shomareShenasname = txt_shomareShenasname.Text;
                        birthday          = txt_birthday.Text;
                        email             = txt_email.Text;
                        telephoneSabet    = txt_tel.Text;
                        telephoneHamrah   = txt_mobile.Text;
                        address           = txt_adress.Text;

                        userName = txt_userName.Text;
                        password = txt_password.Text;
                        foroushande.update(id, name, lastName, shomareShenasname, birthday, gender, email, telephoneSabet, telephoneHamrah, userName, password, address);
                        showData();
                        txt_name.Text              = "";
                        txt_family.Text            = "";
                        txt_shomareShenasname.Text = "";
                        txt_birthday.Text          = "";
                        txt_email.Text             = "";
                        txt_tel.Text       = "";
                        txt_mobile.Text    = "";
                        txt_userName.Text  = "";
                        txt_password.Text  = "";
                        txt_password2.Text = "";
                        txt_adress.Text    = "";
                    }
                }
                else
                {
                    MessageBox.Show("یک سطر را انتخاب کنید ");
                }
            }
            catch { MessageBox.Show("اطلاعات را به طور دقیق وارد کنید "); }
        }