Exemplo n.º 1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!ValidateInput())
            {
                return;
            }

            SysEmployee employee = null;

            switch (_type)
            {
            case EditType.Add:
                employee                = new SysEmployee();
                employee.EmployeeId     = BipGuid.Guid;
                employee.EmployeeCode   = txtEmployeeCode.Text.Trim();
                employee.EmployeeName   = txtEmployeeName.Text.Trim();
                employee.Sex            = uosEmployeeSex.CheckedItem.DataValue.ToString();
                employee.Age            = short.Parse(uneEmployeeAge.Value.ToString());
                employee.Email          = txtEmployeeMail.Text.Trim();
                employee.Ip             = txtEmployeeIp.Text.Trim();
                employee.Phone          = txtEmployeePhone.Text.Trim();
                employee.Address        = txtEmployeeAddress.Text.Trim();
                employee.Remark         = txtEmployeeRemark.Text.Trim();
                employee.OrganizationId = this.OrganizationId;
                if (picEmployeePhoto.Image != null)
                {
                    employee.Photo = ImageUtil.ImageToBytes(picEmployeePhoto.Image);
                }
                this.Update(Globals.EMPLOYEE_SERVICE_NAME, "add", new object[] { employee });
                break;

            case EditType.Update:
                employee = _employee;
                employee.EmployeeCode = txtEmployeeCode.Text.Trim();
                employee.EmployeeName = txtEmployeeName.Text.Trim();
                employee.Sex          = uosEmployeeSex.CheckedItem.DataValue.ToString();
                employee.Age          = short.Parse(uneEmployeeAge.Value.ToString());
                employee.Email        = txtEmployeeMail.Text.Trim();
                employee.Ip           = txtEmployeeIp.Text.Trim();
                employee.Phone        = txtEmployeePhone.Text.Trim();
                employee.Address      = txtEmployeeAddress.Text.Trim();
                employee.Remark       = txtEmployeeRemark.Text.Trim();
                if (!String.IsNullOrEmpty(cbtEmployeeOrg.Value))
                {
                    employee.OrganizationId = cbtEmployeeOrg.Value;
                }
                if (picEmployeePhoto.Image != null)
                {
                    employee.Photo = ImageUtil.ImageToBytes(picEmployeePhoto.Image);
                }
                this.Update(Globals.EMPLOYEE_SERVICE_NAME, "update", new object[] { employee });
                break;
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Exemplo n.º 2
0
        private void ultraGrid1_DoubleClickRow(object sender, DoubleClickRowEventArgs e)
        {
            SysEmployee     employee = e.Row.ListObject as SysEmployee;
            DlgEmployeeEdit dlg      = new DlgEmployeeEdit(employee, EditType.Update, this.Action);

            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                QueryEmployees(activeOrganizationId);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 修改员工信息
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void toolStripMenuItem2_Click(object sender, EventArgs e)
 {
     if (ultraGrid1.ActiveRow != null)
     {
         SysEmployee     employee = ultraGrid1.ActiveRow.ListObject as SysEmployee;
         DlgEmployeeEdit dlg      = new DlgEmployeeEdit(employee, EditType.Update, this.Action);
         if (dlg.ShowDialog(this) == DialogResult.OK)
         {
             QueryEmployees(activeOrganizationId);
         }
     }
 }
Exemplo n.º 4
0
        public HandleState Import(List <SysUserViewModel> data)
        {
            try
            {
                eFMSDataContext    dc           = (eFMSDataContext)DataContext.DC;
                List <SysUser>     sysUsers     = new List <SysUser>();
                List <SysEmployee> sysEmployees = new List <SysEmployee>();
                foreach (var item in data)
                {
                    var objUser     = new SysUserModel();
                    var objEmployee = new SysEmployee();
                    objEmployee.Id = Guid.NewGuid().ToString();
                    objEmployee.DatetimeCreated = objEmployee.DatetimeModified = DateTime.Now;
                    objEmployee.EmployeeNameEn  = item.EmployeeNameEn;
                    objEmployee.EmployeeNameVn  = item.EmployeeNameVn;
                    objEmployee.Tel             = item.Tel;
                    objEmployee.Title           = item.Title;
                    objEmployee.StaffCode       = item.StaffCode;
                    objEmployee.Email           = item.Email;
                    sysEmployees.Add(objEmployee);
                    objUser.Username      = item.Username;
                    objUser.UserType      = item.UserType;
                    objUser.WorkingStatus = !string.IsNullOrEmpty(item.WorkingStatus)? item.WorkingStatus : "Working";
                    objUser.Active        = item.Status?.ToLower() == "active" ? true : (item.Status?.ToLower() == "inactive" ? false : false);
                    objUser.EmployeeId    = objEmployee.Id;
                    objUser.Id            = Guid.NewGuid().ToString();
                    objUser.UserCreated   = objUser.UserModified = currentUser.UserID;
                    objUser.Password      = BCrypt.Net.BCrypt.HashPassword(Constants.PERMISSION_RANGE_OWNER);
                    objUser.Description   = item.Description;
                    objUser.Password      = SystemConstants.Password;
                    objUser.Password      = BCrypt.Net.BCrypt.HashPassword(objUser.Password);
                    sysUsers.Add(objUser);
                }

                dc.SysEmployee.AddRange(sysEmployees);
                dc.SysUser.AddRange(sysUsers);
                dc.SaveChanges();
                return(new HandleState());
            }
            catch (Exception ex)
            {
                return(new HandleState(ex.Message));
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 删除员工
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            ultraGrid1.UpdateData();
            List <String> employeeIdList = new List <string>();

            foreach (UltraGridRow row in ultraGrid1.Rows)
            {
                SysEmployee employee = row.ListObject as SysEmployee;
                if (employee.IsChecked)
                {
                    employeeIdList.Add(employee.EmployeeId);
                }
            }
            if (employeeIdList.Count > 0)
            {
                this.Update(Globals.EMPLOYEE_SERVICE_NAME, "delete", new object[] { employeeIdList.ToArray() });
                QueryEmployees(activeOrganizationId);
            }
        }
Exemplo n.º 6
0
 public DlgEmployeeEdit(SysEmployee employee, EditType type, BipAction action)
     : this(employee, type)
 {
     this.Action = action;
 }
Exemplo n.º 7
0
 public DlgEmployeeEdit(SysEmployee employee, EditType type)
 {
     _type     = type;
     _employee = employee;
     InitializeComponent();
 }