Exemple #1
0
        public string Create(tProject target)
        {
            //------新增專案-----------//
            tProject prj = new tProject();

            prj.fProjectId     = target.fProjectId;
            prj.fProjectName   = target.fProjectName;
            prj.fClient        = target.fClient;
            prj.fPrice         = target.fPrice;
            prj.fCreatdDate    = target.fCreatdDate;
            prj.fDateline      = target.fDateline;
            prj.fEmployeeId    = target.fEmployeeId;
            prj.fProgress      = 0;
            prj.fPaymentStatus = "未收款";

            db.tProjects.Add(prj);
            db.SaveChanges();

            //------新增專案預算書------//
            tBudget budget = new tBudget();

            budget.fProjectId = target.fProjectId;
            db.tBudgets.Add(budget);
            db.SaveChanges();

            //---------新增階段表------//
            //預設為三階段//
            //todo:讓使用者自訂階段數量及名稱

            tLevel level1 = new tLevel();

            level1.fProjectId    = prj.fProjectId;
            level1.fLevelName    = "規劃";
            level1.fEstimateTime = 0;

            tLevel level2 = new tLevel();

            level2.fProjectId    = prj.fProjectId;
            level2.fLevelName    = "開發";
            level2.fEstimateTime = 0;

            tLevel level3 = new tLevel();

            level3.fProjectId    = prj.fProjectId;
            level3.fLevelName    = "測試";
            level3.fEstimateTime = 0;

            db.tLevels.Add(level1);
            db.tLevels.Add(level2);
            db.tLevels.Add(level3);
            db.SaveChanges();

            return("success");
        }
        public string Create(tProject target)
        {
            //------新增專案-----------//
            tProject prj = new tProject();

            prj.fProjectId   = target.fProjectId;
            prj.fProjectName = target.fProjectName;
            prj.fClient      = target.fClient;
            prj.fPrice       = target.fPrice;
            prj.fCreatdDate  = target.fCreatdDate;
            prj.fDateline    = target.fDateline;
            prj.fDepartment  = target.fDepartment;
            prj.fEmployeeId  = target.fEmployeeId;
            prj.fProgress    = 0;

            prj.fStatus = "進行中";

            db.tProjects.Add(prj);
            db.SaveChanges();

            //------新增專案預算書------//
            tBudget budget = new tBudget();

            budget.fProjectId        = target.fProjectId;
            budget.fManagementFeePct = 0.2;
            budget.fSalaryHour       = 200;
            budget.fagree            = "未申請";
            budget.fBudget           = 0;

            db.tBudgets.Add(budget);
            db.SaveChanges();

            //---------新增階段表------//
            //預設為三階段//
            //todo:讓使用者自訂階段數量及名稱

            tLevel level1 = new tLevel();

            level1.fProjectId    = prj.fProjectId;
            level1.fLevelName    = "規劃";
            level1.fEstimateTime = 0;
            level1.fSpendCost    = 0;

            tLevel level2 = new tLevel();

            level2.fProjectId    = prj.fProjectId;
            level2.fLevelName    = "開發";
            level2.fEstimateTime = 0;
            level2.fSpendCost    = 0;

            tLevel level3 = new tLevel();

            level3.fProjectId    = prj.fProjectId;
            level3.fLevelName    = "測試";
            level3.fEstimateTime = 0;
            level3.fSpendCost    = 0;

            db.tLevels.Add(level1);
            db.tLevels.Add(level2);
            db.tLevels.Add(level3);
            db.SaveChanges();

            return("success");
        }