public void insertTimeout(Employee employee)
 {
     int last_id = int.Parse(readScalar("id", "1 = 1 ORDER BY datetime_in DESC").ToString());
     string condition = String.Format("user_id = '{0}' AND id = {1}", employee.User_id, last_id);
     string set = "datetime_out = NOW()";
     update(updateSet(condition, set));
 }
        public void appearWithUser(Employee employee){
            if (employee.Position == UserLevel.ADMIN)
                loginName.ForeColor = Color.Gold;
            else
                loginName.ForeColor = Color.White;

            accessLoginName = employee.User_id;

            if (System.IO.File.Exists(@employee.ImagePath))
                accessLoginImage = Randy.GraphicsLibrary.Renderer.resizeImage(Image.FromFile(@employee.ImagePath) as Bitmap, panelImage.Width, panelImage.Height) as Image;
            else
                accessLoginImage = null;
            appear(DockStyle.Fill);
        }
Example #3
0
        public void showUser(Employee employee)
        {
            lblName.Text = employee.Firstname + " " + employee.MiddleName + " " + employee.Lastname;
            lblPosition.Text = employee.Position.ToString();
            lblMobileno.Text = employee.MobileNo.ToString();

            lblTelno.Text = employee.TelNo.ToString();
            lblEmailadd.Text = employee.EmailAddress.ToString();
            lblRegistrationdate.Text = employee.RegisteredDate.ToLongDateString();

            lblUsername.Text = employee.User_id;
            lblAddress.Text = employee.Address;
            if (File.Exists(@employee.ImagePath))
                userImage.Image = Renderer.resizeImage(Image.FromFile(@employee.ImagePath) as Bitmap, userImage.Width, userImage.Height) as Image;
            else
                userImage.Image = Renderer.resizeImage(Properties.Resources.userBlack, userImage.Width, userImage.Height) as Image;
        }
        public bool updateEmployee(Employee oldE, Employee newE){
            // Make sure that the employee have the same user_id
            if (oldE.User_id != newE.User_id)
                return false;
        
            string updateFirstname, updateMiddlename, updateLastname, updateMobileno, updateTelno, updateEmailAdd, updateAddress, updateImagepath;
            updateFirstname = updateMiddlename = updateLastname = updateMobileno = updateTelno = updateEmailAdd = updateAddress = updateAddress = updateImagepath = "";
            
            if (oldE.Firstname != newE.Firstname && !String.IsNullOrEmpty(newE.Firstname))
                updateFirstname = String.Format("firstname = '{0}'", newE.Firstname);
            if (oldE.MiddleName != newE.MiddleName && !String.IsNullOrEmpty(newE.MiddleName))
                updateMiddlename = String.Format("middlename = '{0}'", newE.MiddleName);

            if (oldE.Lastname != newE.Lastname && !String.IsNullOrEmpty(newE.Lastname))
                updateLastname = String.Format("lastname = '{0}'", newE.Lastname);
            if (oldE.MobileNo != newE.MobileNo && !String.IsNullOrEmpty(newE.MobileNo))
                updateMobileno = String.Format("mobile_no = '{0}'", newE.MobileNo);

            if (oldE.TelNo != newE.TelNo && !String.IsNullOrEmpty(newE.TelNo))
                updateTelno = String.Format("telephone_no = '{0}'", newE.TelNo);
            if (oldE.EmailAddress != newE.EmailAddress && !String.IsNullOrEmpty(newE.EmailAddress))
                updateEmailAdd = string.Format("email_address = '{0}'", newE.EmailAddress);

            if (oldE.Address != newE.Address && !String.IsNullOrEmpty(newE.Address))
                updateAddress = String.Format("address = '{0}'", newE.Address);
            if (oldE.ImagePath != newE.ImagePath && !String.IsNullOrEmpty(newE.ImagePath))
                updateImagepath = String.Format("image_path = '{0}'", newE.ImagePath);


            string condition = String.Format("user_id = '{0}'", newE.User_id);
            return update(
                updateSet(condition, updateFirstname, updateMiddlename, 
                updateLastname, updateMobileno, updateTelno, updateEmailAdd, updateAddress, 
                formatImagePath(updateImagepath))
                );
        }
Example #5
0
        public void init(UserAdminMode mode)
        {
            txtFirstname.Focus();
            masterController.setFormReturnkey = btnSave;
            this.mode = mode;
            hasPictureChanged = false;

            if (mode == UserAdminMode.Add_user)
            {
                clearTextboxes();
                togglePasswordInputs(true);
                updateStatus("You are creating a New User", SystemColors.menuLightBlue);
            }
            else if (mode == UserAdminMode.Edit_user)
            {
                togglePasswordInputs(false);
                updateStatus("You are updating an Existing User", SystemColors.menuBarBlue);
                currentEmployee = userAdministration.selectedEmployee;

                txtLastname.Text = currentEmployee.Lastname;
                txtFirstname.Text = currentEmployee.Firstname;
                txtMiddlename.Text = currentEmployee.MiddleName;
                txtMobno.Text = currentEmployee.MobileNo;

                txtUsername.Text = currentEmployee.User_id;
                txtImagepath.Text = currentEmployee.ImagePath;
                txtAddress.Text = currentEmployee.Address;
                domainPosition.Text = currentEmployee.Position.ToString();

                if (File.Exists(currentEmployee.ImagePath))
                    imageUser.Image = Renderer.resizeImage(Image.FromFile(currentEmployee.ImagePath) as Bitmap, imageUser.Width, imageUser.Height) as Image;
                else
                    imageUser.Image = null;
            }
        }
 public Employee getEmployeeFromUserId(User user){
     string condition = String.Format("user_id = '{0}'", user.UserId);
     Employee employee = new Employee(getEntityWhere(condition));
     employee.Position = user.getUserLevel();
     return employee;
 }
 public string createEmployee(Employee employee)
 {
     return insertValues(employee.User_id, employee.Firstname, employee.MiddleName, employee.Lastname, employee.MobileNo, employee.TelNo, employee.EmailAddress , employee.Address, formatImagePath(employee.ImagePath));
 }
Example #8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (Validation.isFilled(panel_AddUser, txtMiddlename, txtPassword, txtRepassword))
            {
                if (mode == UserAdminMode.Add_user)
                {
                    if (string.IsNullOrWhiteSpace(txtPassword.Text) || string.IsNullOrWhiteSpace(txtRepassword.Text))
                    {
                        MessageBanner banner0 = new MessageBanner("Please fill up all the fields and try again.", 2000);
                        banner0.BackColor = System.Drawing.Color.DarkRed;
                        banner0.ForeColor = System.Drawing.Color.White;
                        banner0.Opacity = 1;
                        banner0.Show();
                        return;
                    }

                }
                if (userAdministration.usernames.Contains(txtUsername.Text) && mode != UserAdminMode.Edit_user)
                {
                    MessageBox.Show(String.Format("The username {0} did already exists!", txtUsername.Text));
                    txtUsername.Focus();
                    txtUsername.SelectAll();
                    return;
                }
                else if (txtPassword.Text != txtRepassword.Text)
                {
                    MessageBox.Show("Passwords didn't match!");
                    txtPassword.Focus();
                    txtRepassword.Clear();
                    return;
                }

                if (hasPictureChanged)
                    saveImage();

                User user = new User()
                {
                    UserId = txtUsername.Text,
                    Password = txtPassword.Text,
                    userLevel = domainPosition.Text,
                    Squery = SelectedIndex(cmbSquery.SelectedIndex),
                    FBAnswer = txtAnswer.Text,
                };

                Employee employee = new Employee(user)
                {
                    Firstname = txtFirstname.Text,
                    MiddleName = txtMiddlename.Text,
                    Lastname = txtLastname.Text,
                    MobileNo = txtMobno.Text,
                    EmailAddress = textBox2.Text,
                    TelNo = txtTelno.Text,
                    ImagePath = txtImagepath.Text,
                    Address = txtAddress.Text
                };

                MessageBanner banner;
                if (mode == UserAdminMode.Add_user)
                {
                    dbController.createUserEmployee(user, employee);
                    banner = new MessageBanner(string.Format("New User was added: {0}", user.UserId), 2000);
                    banner.Show();

                    // audit
                    string action = string.Format("added new User {0}", user.UserId);
                    dbController.insertAuditTrail(action);
                }
                else if (mode == UserAdminMode.Edit_user)
                {
                    dbController.updateEmployee(currentEmployee, employee);
                    banner = new MessageBanner(String.Format("User {0} was updated", employee.User_id), 2000);
                    banner.Show();

                    // audit
                    string action = string.Format("updated User {0}", employee.User_id);
                    dbController.insertAuditTrail(action);
                }

                this.disappear();
            }
            else
            {
                MessageBanner banner1 = new MessageBanner("Please fill up all the fields and try again.", 2000);
                banner1.BackColor = System.Drawing.Color.DarkRed;
                banner1.ForeColor = System.Drawing.Color.White;
                banner1.Opacity = 1;
                banner1.Show();
            }
         
        }
 public void createUserEmployee(User user, Employee employee)
 {
     string insertUser = userMapper.createUser(user);
     string insertEmployee = employeeMapper.createEmployee(employee);
     if (createTransaction(insertUser, insertEmployee)){
         EntityArgs e = new EntityArgs(employee);
         OnInsertEntity(e);
     }
     user.Dispose();
 }
 public string createEmployee(Employee employee)
 {
     return employeeMapper.createEmployee(employee);
 }
 public void insertTimeIn(Employee employee)
 {
     insertQuery = String.Format("INSERT INTO login_trail_tbl(user_id) VALUES('{0}')",employee.User_id);
     create(insertQuery);
 }
 public bool insertAuditTrail(Employee employee, string action, DateTime date)
 {   
     return create(
         insertValues(employee.User_id, action, MyExtension.MySqlToCSharp.convertDate(date), MyExtension.MySqlToCSharp.convertTime(date))
         );
 }
Example #13
0
 public void insertTimeIn(Employee employee)
 {
     insertQuery = String.Format("INSERT INTO login_trail_tbl(user_id, datetime_in) VALUES('{0}' ,'{1}')", employee.User_id, MyExtension.MySqlToCSharp.convertDateTime(DateTime.Now));
     create(insertQuery);
 }
Example #14
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (userAdministration.usernames.Contains(txtUsername.Text) && mode != UserAdminMode.Edit_user){
                MessageBox.Show(String.Format("The username {0} did already exists!", txtUsername.Text));
                txtUsername.Focus();
                txtUsername.SelectAll();
                return;
            }
            else if (txtPassword.Text != txtRepassword.Text)
            {
                MessageBox.Show("Passwords didn't match!");
                txtPassword.Focus();
                txtRepassword.Clear();
                return;
            }

            if (hasPictureChanged)
                saveImage();

            User user = new User()
            {
                UserId = txtUsername.Text,
                Password = txtPassword.Text,
                userLevel = domainPosition.Text
            };

            Employee employee = new Employee(user)
            {
                Firstname = txtFirstname.Text,
                MiddleName = txtMiddlename.Text,
                Lastname = txtLastname.Text,
                MobileNo = txtMobno.Text,
                EmailAddress = textBox2.Text,
                TelNo = txtTelno.Text,
                ImagePath = txtImagepath.Text,
                Address = txtAddress.Text
            };

            MessageBanner banner;
            if (mode == UserAdminMode.Add_user)
            {
                dbController.createUserEmployee(user, employee);
                banner = new MessageBanner(string.Format("New User was added: {0}", user.UserId), 2000);
                banner.Show();

                // audit
                string action = string.Format("added new User {0}", user.UserId);
                dbController.insertAuditTrail(action);
            }
            else if (mode == UserAdminMode.Edit_user)
            {
                dbController.updateEmployee(currentEmployee, employee);
                banner = new MessageBanner(String.Format("User {0} was updated",employee.User_id), 2000);
                banner.Show();

                // audit
                string action = string.Format("updated User {0}", employee.User_id);
                dbController.insertAuditTrail(action);
            }
            this.disappear();
        }
 public void updateEmployee(Employee oldE, Employee newE)
 {
     if (employeeMapper.updateEmployee(oldE, newE))
     {
         EntityArgs e = new EntityArgs(newE);
         OnUpdateEntity(e);
     }
 }
        void viewUser()
        {
            try
                {
                    if (addUserPane != null && addUserPane.IsDirty)
                    {
                        DialogResult result = MessageBox.Show("There are seems unsaved work.. Are you sure you want to continue?",
                                                                "You are going to leave unsave work", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                        if (result == DialogResult.No)
                            return;
                        else
                            addUserPane.clearTextboxes();
                    }

                    if (mode != UserAdminMode.View_user)
                    {
                        userView = new UserView(userPanel, masterController);
                        mode = UserAdminMode.View_user;
                        flipColors();
                    }

                    lbUsers.Focus();
                    selectedEmployee = userEmployeeMap[lbUsers.SelectedItem.ToString()];
                    userView.showUser(selectedEmployee);
                }
                catch (NullReferenceException)
                {
                    if (lbUsers.SelectedItem == null)
                        MessageBox.Show("No selected user.. ");
                }
        }
Example #17
0
 public EmployeeArgs(Employee e)
 {
     employee = e;
 }