Пример #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)
                    {
                        barbari = new Barbari();
                        while (count != 0)
                        {
                            id = Int32.Parse(dataGridView1.SelectedRows[--count].Cells[0].Value.ToString());
                            barbari.delete(id);
                        }
                        showData();
                        txt_name.Text    = "";
                        txt_details.Text = "";

                        txt_tel.Text = "";

                        txt_adress.Text = "";
                    }
                }
                catch { MessageBox.Show("خطا در حذف "); }
            }
        }
Пример #2
0
        private void btn_add_Click(object sender, EventArgs e)
        {
            bool error = false;

            if (!error && (txt_name.Text == ""))
            {
                MessageBox.Show("فیلد ها را پر کنید");
                error = true;
            }
            if (!error)
            {
                name           = txt_name.Text;
                tozihat        = txt_details.Text;
                telephoneSabet = txt_tel.Text;
                address        = txt_adress.Text;

                barbari = new Barbari();
                barbari.add(name, address, telephoneSabet, tozihat);
                showData();
                txt_name.Text    = "";
                txt_details.Text = "";

                txt_tel.Text = "";

                txt_adress.Text = "";
            }
        }
Пример #3
0
        private void btn_update_Click(object sender, EventArgs e)
        {
            bool error = false;

            try
            {
                if (dataGridView1.SelectedRows.Count > 0)
                {
                    if (!error && (txt_name.Text == ""))
                    {
                        MessageBox.Show("فیلد ها را پر کنید");
                        error = true;
                    }
                    if (!error)
                    {
                        barbari        = new Barbari();
                        id             = Int32.Parse(dataGridView1.SelectedRows[0].Cells[0].Value.ToString());
                        name           = txt_name.Text;
                        tozihat        = txt_details.Text;
                        telephoneSabet = txt_tel.Text;
                        address        = txt_adress.Text;
                        barbari.update(id, name, address, telephoneSabet, tozihat);
                        showData();
                        txt_name.Text    = "";
                        txt_details.Text = "";

                        txt_tel.Text = "";

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