Пример #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)
                    {
                        taminKonande = new TaminKonande();
                        while (count != 0)
                        {
                            id = Int32.Parse(dataGridView1.SelectedRows[--count].Cells[0].Value.ToString());
                            taminKonande.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_bedehkar.Text  = "";
                        txt_bestankar.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;
            }


            try
            {
                long test;
                if (txt_bedehkar.Text == "" || txt_bedehkar.Text == null)
                {
                    txt_bedehkar.Text = "0";
                }
                if (txt_bestankar.Text == "" || txt_bestankar.Text == null)
                {
                    txt_bestankar.Text = "0";
                }
                test = long.Parse(txt_bedehkar.Text);
                test = long.Parse(txt_bestankar.Text);
            }
            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;

                bedehkar     = txt_bedehkar.Text;
                bestankar    = txt_bestankar.Text;
                tozihat      = txt_tozihat.Text;
                taminKonande = new TaminKonande();
                taminKonande.add(name, lastName, shomareShenasname, birthday, gender, email, telephoneSabet, telephoneHamrah, bedehkar, bestankar, 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_bedehkar.Text  = "";
                txt_bestankar.Text = "";
                txt_adress.Text    = "";
                txt_tozihat.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;
                    }

                    try
                    {
                        long test;
                        if (txt_bedehkar.Text == "" || txt_bedehkar.Text == null)
                        {
                            txt_bedehkar.Text = "0";
                        }
                        if (txt_bestankar.Text == "" || txt_bestankar.Text == null)
                        {
                            txt_bestankar.Text = "0";
                        }
                        test = long.Parse(txt_bedehkar.Text);
                        test = long.Parse(txt_bestankar.Text);
                    }
                    catch
                    {
                        MessageBox.Show("مبلغ بدهکار و بستانکار را درست وارد کنید");
                        error = true;
                    }
                    if (!error && (txt_name.Text == "" || txt_family.Text == ""))
                    {
                        MessageBox.Show("فیلد ها را پر کنید");
                        error = true;
                    }
                    if (!error)
                    {
                        taminKonande      = new TaminKonande();
                        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;

                        bedehkar  = txt_bedehkar.Text;
                        bestankar = txt_bestankar.Text;
                        tozihat   = txt_tozihat.Text;
                        taminKonande.update(id, name, lastName, shomareShenasname, birthday, gender, email, telephoneSabet, telephoneHamrah, bedehkar, bestankar, 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_bedehkar.Text  = "";
                        txt_bestankar.Text = "";
                        txt_adress.Text    = "";
                        txt_tozihat.Text   = "";
                    }
                }
                else
                {
                    MessageBox.Show("یک سطر را انتخاب کنید ");
                }
            }

            catch { MessageBox.Show("اطلاعات را به طور دقیق وارد کنید "); }
        }