Esempio n. 1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgv.RowCount > 0 && dgv.CurrentRow != null)
                {
                    string pCode = dgv.Rows[dgv.CurrentRow.Index].Cells[0].Value.ToString();
                    employee = employeeBLL.GetById(pCode);
                    frmAddAccount frm = new frmAddAccount();
                    frm.ShowDialog();

                    //reload data
                    Display();
                    SetUIChanges();
                }
            }
            catch (Exception)
            {
                string code = System.Runtime.InteropServices.Marshal.GetExceptionCode().ToString();
                if (code == "-532462766")
                {
                    CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM292"),
                                                                     Common.clsLanguages.GetResource("CRM11"),
                                                                     Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                     Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                }
                return;
            }
        }
Esempio n. 2
0
        private Entities.Employees1 SetEmployee()
        {
            Entities.Employees1 emp = new VVPosM1.Entities.Employees1()
            {
                EmployeeId   = lblEmployeeId.Text,
                EmployeeCode = txtEmployeeCode.Text.Trim(),
                EmployeeName = txtEmployeeName.Text
            };

            if (rdBFemal.Checked == true)
            {
                emp.Gender = 0;
            }
            else
            {
                emp.Gender = 1;
            }
            emp.BirthDate                   = dteTBirthday.Value;
            emp.Email                       = txtEmail.Text;
            emp.PhoneNumber                 = txtPhoneNumber.Text;
            emp.Country.CountryId           = cbBCountry.SelectedValue.ToString();
            emp.Address                     = txtAddress.Text;
            emp.EmployeeType.EmployeeTypeId = cbBEmployeeType.SelectedValue.ToString();
            if (!string.IsNullOrEmpty(txtHourlyWages.Text.Trim()))
            {
                emp.HourlyWages = GetNumberFromString(txtHourlyWages.Text.Trim());
            }
            emp.Notes    = txtNote.Text;
            emp.UserName = txtUserName.Text;

            if (!string.IsNullOrEmpty(txtPassword.Text))
            {
                emp.Password = Program.ConvertStringToMD5(txtPassword.Text.Trim());
            }
            else
            {
                emp.Password = employee.Password;
            }

            emp.CreatedDate = DateTime.Now;
            emp.UpdatedDate = DateTime.Now;
            if (!string.IsNullOrEmpty(imagePath))
            {
                emp.Image = Image.FromFile(imagePath);
            }
            return(emp);
        }
Esempio n. 3
0
        private void dgv_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (dgv.RowCount > 0 && dgv.CurrentRow != null)
                {
                    string pCode = dgv.Rows[dgv.CurrentRow.Index].Cells[0].Value.ToString();
                    employee = employeeBLL.GetById(pCode);
                    frmAddAccount frm = new frmAddAccount();
                    frm.ShowDialog();

                    //reload data
                    Display();
                    SetUIChanges();
                }
            }
            catch (Exception)
            {
                string code = System.Runtime.InteropServices.Marshal.GetExceptionCode().ToString();
                if (code == "-532462766")
                {
                    CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM292"),
                                                                     Common.clsLanguages.GetResource("CRM11"),
                                                                     Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                     Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                }
                return;
            }
            //try
            //{
            //    #region
            //    pStatusAddEmployee = false; //case: edit
            //    int dgvRowIndex = e.RowIndex;
            //    string[] arrDate = new string[3];

            //    if (dgv.RowCount > 0 && dgv.CurrentRow != null)
            //    {
            //        employee.EmployeeId = dgv["EmployeeId", dgvRowIndex].Value.ToString();
            //        employee.EmployeeCode = dgv["EmployeeCode", dgvRowIndex].Value.ToString();
            //        employee.EmployeeName = dgv["EmployeeName", dgvRowIndex].Value.ToString();
            //        employee.UserName = dgv["UserName", dgvRowIndex].Value.ToString();
            //        //employee.Gender = int.Parse(dgv["IntGender", dgvRowIndex].Value.ToString());
            //        employee.BirthDate = DateTime.Parse(dgv["BirthDate", dgvRowIndex].Value.ToString());

            //        employee.PhoneNumber = dgv["PhoneNumber", dgvRowIndex].Value.ToString();
            //        employee.Email = dgv["Email", dgvRowIndex].Value.ToString();
            //        employee.Address = dgv["Address", dgvRowIndex].Value.ToString();
            //        //employee.EmployeeType.EmployeeTypeId = dgv["EmployeeTypeId", dgvRowIndex].Value.ToString();
            //        employee.EmployeeType.EmployeeTypeName = dgv["EmployeeTypeName", dgvRowIndex].Value.ToString();
            //        employee.Country.CountryId = dgv["CountryId", dgvRowIndex].Value.ToString();
            //        employee.Country.CountryName = dgv["CountryName", dgvRowIndex].Value.ToString();
            //        //employee.IsDelete = int.Parse(dgv["IntIsDelete", dgvRowIndex].Value.ToString());
            //        employee.HourlyWages = decimal.Parse(dgv["HourlyWages", dgvRowIndex].Value.ToString());
            //        employee.Notes = dgv["Notes", dgvRowIndex].Value.ToString();

            //        employee.CreatedDate = DateTime.Parse(dgv["CreatedDate", dgvRowIndex].Value.ToString());
            //        employee.Password = dgv["Password", dgvRowIndex].Value.ToString();
            //        employee.UpdatedDate = DateTime.Parse(dgv["UpdatedDate", dgvRowIndex].Value.ToString());

            //        employee.Image = employeeBLL.GetImage(employee.EmployeeId);

            //        frmAddAccount frm = new frmAddAccount();
            //        frm.ShowDialog();
            //        //Reload data
            //        Display();
            //        SetUIChanges();

            //    }
            //    #endregion
            //}
            //catch (Exception)
            //{
            //    /*
            //    string code = System.Runtime.InteropServices.Marshal.GetExceptionCode().ToString();
            //    if (code == "-532462766")
            //    {
            //        CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM292"),
            //                  Common.clsLanguages.GetResource("CRM11"),
            //                  Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
            //                  Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
            //    }
            //    return;
            //     */
            //}
        }