Example #1
0
        private void LoadAsPreviousExport(string projNum)
        {
            CBVisionExport ve = new CBVisionExport();

            //ve.UpdateStagingForPreviousExport(projNum);

            ve.VisionPullPreviousLoc(projNum);
            ve.VisionProcessPrevious(projNum);
            ve.VisionPrepareWBS2();
            ve.VisionPrepareWBS3();
            ve.VisionSyncPrevious();
        }
Example #2
0
        private void bttProcess_Click(object sender, EventArgs e)
        {
            string msg        = "Export the selected budget " + (lvwBudgets.SelectedItems[0]).SubItems[1].Text;
            string projNumber = lvwProjects.SelectedItems[0].SubItems[1].Text;

            if (MessageBox.Show(msg, "Export", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            {
                CBVisionExport ve   = new CBVisionExport();
                CBBudget       bud  = new CBBudget();
                CBProject      proj = new CBProject();
                SqlDataReader  dr;
                int            budID;

                ListViewItem l = lvwBudgets.SelectedItems[0];
                budID = Convert.ToInt32(l.Text);
                bud.Load(budID);
                proj.Load(bud.ProjectID);

                // prepare teh data tables
                lblStatus.Visible = true;
                UpdateStatus("Preparing data tables for export");
                ve.ResetStagingTables();
                UpdateStatus("Retrieving budget information");
                dr = ve.GetBudgetLinesForStaging(budID);
                UpdateStatus("Loading budget info into staging table");
                while (dr.Read())
                {
                    ve.InsertLineForStaging(
                        bud.ID,
                        proj.Number,
                        Convert.ToInt32(dr["DeptGroup"]),
                        Convert.ToInt32(dr["Task"]),
                        Convert.ToInt32(dr["Category"]),
                        Convert.ToInt32(dr["Activity"]),
                        dr["WBS"].ToString(),
                        dr["Description"].ToString(),
                        Convert.ToInt32(dr["Quantity"]),
                        Convert.ToInt32(dr["HoursEach"]),
                        Convert.ToInt32(dr["TotalHours"]),
                        Convert.ToDecimal(dr["LoadedRate"]),
                        Convert.ToDecimal(dr["TotalDollars"]),
                        0, 0, dr["LineGUID"].ToString(),
                        false,
                        "",
                        proj.DateStart,
                        proj.DateEnd,
                        dr["BudgetType"].ToString());
                }
                dr.Close();

                UpdateStatus("Loading plan information");
                ve.InsertPlanInformation(budID);
                UpdateStatus("Loading WBS1 outline");
                ve.InsertWBS1Outline(budID);

                UpdateStatus("Loading WBS2 outline");
                // load wbs2 with outline numbers
                int    outLvl = 1;
                int    chldCnt = 0;
                string outlineNumber, deptName, deptNumber;

                dr = ve.GetWBS2Levels();
                while (dr.Read())
                {
                    outlineNumber = "001." + outLvl.ToString("000");
                    deptName      = dr["Description"].ToString();
                    deptNumber    = dr["DeptGroup"].ToString();
                    chldCnt       = Convert.ToInt32(dr["Cnt"]);

                    ve.InsertWBS2Outline(budID, outlineNumber, deptName, deptNumber, "001", proj.DateStart, proj.DateEnd, chldCnt);

                    outLvl++;
                }
                dr.Close();

                UpdateStatus("Loading WBS3 outline");
                // load wbs3 with outline numbers
                outLvl  = 0;
                chldCnt = 0;
                string currLvl  = "";
                string activity = "";
                int    stageID;

                dr = ve.GetWBS3Levels();
                while (dr.Read())
                {
                    if (dr["OutlineNumber"].ToString() != currLvl)
                    {
                        currLvl = dr["OutlineNumber"].ToString();
                        outLvl  = 1;
                    }

                    stageID       = Convert.ToInt32(dr["ID"]);
                    outlineNumber = currLvl + "." + outLvl.ToString("000");
                    deptName      = dr["Description"].ToString();
                    deptNumber    = dr["DeptGroup"].ToString();
                    activity      = dr["ACtivity"].ToString();

                    ve.InsertWBS3Outline(budID, outlineNumber, deptName, deptNumber, activity, currLvl, proj.DateStart, proj.DateEnd, chldCnt, stageID);

                    outLvl++;
                }
                dr.Close();

                UpdateStatus("Update staging with outline");
                ve.UpdateStagingWithOutline();

                if (CheckForExistingImport(projNumber) == true)
                {
                    UpdateStatus("Processing as previous Export");
                    LoadAsPreviousExport(projNumber);
                }

                ve.RecordExportedBudgetLInes();

                UpdateStatus("Finished Export");

                MessageBox.Show("Finished building export tables");

                this.Close();
            }
        }