Beispiel #1
0
        private void Close_Click(object sender, EventArgs e)
        {
            if (ProjectID.SelectedItem == null || UserID.SelectedItem == null || TaskID.SelectedItem == null)
            {
                MessageBox.Show("All Fields Are Requierd");
                return;
            }

            int     projectId  = Tools.getId(ProjectID.SelectedItem.ToString());
            int     employeeId = Tools.getId(UserID.SelectedItem.ToString());
            int     taskId     = Tools.getId(TaskID.SelectedItem.ToString());
            EmpTask empTask    = Tools.getTask(projectId, employeeId, taskId);

            empTask.close = true;
            Project.writeProjects();
            MessageBox.Show("Task: " + taskId + " Has Been Closed");
            loadData();
            Employee employee = Tools.getEmployee(projectId, employeeId);

            foreach (EmpTask empTask2 in employee.tasksOfEmp)
            {
                if (!empTask2.close)
                {
                    TaskID.Items.Add(empTask2.name + "(" + empTask2.id + ")");
                }
            }
        }
        private void Create_Click(object sender, EventArgs e)
        {
            if (UserID.SelectedItem == null || ProjectID.SelectedItem == null || name.Text == "" || Description.Text == "")
            {
                MessageBox.Show("All Fileds Are Requierd");
                return;
            }

            int     projectId  = Tools.getId(ProjectID.SelectedItem.ToString());
            int     employeeId = Tools.getId(UserID.SelectedItem.ToString());
            EmpTask empTask    = new EmpTask();

            empTask.id          = Tools.getNumberOfTasks();
            empTask.name        = name.Text;
            empTask.description = Description.Text;

            Employee employee = Tools.getEmployee(projectId, employeeId);

            employee.tasksOfEmp.Add(empTask);
            Project.writeProjects();
            MessageBox.Show("Task " + name.Text + " Has Been Added");
            name.Text        = "";
            Description.Text = "";
        }
Beispiel #3
0
        private void button6_Click(object sender, EventArgs e)
        {
            ///
            Employee      em = new Employee();
            FileStream    ss = new FileStream("test.xml", FileMode.OpenOrCreate);
            XmlSerializer xm = new XmlSerializer(em.GetType());

            //em.name = "mohamed";
            ////em.id = 10;
            xm.Serialize(ss, em);
            ///
            List <Project> listOfproj = new List <Project>();
            Project        p          = new Project();
            EmpTask        t          = new EmpTask();

            p.id          = 1;
            p.name        = "chess";
            p.description = "lablablaaa";
            //em.id = 11;
            //em.name = "abdo";
            //t.id = 111;
            //t.name = "checkmyking";
            //t.description = "discc";
            //t.comment = "ya doc";

            //t.attachment.Add("hat file");

            //em.tasksOfEmp.Add(t);
            //p.emploees.Add(em);
            listOfproj.Add(p);

            XmlSerializer ser = new XmlSerializer(listOfproj.GetType());
            FileStream    f   = new FileStream("myfile.xml", FileMode.OpenOrCreate);

            ser.Serialize(f, listOfproj);
            f.Close();

            /// load projects into the combobox
            List <Project> list = new List <Project>();
            XmlSerializer  xs   = new XmlSerializer(list.GetType());
            FileStream     fs   = new FileStream("myfile.xml", FileMode.OpenOrCreate);

            list = (List <Project>)xs.Deserialize(fs);
            fs.Close();

            /*for (int i = 0; i < list.Count; i++)
             * {
             *  combopro.Items.Add(list[i].name + " " + list[i].id + "\n");
             * }*/

            /// add employees to employees file
            List <Employee> lis = new List <Employee>();
            Employee        emp = new Employee();

            emp.id   = 5;
            emp.name = "mohamed";
            lis.Add(emp);
            emp      = new Employee();
            emp.name = "ahmed";
            emp.id   = 7;
            lis.Add(emp);
            FileStream    fss = new FileStream("employees.xml", FileMode.OpenOrCreate);
            XmlSerializer xss = new XmlSerializer(lis.GetType());

            xss.Serialize(fss, lis);
            fss.Close();

            /// load employees into comboemp

            FileStream    ff     = new FileStream("employees.xml", FileMode.OpenOrCreate);
            XmlSerializer xmlser = new XmlSerializer(lis.GetType());

            lis = (List <Employee>)xmlser.Deserialize(ff);

            /*for(int i = 0; i < lis.Count; i++)
             * {
             *  comboemp.Items.Add(lis[i].name + " " + lis[i].id);
             * }*/
            ff.Close();
        }