Exemplo n.º 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)
                    {
                        ranande = new Ranande();
                        while (count != 0)
                        {
                            id = Int32.Parse(dataGridView1.SelectedRows[--count].Cells[0].Value.ToString());
                            ranande.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_nameKamiun.Text = "";
                        txt_tozihat.Text    = "";
                        txt_adress.Text     = "";
                    }
                }
                catch { MessageBox.Show("خطا در حذف "); }
            }
        }
Exemplo n.º 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 (!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;

                nameKamiun = txt_nameKamiun.Text;
                tozihat    = txt_tozihat.Text;
                ranande    = new Ranande();
                ranande.add(name, lastName, shomareShenasname, birthday, gender, email, telephoneSabet, telephoneHamrah, nameKamiun, tozihat, address);
                showData();
                txt_name.Text              = "";
                txt_family.Text            = "";
                txt_shomareShenasname.Text = "";
                txt_birthday.Text          = "";
                txt_email.Text             = "";
                txt_tel.Text        = "";
                txt_mobile.Text     = "";
                txt_nameKamiun.Text = "";
                txt_tozihat.Text    = "";
                txt_adress.Text     = "";
            }
        }
Exemplo n.º 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_nameKamiun.Text == "")
                    {
                        txt_nameKamiun.Text = txt_email.Text;
                    }
                    ;


                    if (!error && (txt_name.Text == "" || txt_family.Text == ""))
                    {
                        MessageBox.Show("فیلد ها را پر کنید");
                        error = true;
                    }
                    if (!error)
                    {
                        ranande           = new Ranande();
                        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;

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