コード例 #1
0
        protected void btnSaveDailyWorkReport_Click(object sender, EventArgs e)
        {
            // CODE INCOMPLETE IN THIS PART BECAUSE IT WAS NOT A REQUIREMENT BUT WE DID START IT
            // Part 1
            // I can either get the userID that doesn't have an assigned workertype in the system
            // Or I can hardcode in a workertypeID since we are only building this system to work with a Managers level of access
            // And just assign the manager type to the workertype in the labour summary table
            // In reality this should be attached to the user upon registration so it can be pulled from the role in the identity database
            // int userID = Convert.ToInt32(System.Web.HttpContext.Current.User.Identity.GetUserId());

            // MATERIAL REQUIREMENTS
            for (int i = 0; i < dailyWorkReportRows.Count; i++)
            {
                // Get project ID and hours worked on project
                int   projID = Convert.ToInt32(dailyWorkReportRows[i][0]);
                short hours  = Convert.ToInt16(dailyWorkReportRows[i][2]);

                // Create material requirements object to hold material data
                LABOUR_SUMMARY ls = new LABOUR_SUMMARY();
                ls.projectID = projID;
                ls.lsHours   = hours;

                // Part 2, See part 1 for explanation
                ls.workerTypeID = 8;

                // Add to material requirements table
                db.LABOUR_SUMMARY.Add(ls);

                PROJECT p = db.PROJECTs.Find(projID);
            }
        }
コード例 #2
0
ファイル: EditDesignBid.aspx.cs プロジェクト: tuneis/nbd
        protected void btnSaveBid_Click(object sender, EventArgs e)
        {
            // Get project id from session
            int projectID = Convert.ToInt32(Session["ProjectID"]);

            // Find the project
            PROJECT proj = db.PROJECTs.Find(projectID);

            // Modify data
            proj.projName     = mdlTxtProjectName.Text;
            proj.projSite     = mdlTxtProjectSite.Text;
            proj.projEstStart = mdlTxtProjectBeginDate.Text;
            proj.projEstEnd   = mdlTxtProjectEndDate.Text;

            // Change entry state
            db.Entry(proj).State = System.Data.Entity.EntityState.Modified;

            try
            {
                db.SaveChanges();
                Response.Redirect("EditDesignBid.aspx", false);
            }
            catch (DataException ex)
            {
                NotifyJS.DisplayNotification(this.Page, ex.InnerException.InnerException.Message, "danger");
            }
        }
コード例 #3
0
ファイル: CreateDesignBid.aspx.cs プロジェクト: tuneis/nbd
        /* ----------------------------------------------------------------------------------------- */
        /* ------------------------ GRID VIEW CODE FOR LABOR TABLE ----------------------------- */
        /* ----------------------------------------------------------------------------------------- */
        protected void btnDesignBidCreate_Click(object sender, EventArgs e)
        {
            if (labourTableFlag == false || materialsTableFlag == false)
            {
                if (materialsTableFlag == false)
                {
                    NotifyJS.DisplayNotification(this.Page, "You cannot create a Design Bid with no Materials added.", "danger");
                }

                if (labourTableFlag == false)
                {
                    NotifyJS.DisplayNotification(this.Page, "You cannot create a Design Bid with no Labor Requirements.", "danger");
                }
            }
            else
            {
                try
                {
                    // Get the last ID from the projects table
                    var projId = db.PROJECTs.Max(x => x.ID) + 1;

                    // Store project information into project variable
                    PROJECT p = new PROJECT();
                    p.ID                = projId;
                    p.projName          = txtProjectName.Text;
                    p.projSite          = txtProjectSite.Text;
                    p.projBidDate       = DateTime.Now;
                    p.projEstStart      = txtProjectBeginDate.Text;
                    p.projEstEnd        = txtProjectEndDate.Text;
                    p.projActStart      = "TBA";
                    p.projActEnd        = "TBA";
                    p.projEstCost       = (txtBidAmount.Text == string.Empty) ? "0.00" : txtBidAmount.Text;
                    p.projActCost       = "0";
                    p.projBidCustAccept = false;
                    p.projBidMgmtAccept = false;
                    p.projCurrentPhase  = "D";
                    p.projIsFlagged     = false;
                    p.clientID          = Convert.ToInt32(ddlClientName.SelectedValue);
                    p.designerID        = Convert.ToInt32(ddlNBDDesigner.SelectedValue);

                    // Add to projects table
                    db.PROJECTs.Add(p);

                    // MATERIAL REQUIREMENTS
                    for (int i = 0; i < materialRows.Count; i++)
                    {
                        // Get the appropriate inventory ID for the material
                        int matID = Convert.ToInt32(materialRows[i][2]);
                        var invID = db.INVENTORies.Where(x => x.ID == matID).SingleOrDefault();

                        // Create material requirements object to hold material data
                        MATERIAL_REQ m = new MATERIAL_REQ();
                        m.inventoryID = invID.ID;
                        m.projectID   = projId;
                        m.mreqDeliver = null;
                        m.mreqInstall = null;
                        m.mreqEstQty  = Convert.ToInt16(materialRows[i][1]);
                        m.mreqActQty  = null;

                        // Add to material requirements table
                        db.MATERIAL_REQ.Add(m);
                    }

                    // PRODUCTION TEAM
                    PROD_TEAM team = new PROD_TEAM();
                    team.projectID   = projId;
                    team.teamName    = "TEST TEAM BRA";
                    team.teamPhaseIn = "B";
                    db.PROD_TEAM.Add(team);

                    // Save changes in order to get the new max prod team id
                    db.SaveChanges();

                    // Get the last production team ID
                    int teamID = db.PROD_TEAM.Max(m => m.ID);

                    //Add Designer
                    TEAM_MEMBER designer = new TEAM_MEMBER();
                    designer.workerID = p.designerID;
                    designer.teamID   = teamID;
                    db.TEAM_MEMBER.Add(designer);

                    //Add Sales Associate
                    TEAM_MEMBER sales = new TEAM_MEMBER();
                    sales.workerID = Convert.ToInt32(ddlNBDSales.SelectedValue);
                    sales.teamID   = teamID;
                    db.TEAM_MEMBER.Add(sales);

                    // LABOR SUMMARY
                    LABOUR_SUMMARY ls = new LABOUR_SUMMARY();
                    ls.projectID    = projId;
                    ls.workerTypeID = Convert.ToInt32(ddlLaborType.SelectedValue);

                    // Total up labor hours and add to object
                    short labourHours = 0;
                    for (int i = 0; i < laborRows.Count; i++)
                    {
                        labourHours += Convert.ToInt16(laborRows[i][1]);
                    }
                    ls.lsHours = labourHours;
                    db.LABOUR_SUMMARY.Add(ls);

                    for (int i = 0; i < laborRows.Count; i++)
                    {
                        LABOUR_REQUIREMENT l = new LABOUR_REQUIREMENT();
                        l.prodTeamID   = teamID;
                        l.taskID       = Convert.ToInt32(laborRows[i][2]);
                        l.lreqEstDate  = null;
                        l.lreqEstHours = Convert.ToInt16(laborRows[i][1]);
                        l.lreqActDate  = null;
                        l.lreqActHours = null;
                        l.lreqComments = null;
                        l.projectID    = projId;
                        l.workerTypeID = Convert.ToInt32(laborRows[i][5]);
                        db.LABOUR_REQUIREMENT.Add(l);
                    }

                    // Save
                    db.SaveChanges();

                    // Display notification
                    Response.Redirect("~/Main.aspx", false);
                    NotifyJS.DisplayNotification(this.Page, "Design bid " + p.projName + " for " + p.CLIENT.cliName + " successfully added.", "success");
                }
                catch (DataException dx)
                {
                    NotifyJS.DisplayNotification(this.Page, dx.InnerException.InnerException.Message, "danger");
                }
                catch (Exception ex)
                {
                    NotifyJS.DisplayNotification(this.Page, ex.InnerException.InnerException.Message, "danger");
                }
            }
        }