private void mnuInvestPrint_Click(object sender, EventArgs e)
        {
            InvestProject project = getCurrentProject();

            ReportGenerate.
            PrintExcelProject(project);
        }
        private void mnuEditStage_Click(object sender, EventArgs e)
        {
            generateBookMark();
            DialogStageProject dialog = new DialogStageProject();
            TreeModel          model  = (TreeModel)treeViewAdv1.Model;

            if (model != null && treeViewAdv1.SelectedNode != null)
            {
                StageProject stage;
                if (treeViewAdv1.SelectedNode.Parent.Index >= 0)
                {
                    stage = ((StageProjectNode)model.Nodes[treeViewAdv1.SelectedNode.Parent.Index].Nodes[treeViewAdv1.SelectedNode.Index]).stage;
                }
                else
                {
                    stage = ((StageProjectNode)model.Nodes[treeViewAdv1.SelectedNode.Index]).stage;
                }
                dialog.setStageProject(stage);
                if (dataGridInvestProject.CurrentRow.DataBoundItem != null && dataGridInvestProject.CurrentRow.DataBoundItem.GetType() == typeof(InvestProject))
                {
                    InvestProject ip = (InvestProject)dataGridInvestProject.CurrentRow.DataBoundItem;
                    dialog.idProject = ip.idProject;
                }

                dialog.ShowDialog();
                initializationInvestProject();
                updateStageProject();
            }
        }
Ejemplo n.º 3
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 InvestProject getCurrentProject()
        {
            InvestProject ip = null;

            if (dataGridInvestProject.CurrentRow.DataBoundItem != null && dataGridInvestProject.CurrentRow.DataBoundItem.GetType() == typeof(InvestProject))
            {
                ip = (InvestProject)dataGridInvestProject.CurrentRow.DataBoundItem;
            }
            return(ip);
        }
        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 showDialogStage()
        {
            generateBookMark();
            DialogStageProject dialog = new DialogStageProject();

            if (dataGridInvestProject.CurrentRow.DataBoundItem != null && dataGridInvestProject.CurrentRow.DataBoundItem.GetType() == typeof(InvestProject))
            {
                InvestProject ip = (InvestProject)dataGridInvestProject.CurrentRow.DataBoundItem;
                dialog.idProject = ip.idProject;
            }
            dialog.ShowDialog();
            initializationInvestProject();
            updateStageProject();
        }
Ejemplo n.º 7
0
 public void setProject(InvestProject editProject)
 {
     Project = editProject;
     if (Project != null)
     {
         textBoxNameStage.Text           = Project.nameProject;
         textBoxNumberProject.Text       = Project.numberProject;
         dateBeginPlan.Value             = Project.dateBegin;
         dateEndPlan.Value               = Project.dateEnd;
         dateBeginProg.Value             = Project.dateBeginProg;
         dateEndProg.Value               = Project.dateEndProg;
         textBoxAbout.Text               = Project.aboutProject;
         comboBoxDepartment.SelectedItem = new KeyValuePair(Project.department.idDepartment.ToString(), Project.department.nameDepartment);
         comboBoxUser.SelectedItem       = new KeyValuePair(Project.user.Id.ToString(), Project.user.FullName);
     }
 }
        public void showDialogInvestProject()
        {
            generateBookMark();
            DialogInvestProject dialog = new DialogInvestProject();

            try
            {
                if (dataGridInvestProject.CurrentRow.DataBoundItem != null && dataGridInvestProject.CurrentRow.DataBoundItem.GetType() == typeof(InvestProject))
                {
                    InvestProject ip = (InvestProject)dataGridInvestProject.CurrentRow.DataBoundItem;
                    dialog.setProject(ip);
                }
            }
            catch (Exception error)
            {
                //TODO;
                //throw new Exception();
            }
            dialog.ShowDialog();
            initializationInvestProject();
        }
 public void updateStageProject()
 {
     if (dataGridInvestProject.CurrentRow.DataBoundItem != null)
     {
         InvestProject       ip           = (InvestProject)((BindingSource)dataGridInvestProject.DataSource).Current;
         StageProjectDAO     dao          = new StageProjectDAO();
         List <StageProject> listProject  = dao.getByProject(ip.idProject);
         List <StageProject> listSubStage = dao.getSubStageProject(ip.idProject);
         TreeModel           model        = new TreeModel();
         treeViewAdv1.Model = model;
         treeViewAdv1.BeginUpdate();
         foreach (StageProject stage in listProject)
         {
             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);
             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(node);
         }
         treeViewAdv1.EndUpdate();
     }
 }
Ejemplo n.º 10
0
        public static void PrintExcelProject(Object objectProject)
        {
            InvestProject project = null;

            if (objectProject.GetType() == typeof(InvestProject))
            {
                project = (InvestProject)objectProject;
            }
            else
            {
                return;
            }

            Excel.Application xlApp = new Excel.Application();
            if (xlApp == null)
            {
                MessageBox.Show("Не удалось создать Excel документ");
                return;
            }
            Excel.Workbook  xlWorkBook;
            Excel.Worksheet xlWorkSheet;
            object          misValue = System.Reflection.Missing.Value;

            xlWorkBook  = xlApp.Workbooks.Add(misValue);
            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.Item[1];

            xlWorkSheet.Cells[4, 2]  = "# СОВА";
            xlWorkSheet.Cells[4, 3]  = "Производство";
            xlWorkSheet.Cells[4, 4]  = "Мероприятие";
            xlWorkSheet.Cells[4, 5]  = "Этап";
            xlWorkSheet.Cells[4, 6]  = "Ответственный";
            xlWorkSheet.Cells[4, 7]  = "Начало(план)";
            xlWorkSheet.Cells[4, 8]  = "Окончание(план)";
            xlWorkSheet.Cells[4, 9]  = "Начало(план/факт)";
            xlWorkSheet.Cells[4, 10] = "Окончание(план/факт)";
            xlWorkSheet.Cells[4, 11] = "Статус";
            xlWorkSheet.Cells[4, 12] = "Начало(прогноз)";
            xlWorkSheet.Cells[4, 13] = "Окончание(прогноз)";
            xlWorkSheet.Cells[4, 14] = "Комментарий";

            ((Excel.Range)(xlWorkSheet.Columns[2])).EntireColumn.ColumnWidth  = 10;
            ((Excel.Range)(xlWorkSheet.Columns[3])).EntireColumn.ColumnWidth  = 20;
            ((Excel.Range)(xlWorkSheet.Columns[4])).EntireColumn.ColumnWidth  = 26;
            ((Excel.Range)(xlWorkSheet.Columns[5])).EntireColumn.ColumnWidth  = 22;
            ((Excel.Range)(xlWorkSheet.Columns[6])).EntireColumn.ColumnWidth  = 16;
            ((Excel.Range)(xlWorkSheet.Columns[7])).EntireColumn.ColumnWidth  = 11.5D;
            ((Excel.Range)(xlWorkSheet.Columns[8])).EntireColumn.ColumnWidth  = 14.5;
            ((Excel.Range)(xlWorkSheet.Columns[9])).EntireColumn.ColumnWidth  = 11.5;
            ((Excel.Range)(xlWorkSheet.Columns[10])).EntireColumn.ColumnWidth = 14.5;
            ((Excel.Range)(xlWorkSheet.Columns[11])).EntireColumn.ColumnWidth = 12.5;
            ((Excel.Range)(xlWorkSheet.Columns[12])).EntireColumn.ColumnWidth = 14;
            ((Excel.Range)(xlWorkSheet.Columns[13])).EntireColumn.ColumnWidth = 14;
            ((Excel.Range)(xlWorkSheet.Columns[14])).EntireColumn.ColumnWidth = 20;

            xlWorkSheet.Range[xlWorkSheet.Cells[4, 2], xlWorkSheet.Cells[4, 14]].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black);
            xlWorkSheet.Range[xlWorkSheet.Cells[4, 2], xlWorkSheet.Cells[4, 14]].Font.Color     = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.White);
            xlWorkSheet.Range[xlWorkSheet.Cells[4, 2], xlWorkSheet.Cells[4, 14]].Font.Bold      = true;


            int index = 5;

            xlWorkSheet.Cells[index, 2]  = project.numberProject;
            xlWorkSheet.Cells[index, 3]  = project.department.nameDepartment;
            xlWorkSheet.Cells[index, 4]  = project.nameProject;
            xlWorkSheet.Cells[index, 12] = project.dateBeginProg;
            xlWorkSheet.Cells[index, 13] = project.dateEndProg;
            index++;
            foreach (StageProject s in project.getProjectList())
            {
                xlWorkSheet.Cells[index, 2]  = project.numberProject;
                xlWorkSheet.Cells[index, 3]  = project.department.nameDepartment;
                xlWorkSheet.Cells[index, 4]  = project.nameProject;
                xlWorkSheet.Cells[index, 5]  = s.NameStage;
                xlWorkSheet.Cells[index, 6]  = s.User.FullName;
                xlWorkSheet.Cells[index, 7]  = s.DateBeginPlan;
                xlWorkSheet.Cells[index, 8]  = s.DateEndPlan;
                xlWorkSheet.Cells[index, 9]  = (s.DateBeginUser.CompareTo(new DateTime(1, 1, 1)) == 0) ? "" : s.DateBeginUser.ToShortDateString();
                xlWorkSheet.Cells[index, 10] = (s.DateEndUser.CompareTo(new DateTime(1, 1, 1)) == 0) ? "" : s.DateEndUser.ToShortDateString();
                xlWorkSheet.Cells[index, 11] = s.StatusStageStr;
                xlWorkSheet.Cells[index, 12] = s.DateBeginProg;
                xlWorkSheet.Cells[index, 13] = s.DateEndProg;
                xlWorkSheet.Cells[index, 14] = s.CommentUser;
                if (s.SubStage != null && s.SubStage.Count > 0)
                {
                    xlWorkSheet.Range[xlWorkSheet.Cells[index, 2], xlWorkSheet.Cells[index, 14]].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightGray);
                    foreach (StageProject sub in s.SubStage)
                    {
                        index++;
                        xlWorkSheet.Cells[index, 2]  = project.numberProject;
                        xlWorkSheet.Cells[index, 3]  = project.department.nameDepartment;
                        xlWorkSheet.Cells[index, 4]  = project.nameProject;
                        xlWorkSheet.Cells[index, 5]  = sub.NameStage;
                        xlWorkSheet.Cells[index, 6]  = sub.User.FullName;
                        xlWorkSheet.Cells[index, 7]  = sub.DateBeginPlan;
                        xlWorkSheet.Cells[index, 8]  = sub.DateEndPlan;
                        xlWorkSheet.Cells[index, 9]  = (sub.DateBeginUser.CompareTo(new DateTime(1, 1, 1)) == 0) ? "" : sub.DateBeginUser.ToShortDateString();
                        xlWorkSheet.Cells[index, 10] = (sub.DateEndUser.CompareTo(new DateTime(1, 1, 1)) == 0) ? "" : sub.DateEndUser.ToShortDateString();
                        xlWorkSheet.Cells[index, 11] = sub.StatusStageStr;
                        xlWorkSheet.Cells[index, 12] = sub.DateBeginProg;
                        xlWorkSheet.Cells[index, 13] = sub.DateEndProg;
                        xlWorkSheet.Cells[index, 14] = sub.CommentUser;
                        Excel.Range range = xlWorkSheet.Rows[index] as Excel.Range;
                        range.OutlineLevel = 1;
                        range.Group(System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value);
                    }
                    //Excel.Range range = xlWorkSheet.Range[xlWorkSheet.Cells[index - s.SubStage.Count-1, 2], xlWorkSheet.Cells[index- s.SubStage.Count-1, 14]];
                    //Excel.Range range = xlWorkSheet.Rows["1:10", null] as Excel.Range;
                    //range.Group(0,0,0,0);
                }
                index++;
            }

            index--;
            xlWorkSheet.Range[xlWorkSheet.Cells[4, 2], xlWorkSheet.Cells[index, 14]].Font.Size       = 8;
            xlWorkSheet.Range[xlWorkSheet.Cells[4, 2], xlWorkSheet.Cells[index, 14]].WrapText        = true;
            xlWorkSheet.Range[xlWorkSheet.Cells[6, 9], xlWorkSheet.Cells[index, 11]].Interior.Color  = System.Drawing.ColorTranslator.ToOle(Color.FromArgb(252, 228, 214));
            xlWorkSheet.Range[xlWorkSheet.Cells[6, 12], xlWorkSheet.Cells[index, 13]].Interior.Color = System.Drawing.ColorTranslator.ToOle(Color.FromArgb(218, 238, 243));
            //xlWorkSheet.Range[xlWorkSheet.Cells[4, 2], xlWorkSheet.Cells[index, 14]].AutoFit();

            xlApp.Visible = true;

            //xlWorkBook.SaveAs("d:\\csharp-Excel.xls", Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
            //xlWorkBook.Close(true, misValue, misValue);
            //xlApp.Quit();

            releaseObject(xlWorkSheet);
            releaseObject(xlWorkBook);
            releaseObject(xlApp);
        }