Exemple #1
0
        private void ViewProjBtn_MouseClick(object sender, MouseEventArgs e)
        {
            ViewProjUC.projInfo.Hide();
            ViewProjUC.editProj.Hide();
            ViewEmpUC.editData.Hide();
            ViewProjUC.tasksPanel.Hide();
            flowLayoutPanel1.Controls.Clear();
            flowLayoutPanel1.BringToFront();
            OnHome.Visible     = false;
            OnAddMng.Visible   = false;
            OnAddProj.Visible  = false;
            OnViewEmp.Visible  = false;
            OnViewProj.Visible = true;
            AdminClass          projectlist = new AdminClass();
            List <ProjectClass> list        = new List <ProjectClass>(); projectlist.projectview(ref list);

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].status == "Finish")
                {
                    ViewProjUC view = new ViewProjUC(list[i]);
                    view.EditLabelBtn.Visible = false;
                    view.ProjectName.Text     = list[i].name;
                    view.TaskEmpLabel.Text    = list[i].manger_name;
                    view.startDuration.Text   = "Start on " + list[i].start_time.Day + " / " + list[i].start_time.Month + " / " + list[i].start_time.Year;
                    view.endDuration.Text     = "End on " + list[i].end_time.Day + " / " + list[i].end_time.Month + " / " + list[i].end_time.Year;
                    flowLayoutPanel1.Controls.Add(view);
                }
            }
            //ProjectClass pro = new ProjectClass();
            //ViewProjUC viewTasks = new ViewProjUC(pro);
            //viewTasks.EditLabelBtn.Visible = false;
            //flowLayoutPanel1.Controls.Add(viewTasks);
        }
Exemple #2
0
        public bool loginadmin(string user_name, string pass, ref AdminClass admin)
        {
            SqlConnection connect = new SqlConnection(connectstr);

            SqlCommand cmd = new SqlCommand("select * from fn_login_admin('" + user_name + "','" + pass + "')", connect);

            try
            {
                connect.Open();

                SqlDataReader reader = cmd.ExecuteReader();
                // cmd.CommandType = CommandType.TableDirect;
                while (reader.Read())
                {
                    admin.id       = (int)reader["id_admin"];
                    admin.username = user_name;
                    admin.password = pass;

                    reader.Close();
                    connect.Close();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(false);
        }
Exemple #3
0
        public void HomeBtn_MouseClick(object sender, MouseEventArgs e)
        {
            flowLayoutPanel1.Controls.Clear();
            flowLayoutPanel1.BringToFront();
            OnHome.Visible     = true;
            OnAddMng.Visible   = false;
            OnAddProj.Visible  = false;
            OnViewEmp.Visible  = false;
            OnViewProj.Visible = false;

            AdminClass          projectlist = new AdminClass();
            List <ProjectClass> list        = new List <ProjectClass>();

            projectlist.projectview(ref list);
            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].status != "Finish")
                {
                    ViewProjUC view = new ViewProjUC(list[i]);
                    view.ProjectName.Text   = list[i].name;
                    view.TaskEmpLabel.Text  = list[i].manger_name;
                    view.startDuration.Text = "Start on " + list[i].start_time.Day + " / " + list[i].start_time.Month + " / " + list[i].start_time.Year;
                    view.endDuration.Text   = "End on " + list[i].end_time.Day + " / " + list[i].end_time.Month + " / " + list[i].end_time.Year;
                    flowLayoutPanel1.Controls.Add(view);
                }
            }
        }
Exemple #4
0
        private void FinishEmpBtn_Click(object sender, EventArgs e)
        {
            emp.name      = FnameTextbox.Text + " " + LnameTextbox.Text;
            emp.password  = PassTextbox.Text;
            emp.phone     = PhoneNumTextbox.Text;
            emp.rank      = RankTextBox.Text;
            emp.salary    = Convert.ToInt16(SalaryTextbox.Text);
            emp.gender    = gender;
            emp.address   = AddressTextbox.Text;
            emp.admin_id  = 1;
            emp.join_date = Convert.ToDateTime(JoinDatePicker.Text);
            //  MessageBox.Show(emp.join_date.ToString());
            emp.mail = EmailTextbox.Text;
            AdminClass newmanger = new AdminClass();

            newmanger.addmanager(emp);

            FnameTextbox.Clear();
            LnameTextbox.Clear();
            PassTextbox.Clear();
            PhoneNumTextbox.Clear();
            SalaryTextbox.Clear();
            MaleCheck.Checked   = false;
            FemaleCheck.Checked = false;
            AddressTextbox.Clear();
            EmailTextbox.Clear();
            RankTextBox.Text = "";
            MessageBox.Show("Employee Added Successfully");
        }
Exemple #5
0
        public AdminForm()
        {
            InitializeComponent();

            flowLayoutPanel1.Controls.Clear();
            OnHome.Visible     = true;
            OnAddMng.Visible   = false;
            OnAddProj.Visible  = false;
            OnViewEmp.Visible  = false;
            OnViewProj.Visible = false;


            AdminClass          projectlist = new AdminClass();
            List <ProjectClass> list        = new List <ProjectClass>();

            projectlist.projectview(ref list);
            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].status != "Finish")
                {
                    ViewProjUC view = new ViewProjUC(list[i]);
                    view.ProjectName.Text   = list[i].name;
                    view.TaskEmpLabel.Text  = list[i].manger_name;
                    view.startDuration.Text = "Start on " + list[i].start_time.Day + " / " + list[i].start_time.Month + " / " + list[i].start_time.Year;
                    view.endDuration.Text   = "End on " + list[i].end_time.Day + " / " + list[i].end_time.Month + " / " + list[i].end_time.Year;
                    flowLayoutPanel1.Controls.Add(view);
                }
            }
        }
Exemple #6
0
        private void deleteEmpLabelBtn_MouseClick(object sender, MouseEventArgs e)
        {
            AdminClass adm = new AdminClass();

            adm.delete_employee(_id);
            MessageBox.Show("Deleted Successfully");
        }
Exemple #7
0
        public void finishproject(int id)
        {
            AdminClass   adm = new AdminClass();
            ProjectClass pro = new ProjectClass();

            adm.projectview(ref list);
            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].id == id)
                {
                    pro = list[i];
                    break;
                }
            }
            SqlConnection connect = new SqlConnection(connectstr);
            SqlCommand    cmd     = new SqlCommand("select dbo.check_finish('" + pro.id + "')", connect);

            try
            {
                connect.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    pro.status = reader.GetString(0);
                }
                reader.Close();
                SqlCommand cmd2 = new SqlCommand("execute edit_project '" + pro.id + "', '" + pro.name + "', '" + pro.description + "', '" + pro.start_time + "', '" + pro.end_time + "', '" + pro.status + "'", connect);
                cmd2.ExecuteNonQuery();
                connect.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #8
0
        private void deleteprojectbtn_MouseClick(object sender, MouseEventArgs e)
        {
            AdminClass adm = new AdminClass();

            adm.delete_project(_id);
            MessageBox.Show("Deleted Successfully");
        }
Exemple #9
0
        private void FinishProjBtn_Click(object sender, EventArgs e)
        {
            ProjectClass pro = new ProjectClass();

            pro.name         = ProjNameTextbox.Text;
            pro.start_time   = Convert.ToDateTime(startTime.Text);
            pro.end_time     = Convert.ToDateTime(EndTime.Text);
            pro.clinet_name  = cNameBox.Text;
            pro.client_mail  = cMailBox.Text;
            pro.status       = "running";
            pro.client_phone = cPhoneBox.Text;
            for (int i = 0; i < managername.Count; i++)
            {
                if (managername[i].name == comboBox1.Text)
                {
                    pro.id_manger = managername[i].id;
                    break;
                }
            }
            pro.description = ProjDescription.Text;
            AdminClass adm = new AdminClass();

            adm.addproject(pro);

            ProjNameTextbox.Clear();
            cNameBox.Clear();
            cMailBox.Clear();
            cPhoneBox.Clear();
            ProjDescription.Clear();
            comboBox1.Text = "";
            MessageBox.Show("Project Added Successfully");
        }
Exemple #10
0
        private void MoreLabelBtn_MouseClick(object sender, MouseEventArgs e)
        {
            projInfo.Hide();
            editProj.Hide();
            tasksPanel.Size       = new Size(850, 400);
            tasksPanel.AutoScroll = true;
            tasksPanel.Location   = new Point(350, 200);
            tasksPanel.BackColor  = Color.Silver;
            ParentForm.Controls.Add(tasksPanel);
            tasksPanel.Controls.Clear();
            tasksPanel.Show();
            tasksPanel.BringToFront();
            //here
            AdminClass       adm      = new AdminClass();
            List <TaskClass> tasklist = new List <TaskClass>();

            adm.showtask(ref tasklist, project.id);
            for (int i = 0; i < tasklist.Count; i++)
            {
                ViewTasksUC task = new ViewTasksUC();
                task.taskStatus.Visible      = true;
                task.InfoLabelBtn.Visible    = false;
                task.AssignLabelBtn.Visible  = false;
                task.CommentLabelBtn.Visible = false;
                task.TaskFinishedBtn.Visible = false;
                //here
                task.TaskName.Text      = tasklist[i].name;
                task.ProjectName.Text   = tasklist[i].project_name;
                task.TaskEmpLabel.Text  = tasklist[i].employee_name;
                task.startDuration.Text = "Start on " + tasklist[i].start_time.Day + " / " + tasklist[i].start_time.Month + " / " + tasklist[i].start_time.Year;
                task.endDuration.Text   = "End on " + tasklist[i].end_time.Day + " / " + tasklist[i].end_time.Month + " / " + tasklist[i].end_time.Year;
                task.taskStatus.Text    = tasklist[i].status;
                tasksPanel.Controls.Add(task);
            }
        }
Exemple #11
0
        private void loginBtn_MouseClick(object sender, MouseEventArgs e)
        {
            if (isAdmin)
            {
                AdminClass admin   = new AdminClass();
                bool       isadmin = admin.loginadmin(usernameTextbox.Text, passwordTextbox.Text, ref admin);
                if (isadmin)
                {
                    this.Hide();
                    AdminForm showAdmin = new AdminForm();

                    showAdmin.WelcomeLabel.Text = "Welcome, " + admin.username;
                    showAdmin.Show();
                }
                else
                {
                    MessageBox.Show("invalid name and password");
                }
            }

            else if (isManager)
            {
                EmployeeClass manager    = new EmployeeClass();
                bool          isemanager = manager.login(usernameTextbox.Text, passwordTextbox.Text, "Manager", ref manager);
                if (isemanager == true)
                {
                    this.Hide();
                    ManagerForm showManager = new ManagerForm(manager.id);
                    showManager.empnow            = manager;
                    showManager.WelcomeLabel.Text = "welcome, " + manager.name;
                    showManager.Show();
                }
                else
                {
                    MessageBox.Show("invalid username and password");
                }
            }

            else if (isEmployee)
            {
                EmployeeClass employee   = new EmployeeClass();
                bool          isemanager = employee.login(usernameTextbox.Text, passwordTextbox.Text, "Employee", ref employee);
                if (isemanager == true)
                {
                    this.Hide();
                    EmployeeForm showEmployee = new EmployeeForm(employee);
                    showEmployee.empnow            = employee;
                    showEmployee.WelcomeLabel.Text = "welcome, " + employee.name;
                    showEmployee.Show();
                }
                else
                {
                    MessageBox.Show("invalid username and password");
                }
            }
        }
Exemple #12
0
        private void AddProjUC_Load(object sender, EventArgs e)
        {
            AdminClass adm = new AdminClass();

            managername = adm.viewmanager();
            for (int i = 0; i < managername.Count; i++)
            {
                if (managername[i].rank == "Manager")
                {
                    comboBox1.Items.Add(managername[i].name);
                }
            }
        }
Exemple #13
0
        private void Finisheditbtn_MouseClick(object sender, MouseEventArgs e)
        {
            ProjectClass pro = new ProjectClass();

            pro.id          = project_id;
            pro.name        = ProjNameTextbox.Text;
            pro.start_time  = Convert.ToDateTime(startTime.Text);
            pro.end_time    = Convert.ToDateTime(EndTime.Text);
            pro.description = ProjDescription.Text;
            AdminClass adm = new AdminClass();

            adm.editproject(pro);
            MessageBox.Show("Edited Successfully");
            this.Hide();
        }
Exemple #14
0
        private void editemployee_Click(object sender, EventArgs e)
        {
            emp.name      = FnameTextbox.Text + " " + LnameTextbox.Text;
            emp.password  = PassTextbox.Text;
            emp.phone     = PhoneNumTextbox.Text;
            emp.rank      = RankTextBox.Text;
            emp.salary    = Convert.ToInt16(SalaryTextbox.Text);
            emp.gender    = gender;
            emp.address   = AddressTextbox.Text;
            emp.join_date = Convert.ToDateTime(JoinDatePicker.Text);
            emp.admin_id  = 1;
            AdminClass adm = new AdminClass();

            adm.edit_employee(emp);

            MessageBox.Show("Employee Edited Successfully");
        }
Exemple #15
0
        private void ViewMngBtn_MouseClick(object sender, MouseEventArgs e)
        {
            FlowLayoutPanel empViewPanel = new FlowLayoutPanel();

            AdminClass           adm     = new AdminClass();
            List <EmployeeClass> emplist = adm.viewmanager();

            ViewProjUC.projInfo.Hide();
            ViewProjUC.editProj.Hide();
            ViewEmpUC.editData.Hide();
            ViewProjUC.tasksPanel.Hide();
            flowLayoutPanel1.Controls.Clear();
            flowLayoutPanel1.BringToFront();
            OnHome.Visible     = false;
            OnAddMng.Visible   = false;
            OnAddProj.Visible  = false;
            OnViewEmp.Visible  = true;
            OnViewProj.Visible = false;

            SplitContainer empViewCont = new SplitContainer();

            empViewCont.Dock             = DockStyle.Fill;
            empViewCont.Orientation      = Orientation.Horizontal;
            empViewCont.SplitterDistance = 50;
            empViewCont.BorderStyle      = BorderStyle.FixedSingle;
            empViewCont.FixedPanel       = FixedPanel.Panel1;
            splitContainer2.Panel2.Controls.Add(empViewCont);
            empViewCont.BringToFront();

            TextBox search = new TextBox();

            search.Size     = new Size(300, 25);
            search.Text     = "Search";
            search.Location = new Point(450, 13);
            empViewCont.Panel1.Controls.Add(search);
            //search.TextChanged += new EventHandler(txtFilter_TextChanged);

            ////search
            //void txtFilter_TextChanged(object textsender, EventArgs texte)
            //{
            //    empViewPanel.Controls.Clear();
            //    // Never get here
            //    for (int i = 0; i < emplist.Count; i++)
            //    {
            //        if (emplist[i].name.Contains(search.Text))
            //        {
            //            ViewEmpUC viewEmp = new ViewEmpUC();
            //            string fname = "", lname = "";
            //            int j;
            //            for (j = 0; j < emplist[i].name.Length; j++)
            //            {
            //                if (emplist[i].name[j] == ' ')
            //                    break;
            //                fname += emplist[i].name[j];
            //            }
            //            for (; j < emplist[i].name.Length; j++)
            //            {
            //                lname += emplist[i].name[j];
            //            }
            //            viewEmp.ViewFName.Text = "First name : " + fname;
            //            viewEmp.ViewLName.Text = "Last name : " + lname;
            //            viewEmp.ViewGender.Text = "Gender : " + emplist[i].gender;
            //            viewEmp.ViewHours.Text = "Hours : " + emplist[i].hours;
            //            viewEmp.ViewJoinDate.Text = "Join Date : " + emplist[i].join_date.ToString();
            //            viewEmp.ViewSalary.Text = "Salary : " + (emplist[i].hours * emplist[i].salary).ToString();
            //            viewEmp.viewRank.Text = "Rank : " + emplist[i].rank;
            //            viewEmp.ViewPhoneNum.Text = "Phone : " + emplist[i].phone;
            //            viewEmp.ViewEmail.Text = "Email : " + emplist[i].mail;
            //            viewEmp.ViewAddress.Text = "Address : " + emplist[i].address;
            //            viewEmp.closeBtn.Visible = false;
            //            if (emplist[i].rank == "Manager")
            //                viewEmp.deleteEmpLabelBtn.Visible = false;
            //            viewEmp._id = emplist[i].id;
            //            viewEmp.emp = emplist[i];
            //            empViewPanel.Controls.Add(viewEmp);

            //        }

            //    }

            //}


            empViewPanel.Controls.Clear();
            empViewPanel.Dock          = DockStyle.Fill;
            empViewPanel.AutoScroll    = true;
            empViewPanel.FlowDirection = FlowDirection.LeftToRight;
            empViewCont.Panel2.Controls.Add(empViewPanel);

            // ViewEmpUC viewEmp = new ViewEmpUC();
            //empViewPanel.Controls.Add(viewEmp);

            for (int i = 0; i < emplist.Count; i++)
            {
                ViewEmpUC viewEmp = new ViewEmpUC();
                string    fname = "", lname = "";
                int       j;
                for (j = 0; j < emplist[i].name.Length; j++)
                {
                    if (emplist[i].name[j] == ' ')
                    {
                        break;
                    }
                    fname += emplist[i].name[j];
                }
                for (; j < emplist[i].name.Length; j++)
                {
                    lname += emplist[i].name[j];
                }
                viewEmp.ViewFName.Text    = "First name : " + fname;
                viewEmp.ViewLName.Text    = "Last name : " + lname;
                viewEmp.ViewGender.Text   = "Gender : " + emplist[i].gender;
                viewEmp.ViewHours.Text    = "Hours : " + emplist[i].hours;
                viewEmp.ViewJoinDate.Text = "Join Date : " + emplist[i].join_date.Day + " / " + emplist[i].join_date.Month + " / " + emplist[i].join_date.Year;
                viewEmp.ViewSalary.Text   = "Salary : " + (emplist[i].hours * emplist[i].salary).ToString();
                viewEmp.viewRank.Text     = "Rank : " + emplist[i].rank;
                viewEmp.ViewPhoneNum.Text = "Phone : " + emplist[i].phone;
                viewEmp.ViewEmail.Text    = "Email : " + emplist[i].mail;
                viewEmp.ViewAddress.Text  = "Address : " + emplist[i].address;
                viewEmp.closeBtn.Visible  = false;
                if (emplist[i].rank == "Manager")
                {
                    viewEmp.deleteEmpLabelBtn.Visible = false;
                }
                viewEmp._id = emplist[i].id;
                viewEmp.emp = emplist[i];
                empViewPanel.Controls.Add(viewEmp);
            }
        }