コード例 #1
0
        private async void btnSave_Click(object sender, EventArgs e)
        {
            var id           = txtIdNo.Text;
            var name         = txtFullName.Text;
            var address      = txtAddress.Text;
            var contactNo    = txtContact.Text;
            var email        = txtEmail.Text;
            var desigination = txtDesignation.Text;
            var department   = comboBoxDepartment.Text;
            var dateOfJoin   = dateTimePicker.Text;
            var wageRate     = txtWage.Text;
            var hourWorked   = txtWorkedHour.Text;

            using (var context = new EmployeeManagementContext())
            {
                var emp = new Employee(id, name, address, contactNo, email, desigination, department, dateOfJoin, wageRate, hourWorked);
                context.Employees.Add(emp);
                await context.SaveChangesAsync();
            }

            //instance event args and value has been passed
            var args = new IdentityEventArgs(id, name, address, contactNo, email, desigination, department, dateOfJoin, wageRate, hourWorked);

            //Event has be raised with update arguments of delegate
            IdentityUpdated?.Invoke(this, args);

            this.Hide();
        }
コード例 #2
0
 private void UpdateRecord(object sender, IdentityEventArgs e)
 {
     dataGridView.Rows[_row].Cells[0].Value = e.EmployeeNum;
     dataGridView.Rows[_row].Cells[1].Value = e.Id;
     dataGridView.Rows[_row].Cells[2].Value = e.FullName;
     dataGridView.Rows[_row].Cells[3].Value = e.Mobile;
     dataGridView.Rows[_row].Cells[4].Value = e.Email;
     dataGridView.Rows[_row].Cells[5].Value = e.Department;
 }
コード例 #3
0
 private void UpdateRecord(object sender, IdentityEventArgs e)
 {
     dataGridView.Rows[_row].Cells[0].Value = e.Id;
     dataGridView.Rows[_row].Cells[1].Value = e.FullName;
     dataGridView.Rows[_row].Cells[2].Value = e.Address;
     dataGridView.Rows[_row].Cells[3].Value = e.Contact;
     dataGridView.Rows[_row].Cells[4].Value = e.Email;
     dataGridView.Rows[_row].Cells[5].Value = e.Designation;
     dataGridView.Rows[_row].Cells[6].Value = e.Department;
     dataGridView.Rows[_row].Cells[7].Value = e.DateOfJoin;
     dataGridView.Rows[_row].Cells[8].Value = e.WageRate;
     dataGridView.Rows[_row].Cells[9].Value = e.WorkedHour;
 }
コード例 #4
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            var employeeNum = txtEmpNum.Text;
            var id          = txtIdNo.Text;
            var name        = txtFullName.Text;
            var mobile      = txtMobile.Text;
            var email       = txtEmail.Text;
            var department  = comboBoxDepartment.Text;

            Employee emp = new Employee(employeeNum, id, name, mobile, email, department);

            if (!bEdit)
            {
                var myItem = DBUtility.GetEmployees().Find(item => item.EmployeeNum == employeeNum);
                if (myItem == null)
                {
                    DBUtility.AddEmployee(emp);
                }
                else
                {
                    string message, caption;
                    string language = ChangeLanguage.ReadConfigValue("language");
                    if (language == "he-IL")
                    {
                        message = "עובד עם מספר זהה קיים במערכת";
                        caption = "שגיאה";
                    }
                    else
                    {
                        message = "Employee with this ID allready exsits in data base";
                        caption = "Error";
                    }
                    MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);

                    return;
                }
            }
            else
            {
                DBUtility.EditEmployee(emp);
            }

            //instance event args and value has been passed
            var args = new IdentityEventArgs(employeeNum, id, name, mobile, email, department);

            //Event has be raised with update arguments of delegate
            IdentityUpdated?.Invoke(this, args);

            this.Hide();
        }
コード例 #5
0
 private void SaveRecord(object sender, IdentityEventArgs e)
 {
     try
     {
         var count = dataGridView.Rows.Count;
         dataGridView.Rows.Add();
         dataGridView.Rows[count].Cells[0].Value = e.EmployeeNum;
         dataGridView.Rows[count].Cells[1].Value = e.Id;
         dataGridView.Rows[count].Cells[2].Value = e.FullName;
         dataGridView.Rows[count].Cells[3].Value = e.Mobile;
         dataGridView.Rows[count].Cells[4].Value = e.Email;
         dataGridView.Rows[count].Cells[5].Value = e.Department;
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message, "Error !", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #6
0
 private void SaveRecord(object sender, IdentityEventArgs e)
 {
     try
     {
         var count = dataGridView.Rows.Count - 1;
         dataGridView.Rows.Add();
         dataGridView.Rows[count].Cells[0].Value = e.Id;
         dataGridView.Rows[count].Cells[1].Value = e.FullName;
         dataGridView.Rows[count].Cells[2].Value = e.Address;
         dataGridView.Rows[count].Cells[3].Value = e.Contact;
         dataGridView.Rows[count].Cells[4].Value = e.Email;
         dataGridView.Rows[count].Cells[5].Value = e.Designation;
         dataGridView.Rows[count].Cells[6].Value = e.Department;
         dataGridView.Rows[count].Cells[7].Value = e.DateOfJoin;
         dataGridView.Rows[count].Cells[8].Value = e.WageRate;
         dataGridView.Rows[count].Cells[9].Value = e.WorkedHour;
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message, "Error !", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }