private void saveButton(object sender, EventArgs e)
 {
     if (isValid())
     {
         if (Project == null)
         {
             Project = new InvestProject();
         }
         Project.nameProject = textBoxNameStage.Text;
         Project.numberProject = textBoxNumberProject.Text;
         Project.dateBegin = dateBeginPlan.Value;
         Project.dateEnd = dateEndPlan.Value;
         Project.dateBeginProg = dateBeginProg.Value;
         Project.dateEndProg = dateEndProg.Value;
         UserDAO daoUser = new UserDAO();
         DepartmentDAO daoDepartment = new DepartmentDAO();
         InvestProjectDAO projectDAO = new InvestProjectDAO();
         Project.user = daoUser.getById(Convert.ToInt32(((KeyValuePair)comboBoxUser.SelectedItem).Key));
         Project.department = daoDepartment.getById(Convert.ToInt32(((KeyValuePair)comboBoxDepartment.SelectedItem).Key));
         
         if (Project.idProject != 0)
         {
             projectDAO.update(Project);
         }
         else
         {
             projectDAO.insert(Project);
         }
         this.Close();
     }
 }
        public void initializationInvestProject()
        {
            BindingSource    bindingSource = new BindingSource();
            InvestProjectDAO dao           = new InvestProjectDAO();

            bindingSource.Clear();
            bindingSource.DataSource          = dao.getAll();
            dataGridInvestProject.DataSource  = bindingSource;
            bindingSource.CurrentItemChanged += BindingSource_CurrentItemChanged;

            if ((ScrollIndex >= 0) && (dataGridInvestProject.Rows.Count > 0))
            {
                dataGridInvestProject.FirstDisplayedScrollingRowIndex = ScrollIndex;
            }
            if (BookMarkInvestProject != 0)
            {
                dataGridInvestProject.Rows[BookMarkInvestProject].Selected = true;
                bindingSource.Position = BookMarkInvestProject;
            }
            else
            {
                if (bindingSource.Count > 0)
                {
                    bindingSource.MoveNext();
                    bindingSource.MoveFirst();
                }
                //dataGridInvestProject.Rows[1].Selected = true;
            }
        }
Ejemplo n.º 3
0
        public void updateStageProject()
        {
            TreeModel model = new TreeModel();

            treeProject.Model = model;

            treeProject.BeginUpdate();
            InvestProjectDAO     daoProject   = new InvestProjectDAO();
            StageProjectDAO      dao          = new StageProjectDAO();
            List <InvestProject> listProject  = daoProject.getAll();
            List <StageProject>  listStage    = null;
            List <StageProject>  listSubStage = null;

            foreach (InvestProject project in listProject)
            {
                listStage    = dao.getByProject(project.idProject);
                listSubStage = dao.getSubStageProject(project.idProject);
                Node nodeProject = new StageProjectNode(project.nameProject, "", project.dateBegin.ToShortDateString(), project.dateEnd.ToShortDateString(), project.dateBeginProg.ToShortDateString(), project.dateEndProg.ToShortDateString(), "", "", "", "", null);
                foreach (StageProject stage in listStage)
                {
                    Node node = new StageProjectNode(stage.NameStage, stage.CommentUser, stage.DateBeginPlan.ToShortDateString(), stage.DateEndPlan.ToShortDateString(), stage.DateBeginProg.ToShortDateString(), stage.DateEndProg.ToShortDateString(), stage.DateBeginUser.ToShortDateString(), stage.DateEndUser.ToShortDateString(), stage.User.FullName, stage.StatusStage.ToString(), stage);
                    nodeProject.Nodes.Add(node);
                    foreach (StageProject child in stage.SubStage)
                    {
                        Node childNode = new StageProjectNode(child.NameStage, child.CommentUser, child.DateBeginPlan.ToShortDateString(), child.DateEndPlan.ToShortDateString(), child.DateBeginProg.ToShortDateString(), child.DateEndProg.ToShortDateString(), child.DateBeginUser.ToShortDateString(), child.DateEndUser.ToShortDateString(), child.User.FullName, child.StatusStage.ToString(), child);
                        node.Nodes.Add(childNode);
                    }
                    model.Nodes.Add(nodeProject);
                }
            }

            treeProject.EndUpdate();
        }
Ejemplo n.º 4
0
        private void saveButton(object sender, EventArgs e)
        {
            if (isValid())
            {
                if (Project == null)
                {
                    Project = new InvestProject();
                }
                Project.nameProject   = textBoxNameStage.Text;
                Project.numberProject = textBoxNumberProject.Text;
                Project.dateBegin     = dateBeginPlan.Value;
                Project.dateEnd       = dateEndPlan.Value;
                Project.dateBeginProg = dateBeginProg.Value;
                Project.dateEndProg   = dateEndProg.Value;
                UserDAO          daoUser       = new UserDAO();
                DepartmentDAO    daoDepartment = new DepartmentDAO();
                InvestProjectDAO projectDAO    = new InvestProjectDAO();
                Project.user       = daoUser.getById(Convert.ToInt32(((KeyValuePair)comboBoxUser.SelectedItem).Key));
                Project.department = daoDepartment.getById(Convert.ToInt32(((KeyValuePair)comboBoxDepartment.SelectedItem).Key));

                if (Project.idProject != 0)
                {
                    projectDAO.update(Project);
                }
                else
                {
                    projectDAO.insert(Project);
                }
                this.Close();
            }
        }
        private void deleteInvestProjectMenu(object sender, EventArgs e)
        {
            InvestProject ip = (InvestProject)dataGridInvestProject.CurrentRow.DataBoundItem;

            if (MessageBox.Show("Вы действительно хотите удалить проект и все связанные с ним данные ?", "Удаление", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                InvestProjectDAO dao = new InvestProjectDAO();
                dao.delete(ip);
                initializationInvestProject();
            }
        }
Ejemplo n.º 6
0
        public void updateProjectTreeView()
        {
            TreeNode root = new TreeNode();

            treeViewProject.Nodes.Clear();
            InvestProjectDAO     daoProject   = new InvestProjectDAO();
            StageProjectDAO      dao          = new StageProjectDAO();
            List <InvestProject> listProject  = daoProject.getAll();
            List <StageProject>  listStage    = null;
            List <StageProject>  listSubStage = null;
            TreeNode             nodeRoot     = new TreeNode("Проекты");

            nodeRoot.Tag = new InvestProject();
            foreach (InvestProject project in listProject)
            {
                listStage    = dao.getByProject(project.idProject);
                listSubStage = dao.getSubStageProject(project.idProject);
                TreeNode nodeProject = new TreeNode(String.Format("Проект: {0} || Дата начала {1} || Дата завершения {2} || Дана начала(прогноз) {3} || Дата завершения(прогноз) {4}", project.nameProject, project.dateBegin.ToShortDateString(), project.dateEnd.ToShortDateString(), project.dateBeginProg.ToShortDateString(), project.dateEndProg.ToShortDateString()));
                nodeProject.Tag = project;
                foreach (StageProject stage in listStage)
                {
                    TreeNode node = new TreeNode(String.Format("Этап: {0} || Дата начала {1} || Дата завершения {2} || Дана начала(прогноз) {3} || Дата завершения(прогноз) {4} || Ответственный {5} || Дата начала(ответств) {6} || Дата завершения(ответств) {7}",
                                                               stage.NameStage, stage.DateBeginPlan.ToShortDateString(), stage.DateEndPlan.ToShortDateString(), stage.DateBeginProg.ToShortDateString(), stage.DateEndProg.ToShortDateString(),
                                                               stage.User.FullName, stage.DateBeginUser.ToShortDateString(), stage.DateEndUser.ToShortDateString()));
                    node.Tag = stage;
                    nodeProject.Nodes.Add(node);
                    foreach (StageProject child in stage.SubStage)
                    {
                        TreeNode childNode = new TreeNode(String.Format("Этап: {0} || Дата начала {1} || Дата завершения {2} || Дана начала(прогноз) {3} || Дата завершения(прогноз) {4} || Ответственный {5} || Дата начала(ответств) {6} || Дата завершения(ответств) {7}",
                                                                        child.NameStage, child.DateBeginPlan.ToShortDateString(), child.DateEndPlan.ToShortDateString(), child.DateBeginProg.ToShortDateString(), child.DateEndProg.ToShortDateString(),
                                                                        child.User.FullName, child.DateBeginUser.ToShortDateString(), child.DateEndUser.ToShortDateString()));
                        childNode.Tag = child;
                        node.Nodes.Add(childNode);
                    }
                }
                nodeRoot.Nodes.Add(nodeProject);
            }
            treeViewProject.Nodes.Add(nodeRoot);
            treeProject.EndUpdate();
        }
        public void updateProjectTreeView()
        {
            TreeNode root = new TreeNode();

            treeViewProject.Nodes.Clear();
            InvestProjectDAO daoProject = new InvestProjectDAO();
            StageProjectDAO dao = new StageProjectDAO();
            List<InvestProject> listProject = daoProject.getAll();
            List<StageProject> listStage = null;
            List<StageProject> listSubStage = null;
            TreeNode nodeRoot = new TreeNode("Проекты");
            nodeRoot.Tag = new InvestProject();
            foreach (InvestProject project in listProject)
            {
                listStage = dao.getByProject(project.idProject);
                listSubStage = dao.getSubStageProject(project.idProject);
                TreeNode nodeProject = new TreeNode(String.Format("Проект: {0} || Дата начала {1} || Дата завершения {2} || Дана начала(прогноз) {3} || Дата завершения(прогноз) {4}",project.nameProject, project.dateBegin.ToShortDateString(), project.dateEnd.ToShortDateString(), project.dateBeginProg.ToShortDateString(), project.dateEndProg.ToShortDateString()));
                nodeProject.Tag = project;
                foreach (StageProject stage in listStage)
                {
                    TreeNode node = new TreeNode(String.Format("Этап: {0} || Дата начала {1} || Дата завершения {2} || Дана начала(прогноз) {3} || Дата завершения(прогноз) {4} || Ответственный {5} || Дата начала(ответств) {6} || Дата завершения(ответств) {7}", 
                        stage.NameStage, stage.DateBeginPlan.ToShortDateString(), stage.DateEndPlan.ToShortDateString(), stage.DateBeginProg.ToShortDateString(), stage.DateEndProg.ToShortDateString(),
                        stage.User.FullName, stage.DateBeginUser.ToShortDateString(), stage.DateEndUser.ToShortDateString()));
                    node.Tag = stage;
                    nodeProject.Nodes.Add(node);
                    foreach (StageProject child in stage.SubStage)
                    {
                        TreeNode childNode = new TreeNode(String.Format("Этап: {0} || Дата начала {1} || Дата завершения {2} || Дана начала(прогноз) {3} || Дата завершения(прогноз) {4} || Ответственный {5} || Дата начала(ответств) {6} || Дата завершения(ответств) {7}",
                            child.NameStage, child.DateBeginPlan.ToShortDateString(), child.DateEndPlan.ToShortDateString(), child.DateBeginProg.ToShortDateString(), child.DateEndProg.ToShortDateString(),
                            child.User.FullName, child.DateBeginUser.ToShortDateString(), child.DateEndUser.ToShortDateString()));
                        childNode.Tag = child;
                        node.Nodes.Add(childNode);
                    }
                }
                nodeRoot.Nodes.Add(nodeProject);
                
            }
            treeViewProject.Nodes.Add(nodeRoot);
            treeProject.EndUpdate();
        }
        public void updateStageProject()
        {
            TreeModel model = new TreeModel();
            treeProject.Model = model;
            
            treeProject.BeginUpdate();
            InvestProjectDAO daoProject = new InvestProjectDAO();
            StageProjectDAO dao = new StageProjectDAO();
            List<InvestProject> listProject = daoProject.getAll();
            List<StageProject> listStage = null;
            List<StageProject> listSubStage = null;
            foreach (InvestProject project in listProject)
            {
                listStage = dao.getByProject(project.idProject);
                listSubStage = dao.getSubStageProject(project.idProject);
                Node nodeProject = new StageProjectNode(project.nameProject, "", project.dateBegin.ToShortDateString(), project.dateEnd.ToShortDateString(), project.dateBeginProg.ToShortDateString(), project.dateEndProg.ToShortDateString(), "", "", "","", null);
                foreach (StageProject stage in listStage)
                {
                    Node node = new StageProjectNode(stage.NameStage, stage.CommentUser, stage.DateBeginPlan.ToShortDateString(), stage.DateEndPlan.ToShortDateString(), stage.DateBeginProg.ToShortDateString(), stage.DateEndProg.ToShortDateString(), stage.DateBeginUser.ToShortDateString(), stage.DateEndUser.ToShortDateString(), stage.User.FullName, stage.StatusStage.ToString(), stage);
                    nodeProject.Nodes.Add(node);
                    foreach (StageProject child in stage.SubStage)
                    {
                        Node childNode = new StageProjectNode(child.NameStage, child.CommentUser, child.DateBeginPlan.ToShortDateString(), child.DateEndPlan.ToShortDateString(), child.DateBeginProg.ToShortDateString(), child.DateEndProg.ToShortDateString(), child.DateBeginUser.ToShortDateString(), child.DateEndUser.ToShortDateString(), child.User.FullName, child.StatusStage.ToString(), child);
                        node.Nodes.Add(childNode);
                    }
                    model.Nodes.Add(nodeProject);
                }
            }

            treeProject.EndUpdate();
        }
 private void deleteInvestProjectMenu(object sender, EventArgs e)
 {
     InvestProject ip = (InvestProject)dataGridInvestProject.CurrentRow.DataBoundItem;
     if (MessageBox.Show("Вы действительно хотите удалить проект и все связанные с ним данные ?", "Удаление",MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         InvestProjectDAO dao = new InvestProjectDAO();
         dao.delete(ip);
         initializationInvestProject();
     }
 }
 public void initializationInvestProject()
 {
     BindingSource bindingSource = new BindingSource();
     InvestProjectDAO dao = new InvestProjectDAO();
     bindingSource.Clear();
     bindingSource.DataSource = dao.getAll();
     dataGridInvestProject.DataSource = bindingSource;
     bindingSource.CurrentItemChanged += BindingSource_CurrentItemChanged;
     
     if ((ScrollIndex >=0) && (dataGridInvestProject.Rows.Count > 0))
     {
         dataGridInvestProject.FirstDisplayedScrollingRowIndex = ScrollIndex;
     }
     if (BookMarkInvestProject != 0)
     {
         dataGridInvestProject.Rows[BookMarkInvestProject].Selected = true;
         bindingSource.Position = BookMarkInvestProject;
     }
     else
     {
         if (bindingSource.Count > 0)
         {
             bindingSource.MoveNext();
             bindingSource.MoveFirst();
         }
         //dataGridInvestProject.Rows[1].Selected = true;
     }
 }