Exemplo n.º 1
0
        private void workUpdate()
        {
            // Get general variables
            int workId = Int32.Parse(hdfWorkId.Value.Trim());
            int projectId = Int32.Parse(hdfCurrentProjectId.Value.Trim());
            int assetId = Int32.Parse(hdfAssetId.Value.Trim());
            int companyId = Int32.Parse(hdfCompanyId.Value.Trim());
            string workType = hdfWorkType.Value.Trim();

            // Update comments for rehab assessment
            // Get original variables
            WorkGateway workGateway = new WorkGateway();
            workGateway.LoadByWorkId(workId, companyId);

            string originalWorkType = workGateway.GetWorkTypeOriginal(workId);
            int? originalLibraryCategoriesId = workGateway.GetLibraryCategoriesIdOriginal(workId);
            string originalComment = workGateway.GetCommentsOriginal(workId);
            string originalHistory = workGateway.GetHistoryOriginal(workId);

            //Get all new rehab assessment comments
            RehabAssessmentCommentDetailsGateway rehabAssessmentCommentDetailsGateway = new RehabAssessmentCommentDetailsGateway(rehabAssessmentTDS);
            rehabAssessmentCommentDetailsGateway.LoadAllByWorkIdWorkType(workId, companyId, workType);
            RehabAssessmentCommentDetails rehabAssessmentCommentDetails = new RehabAssessmentCommentDetails(rehabAssessmentCommentDetailsGateway.Data);
            string newComment = rehabAssessmentCommentDetails.GetAllRehabAssessmentComments(workId, companyId, rehabAssessmentCommentDetailsGateway.Table.Rows.Count, "\n");

            Work work = new Work(null);
            work.UpdateDirect(workId, projectId, assetId, originalWorkType, originalLibraryCategoriesId, false, companyId, originalComment, originalHistory, workId, projectId, assetId, originalWorkType, originalLibraryCategoriesId, false, companyId, newComment, originalHistory);

            // Update comments for full length lining
            int workIdFll = Int32.Parse(hdfWorkIdFll.Value.Trim());

            if (workIdFll != 0)
            {
                WorkGateway workGatewayForFll = new WorkGateway();
                workGatewayForFll.LoadByWorkId(workIdFll, companyId);

                string originalWorkTypeForFll = workGatewayForFll.GetWorkTypeOriginal(workIdFll);
                int? originalLibraryCategoriesIdForFll = workGatewayForFll.GetLibraryCategoriesIdOriginal(workIdFll);
                string originalCommentForFll = workGatewayForFll.GetCommentsOriginal(workIdFll);
                string originalHistoryForFll = workGatewayForFll.GetHistoryOriginal(workIdFll);

                //Get all new fulllengthlining comments
                FullLengthLiningCommentDetailsGateway fullLengthLiningCommentDetailsGateway = new FullLengthLiningCommentDetailsGateway();
                fullLengthLiningCommentDetailsGateway.LoadAllByWorkIdWorkType(workIdFll, companyId, "Full Length Lining");
                FullLengthLiningCommentDetails fullLengthLiningCommentDetails = new FullLengthLiningCommentDetails(fullLengthLiningCommentDetailsGateway.Data);
                string newCommentForFll = fullLengthLiningCommentDetails.GetAllFullLengthLiningComments(workIdFll, companyId, fullLengthLiningCommentDetailsGateway.Table.Rows.Count, "\n");

                // Save comments
                Work workForFll = new Work(null);
                workForFll.UpdateDirect(workIdFll, projectId, assetId, originalWorkTypeForFll, originalLibraryCategoriesIdForFll, false, companyId, originalCommentForFll, originalHistoryForFll, workIdFll, projectId, assetId, originalWorkTypeForFll, originalLibraryCategoriesIdForFll, false, companyId, newCommentForFll, originalHistoryForFll);
            }
        }
        public void UpdateDataToCorrectDataSet(int workIdRa, int workIdFll, RehabAssessmentCommentDetails raCommentDetails, FullLengthLiningCommentDetails fllCommentDetails, string workType)
        {
            foreach (RehabAssessmentTDS.CommentDetailsRow row in (RehabAssessmentTDS.CommentDetailsDataTable)Table)
            {
                int workId = row.WorkID;
                string type = row.Type;
                string subject = row.Subject;
                int loginId = row.UserID;
                DateTime dateTime_ = row.DateTime_;
                string comment = row.Comment;
                int? libraryFilesId = null; if (!row.IsLIBRARY_FILES_IDNull() ) libraryFilesId = row.LIBRARY_FILES_ID;
                bool deleted = row.Deleted;
                int companyId = row.COMPANY_ID;
                bool inDatabase = row.InDatabase;
                string userFullName = row.UserFullName;
                bool toHistory = row.ToHistory;

                if (row.WorkID == workIdRa)
                {
                    raCommentDetails.Insert(workId, type, subject, loginId, dateTime_, comment, libraryFilesId, deleted, companyId, inDatabase, userFullName, toHistory, workType);
                }
                else
                {
                    if (row.WorkID == workIdFll)
                    {
                        fllCommentDetails.Insert(workId, type, subject, loginId, dateTime_, comment, libraryFilesId, deleted, companyId, inDatabase, userFullName, toHistory, workType);
                    }
                }
            }
        }
Exemplo n.º 3
0
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_CWP_REHABASSESSMENT_VIEW"]) && Convert.ToBoolean(Session["sgLFS_CWP_REHABASSESSMENT_EDIT"])))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                }

                // Validate query string
                if (((string)Request.QueryString["source_page"] == null) || ((string)Request.QueryString["client_id"] == null) || ((string)Request.QueryString["project_id"] == null) || ((string)Request.QueryString["work_id"] == null) || ((string)Request.QueryString["asset_id"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in ra_comments.aspx");
                }

                // Tag Page
                hdfCompanyId.Value = Session["companyID"].ToString();
                hdfCurrentProjectId.Value = Request.QueryString["project_id"].ToString();
                hdfCurrentClientId.Value = Request.QueryString["client_id"].ToString();
                hdfLoginId.Value = Convert.ToInt32(Session["loginID"]).ToString();
                hdfAdminPermission.Value = Convert.ToBoolean(Session["sgLFS_CWP_REHABASSESSMENT_ADMIN"]).ToString();
                hdfWorkType.Value = "Rehab Assessment";
                hdfWorkId.Value = Request.QueryString["work_id"].ToString();
                hdfAssetId.Value = Request.QueryString["asset_id"].ToString();
                hdfUpdate.Value = "yes";

                // Prepare initial data
                Session.Remove("rehabAssessmentCommentDetailsDummy");

                // ... Names for UserList
                string workType = hdfWorkType.Value.Trim();
                int companyId = Int32.Parse(hdfCompanyId.Value);

                LoginGateway loginGateway = new LoginGateway();
                loginGateway.LoadByLoginId(Convert.ToInt32(hdfLoginId.Value),companyId);
                hdfCreatedBy.Value = loginGateway.GetLastName(Convert.ToInt32(hdfLoginId.Value), companyId) + " " + loginGateway.GetFirstName(Convert.ToInt32(hdfLoginId.Value), companyId);
                hdfCreationDateTime.Value = DateTime.Now.ToString();

                // If coming from
                // ... ra_summary.aspx or ra_edit.aspx
                if (Request.QueryString["source_page"] == "ra_summary.aspx" || Request.QueryString["source_page"] == "ra_edit.aspx")
                {
                    StoreNavigatorState();
                    ViewState["update"] = Request.QueryString["update"];

                    // For RA
                    rehabAssessmentTDS = (RehabAssessmentTDS)Session["rehabAssessmentTDS"];

                    int assetId = Int32.Parse(hdfAssetId.Value.Trim());
                    int currentProjectId = Int32.Parse(hdfCurrentProjectId.Value.Trim());
                    int workId = Int32.Parse(hdfWorkId.Value.Trim());

                    if (workId != 0)
                    {
                        // ... update comments
                        RehabAssessmentCommentDetailsGateway rehabAssessmentCommentDetailsGateway = new RehabAssessmentCommentDetailsGateway(rehabAssessmentTDS);
                        rehabAssessmentCommentDetailsGateway.LoadAllByWorkIdWorkType(workId, companyId, workType);

                        RehabAssessmentCommentDetails rehabAssessmentCommentDetails = new RehabAssessmentCommentDetails(rehabAssessmentCommentDetailsGateway.Data);
                        rehabAssessmentCommentDetails.UpdateForProcess();
                    }

                    // For FLL
                    int workIdFll = GetWorkId(currentProjectId, assetId, "Full Length Lining", companyId);
                    hdfWorkIdFll.Value = workIdFll.ToString();

                    if (workIdFll != 0)
                    {
                        // ... update comments
                        FullLengthLiningCommentDetailsGateway fullLengthLiningCommentDetailsGateway = new FullLengthLiningCommentDetailsGateway();
                        fullLengthLiningCommentDetailsGateway.LoadAllByWorkIdWorkType(workIdFll, companyId, "Full Length Lining");

                        FullLengthLiningCommentDetails fullLengthLiningCommentDetails = new FullLengthLiningCommentDetails(fullLengthLiningCommentDetailsGateway.Data);
                        fullLengthLiningCommentDetails.UpdateForProcess();
                    }

                    // ... Store datasets
                    Session["rehabAssessmentTDS"] = rehabAssessmentTDS;
                    Session["rehabAssessmentCommentDetails"] = rehabAssessmentTDS.CommentDetails;
                }
            }
            else
            {
                // Restore datasets
                rehabAssessmentTDS = (RehabAssessmentTDS)Session["rehabAssessmentTDS"];
                rehabAssessmentCommentDetails = rehabAssessmentTDS.CommentDetails;
            }
        }
Exemplo n.º 4
0
        private void UpdateDatabase()
        {
            DB.Open();
            DB.BeginTransaction();
            try
            {
                int companyId = Int32.Parse(hdfCompanyId.Value);

                // Update comments
                FullLengthLiningCommentDetails fullLengthLiningCommentDetails = new FullLengthLiningCommentDetails(fullLengthLiningTDS);
                fullLengthLiningCommentDetails.Save(companyId);

                // Update works
                workUpdate();

                // Update section
                int workId = Int32.Parse(hdfWorkId.Value.Trim());
                FullLengthLiningWorkDetails fullLengthLiningWorkDetails = new FullLengthLiningWorkDetails(fullLengthLiningTDS);
                fullLengthLiningWorkDetails.UpdateCommentsForSummaryEdit(workId, companyId);

                // Store datasets
                Session["fullLengthLiningTDS"] = fullLengthLiningTDS;

                DB.CommitTransaction();
            }
            catch (Exception ex)
            {
                DB.RollbackTransaction();

                string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' '));
                Response.Redirect(url);
            }
        }
Exemplo n.º 5
0
        private void GrdCommentsAdd()
        {
            if (ValidateCommentsFooter())
            {
                Page.Validate("commentsDataAdd");
                if (Page.IsValid)
                {
                    int workId = Int32.Parse(hdfWorkId.Value);
                    int companyId = Int32.Parse(hdfCompanyId.Value);
                    int loginId = Convert.ToInt32(Session["loginID"]);
                    DateTime dateTime_ = DateTime.Now;
                    bool inDatabase = false;
                    bool toHistory = false;
                    bool deleted = false;
                    string workType = hdfWorkType.Value;

                    string newSubject = ((TextBox)grdComments.FooterRow.FindControl("tbxSubjectNew")).Text.Trim();
                    string newType = ((DropDownList)grdComments.FooterRow.FindControl("ddlTypeNew")).SelectedValue.ToString().Trim();
                    string newComment = ((TextBox)grdComments.FooterRow.FindControl("tbxCommentsNew")).Text.Trim();
                    int? libraryFilesId = null; if (((Label)grdComments.FooterRow.FindControl("lblLIBRARY_FILES_IDNew")).Text != "") libraryFilesId = Int32.Parse(((Label)grdComments.FooterRow.FindControl("lblLIBRARY_FILES_IDNew")).Text.Trim());

                    LoginGateway loginGateway = new LoginGateway();
                    loginGateway.LoadByLoginId(loginId, companyId);
                    string userFullName = loginGateway.GetLastName(loginId, companyId) + " " + loginGateway.GetFirstName(loginId, companyId);

                    FullLengthLiningCommentDetails model = new FullLengthLiningCommentDetails(fullLengthLiningTDS);
                    model.Insert(workId, newType, newSubject, loginId, dateTime_, newComment, libraryFilesId, deleted, companyId, inDatabase, userFullName, toHistory, workType);

                    Session.Remove("fullLengthLiningCommentDetailsDummy");
                    Session["fullLengthLiningTDS"] = fullLengthLiningTDS;
                    Session["fullLengthLiningCommentDetails"] = fullLengthLiningTDS.CommentDetails;

                    grdComments.DataBind();
                    grdComments.PageIndex = grdComments.PageCount - 1;
                }
            }
        }
Exemplo n.º 6
0
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_CWP_FULLLENGTHLINING_VIEW"]) && Convert.ToBoolean(Session["sgLFS_CWP_FULLLENGTHLINING_EDIT"])))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                }

                // Validate query string
                if (((string)Request.QueryString["source_page"] == null) || ((string)Request.QueryString["client_id"] == null) || ((string)Request.QueryString["project_id"] == null) || ((string)Request.QueryString["work_id"] == null) || ((string)Request.QueryString["asset_id"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in fl_comments.aspx");
                }

                // Tag Page
                hdfCompanyId.Value = Session["companyID"].ToString();
                hdfCurrentProjectId.Value = Request.QueryString["project_id"].ToString();
                hdfCurrentClientId.Value = Request.QueryString["client_id"].ToString();
                hdfLoginId.Value = Convert.ToInt32(Session["loginID"]).ToString();
                hdfAdminPermission.Value = Convert.ToBoolean(Session["sgLFS_CWP_FULLLENGTHLINING_ADMIN"]).ToString();
                hdfWorkType.Value = "Full Length Lining";
                hdfWorkId.Value = Request.QueryString["work_id"].ToString();
                hdfAssetId.Value = Request.QueryString["asset_id"].ToString();
                hdfUpdate.Value = "yes";

                // ... Names for UserList
                string workType = hdfWorkType.Value.Trim();
                int companyId = Int32.Parse(hdfCompanyId.Value);

                LoginGateway loginGateway = new LoginGateway();
                loginGateway.LoadByLoginId(Convert.ToInt32(hdfLoginId.Value), companyId);
                hdfCreatedBy.Value = loginGateway.GetLastName(Convert.ToInt32(hdfLoginId.Value), companyId) + " " + loginGateway.GetFirstName(Convert.ToInt32(hdfLoginId.Value), companyId);

                // Prepare initial data
                Session.Remove("fullLengthLiningCommentDetailsDummy");

                // If coming from
                // ... flsummary.aspx and fl_edit.aspx
                if (Request.QueryString["source_page"] == "fl_summary.aspx" || Request.QueryString["source_page"] == "fl_edit.aspx")
                {
                    StoreNavigatorState();
                    ViewState["update"] = Request.QueryString["update"];

                    fullLengthLiningTDS = (FullLengthLiningTDS)Session["fullLengthLiningTDS"];

                    int assetId = Int32.Parse(hdfAssetId.Value.Trim());
                    int currentProjectId = Int32.Parse(hdfCurrentProjectId.Value.Trim());
                    int flWorkId = Int32.Parse(hdfWorkId.Value.Trim());
                    int raWorkId = 0;

                    // ... If the project has fl works
                    if (flWorkId != 0)
                    {
                        WorkGateway workGateway = new WorkGateway();
                        workGateway.LoadByProjectIdAssetIdWorkType(currentProjectId, assetId, "Rehab Assessment", companyId);
                        if (workGateway.Table.Rows.Count > 0)
                        {
                            raWorkId = workGateway.GetWorkId(assetId, "Rehab Assessment", currentProjectId);
                        }

                        // ... update fl and ra comments
                        FullLengthLiningCommentDetailsGateway fullLengthLiningCommentDetailsGateway = new FullLengthLiningCommentDetailsGateway(fullLengthLiningTDS);
                        fullLengthLiningCommentDetailsGateway.LoadAllByFlWorkIdRaWorkId(flWorkId, raWorkId, companyId);

                        FullLengthLiningCommentDetails fullLengthLiningCommentDetailsForLoad = new FullLengthLiningCommentDetails(fullLengthLiningCommentDetailsGateway.Data);
                        fullLengthLiningCommentDetailsForLoad.UpdateForProcess();
                    }

                    // ... Store datasets
                    Session["fullLengthLiningTDS"] = fullLengthLiningTDS;
                    Session["fullLengthLiningCommentDetails"] = fullLengthLiningTDS.CommentDetails;
                }
            }
            else
            {
                // Restore datasets
                fullLengthLiningTDS = (FullLengthLiningTDS)Session["fullLengthLiningTDS"];
                fullLengthLiningCommentDetails = fullLengthLiningTDS.CommentDetails;

                // Store
                Session["fullLengthLiningCommentDetails"] = fullLengthLiningTDS.CommentDetails;
            }
        }
Exemplo n.º 7
0
        protected void grdComments_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            Page.Validate("commentsDataEdit");
            if (Page.IsValid)
            {
                int workId = (int)e.Keys["WorkID"];
                int refId = (int)e.Keys["RefID"];
                int companyId = Int32.Parse(hdfCompanyId.Value);
                int loginId = Convert.ToInt32(Session["loginID"]);
                bool adminPermission = Convert.ToBoolean(Session["sgLFS_CWP_FULLLENGTHLINING_ADMIN"]);
                bool toHistory = false;

                string newSubject = ((TextBox)grdComments.Rows[e.RowIndex].Cells[3].FindControl("tbxSubjectEdit")).Text.Trim();
                string newComment = ((TextBox)grdComments.Rows[e.RowIndex].Cells[4].FindControl("tbxCommentsEdit")).Text.Trim();
                string newType = "";
                if (((DropDownList)grdComments.Rows[e.RowIndex].Cells[3].FindControl("ddlTypeEdit")).Visible)
                {
                    newType = ((DropDownList)grdComments.Rows[e.RowIndex].Cells[3].FindControl("ddlTypeEdit")).SelectedValue.ToString().Trim();
                }
                else
                {
                    newType = ((TextBox)grdComments.Rows[e.RowIndex].Cells[3].FindControl("tbxTypeEdit")).Text;
                }

                // Update data
                FullLengthLiningCommentDetails model = new FullLengthLiningCommentDetails(fullLengthLiningTDS);
                model.Update(workId, refId, newType, newSubject, companyId, newComment, loginId, adminPermission, toHistory);

                // Store dataset
                Session["fullLengthLiningTDS"] = fullLengthLiningTDS;
                Session["fullLengthLiningCommentDetails"] = fullLengthLiningTDS.CommentDetails;
            }
            else
            {
                e.Cancel = true;
            }
        }
Exemplo n.º 8
0
        protected void grdComments_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            // Comments Gridview, if the gridview is edition mode
            if (grdComments.EditIndex >= 0)
            {
                grdComments.UpdateRow(grdComments.EditIndex, true);
            }

            // Delete comments
            int workId = (int)e.Keys["WorkID"];
            int refId = (int)e.Keys["RefID"];
            int companyId = Int32.Parse(hdfCompanyId.Value);
            int loginId = Convert.ToInt32(hdfLoginId.Value);
            bool adminPermission = Convert.ToBoolean(Session["sgLFS_CWP_FULLLENGTHLINING_ADMIN"]);

            // Delete comment
            FullLengthLiningCommentDetails model = new FullLengthLiningCommentDetails(fullLengthLiningTDS);
            model.Delete(workId, refId, companyId, loginId, adminPermission);

            // Store dataset
            Session["fullLengthLiningTDS"] = fullLengthLiningTDS;
        }