Beispiel #1
0
        private void txtUserID_TextChanged(object sender, EventArgs e)
        {
            User USR = new User();
            DataSet ds = USR.getUserList(txtUserID.Text);

            gridUsers.DataSource = ds.Tables["Users"].DefaultView;
        }
Beispiel #2
0
        private void UserSummary_Load(object sender, EventArgs e)
        {
            User USR = new User();
            DataSet DS = USR.getLogTrack();
            string userID;
            int count;
            //generate chart
            chart1.Series.Add("Login_Rate");
            chart1.Series["Login_Rate"].ChartType = SeriesChartType.Column;
            chart1.Series["Login_Rate"].ChartArea = "ChartArea1";
            chart1.Series["Login_Rate"].BackSecondaryColor = Color.White;
            chart1.Series["Login_Rate"].BackGradientStyle = GradientStyle.TopBottom;

            int rowCount = 0;

            foreach (DataRow row in DS.Tables[0].Rows)
            {

                userID = row[0].ToString().Trim();
                count = Convert.ToInt32(row[1]);

                chart1.Series["Login_Rate"].Points.AddXY(userID, count);

                rowCount++;
            }

            //fill the grid
            DataSet ds = USR.getLogInfo();
            gridUsers.DataSource = ds.Tables["Info"].DefaultView;
        }
Beispiel #3
0
        private void btnReset_Click(object sender, EventArgs e)
        {
            User usr = new User();

            if (usr.ResetUser(lblUserID.Text,lblUsername.Text,UTL.NewPassWordGen()))
            {
                MessageBox.Show("User Reset successfully!", "Successfully", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Reset incompleted!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #4
0
        private void btnRemove_Click(object sender, EventArgs e)
        {
            User usr = new User();

            if (usr.DeleteUser(lblUserID.Text))
            {
                MessageBox.Show("User Removed successfully!", "Successfully", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Deletion incompleted!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #5
0
        private void radButton2_Click(object sender, EventArgs e)
        {
            byte[] userPhoto = UTL.ConvertImageToBytes(picUser.Image);

            User newUser = new User(lblUserID.Text, txtFirstName.Text, txtLastName.Text, lstTitle.SelectedText, lstUserLevels.SelectedText, txtUsername.Text, txtPassword.Text, txtEmail.Text, Convert.ToDateTime(lblCreatedDate.Value.ToShortDateString()), lblCreatedTime.Text,userPhoto);

            if(newUser.InsertUser(newUser))
            {
                MessageBox.Show("New user crated successfuly!", "Successfully", MessageBoxButtons.OK, MessageBoxIcon.Information);
                clear_Txt();
            }
            else
            {
                MessageBox.Show("Insert incompleted!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #6
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            Utility utl = new Utility();
            byte[] photo = utl.ConvertImageToBytes(picUser.Image);

            User usr = new User(lblUserID.Text, txtFirstName.Text, txtLastName.Text, lblTitle.Text, lblUserLevel.Text, txtUserName.Text, txtPassword.Text, txtEmailAdd.Text, Convert.ToDateTime(lblDate.Text), lblTime.Text,photo);

            if (txtPassword.Text != "")
            {
                if (usr.UpdateUser(usr))
                {
                    MessageBox.Show("User Modification is successful!", "Successfully", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    clear_Txt();
                }
                else
                {
                    MessageBox.Show("Modification Rejected!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Empty password not allowed", "Successfully", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #7
0
        private void btnSendMail_Click(object sender, EventArgs e)
        {
            User usr = new User();

            bool x = usr.sendMail("*****@*****.**", "Working", "ABC", "123");
        }
Beispiel #8
0
        private void btnLogout_Click(object sender, EventArgs e)
        {
            User USR = new User();
            DateTime GloblogoutTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz"));

            if (USR.UpdateLogRecord(GlobUser_id, GlobLoggedTime, GloblogoutTime))
            {
                alertLogTracker.CaptionText = "Logout Tracker";
                alertLogTracker.ContentText = "Logout Tracked : " + GloblogoutTime.ToString();
                alertLogTracker.Show();
                MessageBox.Show("System usage tracked successfully..!","Thank you");
            }
            else
            {
                alertLogTracker.ContentText = "Failure Occured ..!";
                alertLogTracker.Show();
            }

            Login lgout = new Login();

            Login log = new Login();
            this.Dispose();
            log.Show();
        }
Beispiel #9
0
        //update User
        public bool UpdateUser(User editedUser)
        {
            try
            {
                this.connection = DBHandler.getConnection();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message.ToString());
            }

            bool status = false;

            if (connection.State.ToString() == "Closed")
            {
                connection.Open();
            }

            SqlCommand newCmd = connection.CreateCommand();

            newCmd.Connection = connection;
            newCmd.CommandType = CommandType.Text;
            newCmd.CommandText = "UPDATE Users SET user_id='" + editedUser.userId + "',first_name='" + editedUser.firstName + "',last_name='" + editedUser.lastName + "',title='" + editedUser.title + "',user_level='" + editedUser.userLevel + "',user_name='" + editedUser.username + "',password='******',email='" + editedUser.email + "',photograph='" + editedUser.photo + "' where user_id='" + editedUser.userId + "';";
            try
            {
                newCmd.ExecuteNonQuery();
                status = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            connection.Close();
            return status;
        }
Beispiel #10
0
        //Inset new User
        public bool InsertUser(User newUser)
        {
            try
            {
                this.connection = DBHandler.getConnection();
            }
             catch (Exception e)
            {
                MessageBox.Show(e.Message.ToString());
            }

            bool status = false;

            if (connection.State.ToString() == "Closed")
            {
                connection.Open();
            }

            SqlCommand newCmd = connection.CreateCommand();

            newCmd.Connection = connection;
            newCmd.CommandType = CommandType.Text;
            newCmd.CommandText = "insert into Users values('" + newUser.userId + "','" + newUser.firstName + "','" + newUser.lastName + "','" + newUser.title + "','" + newUser.userLevel + "','" + newUser.username + "','" + newUser.password + "','" + newUser.email + "','" + newUser.createdDate + "','" + newUser.createdTime + "','" + newUser.photo + "')";
            try
            {
                newCmd.ExecuteNonQuery();
                status = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            connection.Close();
            return status;
        }