private void btnInsert_Click(object sender, EventArgs e)
 {
     UI.Employees.frmEmployeesAdd insert = new UI.Employees.frmEmployeesAdd();
     insert.ShowDialog();
     Business.Employees Employeesread = new Business.Employees();
     dataGridView1.DataSource = Employeesread.read();
 }
        private void btnSerch_Click(object sender, EventArgs e)
        {
            Business.Employees Employeeslist = new Business.Employees();
            Employeeslist.Ntiolecode = txtSerch.Text;
            Employeeslist.FirstName  = txtSerchName.Text;
            if (txtSerch.Text == "" && txtSerchName.Text == "")
            {
                MessageBox.Show("لطفا یکی ار فیلد هارا برای جستجو پر کنید.");

                dataGridView1.AutoGenerateColumns = true;
                dataGridView1.DataSource          = Employeeslist.read();
            }
            if (txtSerch.Text != string.Empty)
            {
                Employeeslist.serch();
                dataGridView1.AutoGenerateColumns = true;
                dataGridView1.DataSource          = Employeeslist.serch();
            }

            if (txtSerchName.Text != string.Empty)
            {
                Employeeslist.serchName();
                dataGridView1.AutoGenerateColumns = true;
                dataGridView1.DataSource          = Employeeslist.serchName();
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            var result = MessageBox.Show("آیا مایل به ویرایش این کاربر هتسید؟", "اطلاع", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                Business.Employees EmployeesEdit = new Business.Employees();
                #region sent
                EmployeesEdit.ID         = this.ID;
                EmployeesEdit.FirstName  = txtName.Text;
                EmployeesEdit.Lastname   = txtLname.Text;
                EmployeesEdit.Tell       = txtTell.Text;
                EmployeesEdit.Call       = txtCall.Text;
                EmployeesEdit.type       = txtType.Text;
                EmployeesEdit.time       = txtTime.Text;
                EmployeesEdit.Ntiolecode = txtNtionalcode.Text;
                #endregion
                EmployeesEdit.update();

                MessageBox.Show("ویرایش با موفقیت انجام شد ");
                UI.Employees.frmEmployeesList list = new frmEmployeesList();

                this.Close();
            }
        }
        private void btnDelet_Click(object sender, EventArgs e)
        {
            Business.Employees EmployeesDeleat = new Business.Employees();
            var result = MessageBox.Show("آیا مایل به حذف این کاربر هتسید؟", "هشدار", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                EmployeesDeleat.ID = Convert.ToInt32(dataGridView1.CurrentRow.Cells["clmnID"].Value);
                EmployeesDeleat.deleat();
                dataGridView1.AutoGenerateColumns = true;

                MessageBox.Show("حذف با موفقیت انجام شد");
                dataGridView1.DataSource = EmployeesDeleat.read();
            }
        }
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (txtname.Text == "" && txtlname.Text == "" && txtNtionalcode.Text == "" && txtTell.Text == "" && txtCall.Text == "" && txtTime.Text == "" && txtType.Text == "")
     {
         MessageBox.Show("لطفا فیلد هایی خالی را پر کنید");
     }
     Business.Employees insart = new Business.Employees();
     insart.Ntiolecode = txtNtionalcode.Text;
     insart.FirstName  = txtname.Text;
     insart.Lastname   = txtlname.Text;
     insart.Tell       = txtTell.Text;
     insart.Call       = txtCall.Text;
     insart.time       = txtTime.Text;
     insart.type       = txtType.Text;
     insart.insert();
     MessageBox.Show("ثبت با موفقیت انجام شد");
     this.Close();
 }
        private void btnEdit_Click(object sender, EventArgs e)
        {
            UI.Employees.frmEmployeesEdit frmEdit = new UI.Employees.frmEmployeesEdit();
            #region setProperties

            Business.Employees Employeesread = new Business.Employees();
            frmEdit.name = dataGridView1.CurrentRow.Cells["clmnFIrstName"].Value.ToString();

            frmEdit.lname = dataGridView1.CurrentRow.Cells["clmnLastname"].Value.ToString();
            frmEdit.tell  = dataGridView1.CurrentRow.Cells["clmnTell"].Value.ToString();
            frmEdit.cell  = dataGridView1.CurrentRow.Cells["clmnCell"].Value.ToString();
            frmEdit.type  = dataGridView1.CurrentRow.Cells["clmntype"].Value.ToString();
            frmEdit.time  = dataGridView1.CurrentRow.Cells["clmnTime"].Value.ToString();
            frmEdit.NC    = dataGridView1.CurrentRow.Cells["clmnNationalCode"].Value.ToString();
            frmEdit.ID    = Convert.ToInt32(dataGridView1.CurrentRow.Cells["clmnID"].Value);
            frmEdit.ShowDialog();
            dataGridView1.DataSource = Employeesread.read();

            #endregion
        }
 private void frmEmployeesList_Shown(object sender, EventArgs e)
 {
     Business.Employees Employees = new Business.Employees();
     dataGridView1.AutoGenerateColumns = true;
     dataGridView1.DataSource          = Employees.read();
 }