using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls;
using ajans.class_ajans;

namespace ajans.forms
{
    public partial class frm_ranande : Telerik.WinControls.UI.RadForm
    {
        public frm_ranande()
        {
            InitializeComponent();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            pbar.Visible = true;
            if (pbar.Value1 <= 60)
                pbar.Value1 += 10;
            if (pbar.Value2 <= 95)
                pbar.Value2 += 5;
            if (pbar.Value2 == 100)
                pbar.Visible = false;
            gpanel.Visible = true;

        }

       

        private void btn_search_Click(object sender, EventArgs e)
        {
            timer1.Enabled = true;
        }

        private void btn_home_Click(object sender, EventArgs e)
        {
            frm_main fm = new frm_main();
            fm.Show();
            this.Hide();
        }

        private void btn_insert_Click(object sender, EventArgs e)
        {
            frm_darj_ranande fdr = new frm_darj_ranande();
            fdr.ShowDialog();
            frm_ranande_Load(null, null);

        }

        private void btn_edit_Click(object sender, EventArgs e)
        {
            frm_darj_ranande fd = new frm_darj_ranande();
            fd.id_ran = Convert.ToInt16(dg_ranande["id_ran", dg_ranande.CurrentRow.Index].Value);
            fd.txt_coderanande.Text = dg_ranande["coderanande", dg_ranande.CurrentRow.Index].Value.ToString();
            fd.txt_nranande.Text = dg_ranande["n_ranande", dg_ranande.CurrentRow.Index].Value.ToString();
            fd.txt_lranande.Text = dg_ranande["l_ranande", dg_ranande.CurrentRow.Index].Value.ToString();
            fd.txt_mob.Text = dg_ranande["mob", dg_ranande.CurrentRow.Index].Value.ToString();
            fd.txt_telhome.Text = dg_ranande["tel_home", dg_ranande.CurrentRow.Index].Value.ToString();
            fd.txt_testekhdam.Text = dg_ranande["t_estekhdam", dg_ranande.CurrentRow.Index].Value.ToString();
            fd.txt_codemeli.Text = dg_ranande["codemeli", dg_ranande.CurrentRow.Index].Value.ToString();
            fd.txt_add.Text = dg_ranande["address", dg_ranande.CurrentRow.Index].Value.ToString();
            fd.Editmode = true;

            fd.ShowDialog();
            frm_ranande_Load(null, null);
        }

        private void btn_delete_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("آیا می خواهید حذف شود", "حذف", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dr == DialogResult.Yes)
            {
                ranande r = new ranande();
                r.coderanande = dg_ranande["coderanande", dg_ranande.CurrentRow.Index].Value.ToString();

                r.delete();
                frm_ranande_Load(null, null);
            }
            
        }

        private void frm_ranande_Load(object sender, EventArgs e)
        {
            ranande r = new ranande();
            dg_ranande.DataSource = r.show();
        }
    }
}
