Exemple #1
0
        // Created By PVMS
        // Get Details of Car
        public void GetCarDetails(int id)
        {
            try
            {
                ActMonitorModel actmonitormodel = new ActMonitorModel();
                ActMonitor      actmonitor      = actmonitormodel.RetrieveData(id);

                ddlNetworkGrid.SelectedValue = actmonitor.Network_Grid_BA.ToString();
                SetNetworkBusinessDMZ(actmonitor);

                txtRemarks.Text      = actmonitor.Remarks__Comments;
                txtLocation.Text     = actmonitor.Location;
                txtBrgy.Text         = actmonitor.Affected_Barangay_s_;
                txtMunicipality.Text = actmonitor.Affected_Municipality;
                txtMRU.Text          = actmonitor.List_of_Affected_MRUs;
                txtDMA.Text          = actmonitor.List_of_Affected_DMAs;
                txtHousehold.Text    = actmonitor.Number_of_Affected_Households.ToString();

                SetClassificationEvent(actmonitor);

                ddlEquip.SelectedValue      = actmonitor.Equipment__Appurtenance.ToString();
                ddlType.SelectedValue       = actmonitor.Type_of_Equipment_Appurtenance.ToString();
                ddlSize.SelectedValue       = actmonitor.Size.ToString();
                ddlContractor.SelectedValue = actmonitor.Contractor.ToString();
            }
            catch (Exception Err)
            {
                lblError.Visible = true;
                lblError.Text    = Err.ToString();
            }
        }
Exemple #2
0
        // Created By PVMS
        // Set dropdownlist values for NetworkGrid, Business Zone, DMZ
        private void SetNetworkBusinessDMZ(ActMonitor actMonitor)
        {
            try
            {
                CarDetails            objCarDetails = new CarDetails();
                List <NetworkGrid_BA> objNetwork    = objCarDetails.GetNetworkGrid();

                ddlNetworkGrid.DataSource     = objNetwork;
                ddlNetworkGrid.DataValueField = "ID";
                ddlNetworkGrid.DataTextField  = "NetworkGrid_BA1";
                ddlNetworkGrid.DataBind();
                ddlNetworkGrid.SelectedValue = actMonitor.Network_Grid_BA.ToString();

                List <BusinessZone_Grid> objBusiness = objCarDetails.GetBusinessZone(Convert.ToInt32(ddlNetworkGrid.SelectedValue));
                ddlBusinessZone.DataSource     = objBusiness;
                ddlBusinessZone.DataValueField = "ID";
                ddlBusinessZone.DataTextField  = "BusinessZone_Grid1";
                ddlBusinessZone.DataBind();
                ddlBusinessZone.SelectedValue = actMonitor.Business_Zone__Grid.ToString();

                List <DMZFacility> objDMZ = objCarDetails.GetDMZ(Convert.ToInt32(ddlBusinessZone.SelectedValue));
                ddlDMZ.DataSource     = objDMZ;
                ddlDMZ.DataValueField = "ID";
                ddlDMZ.DataTextField  = "DMZ_Facility";
                ddlDMZ.DataBind();
                ddlDMZ.SelectedValue = actMonitor.DMZ__Facility.ToString();
            }
            catch (Exception Err)
            {
                lblError.Visible = true;
                lblError.Text    = Err.ToString();
            }
        }
Exemple #3
0
        // Created By PVMS
        // Set dropdownlist values for Classification, Event, Activity Type
        private void SetClassificationEvent(ActMonitor actMonitor)
        {
            try {
                CarDetails objCarDetails = new CarDetails();

                List <Classification> objClassification = objCarDetails.GetClassification();

                ddlClassification.DataSource     = objClassification;
                ddlClassification.DataValueField = "ID";
                ddlClassification.DataTextField  = "Classification1";
                ddlClassification.DataBind();
                ddlClassification.SelectedValue = actMonitor.Classification.ToString();

                List <Incident_Event> objIncidentEvent = objCarDetails.GetIncidentEvent(Convert.ToInt32(ddlClassification.SelectedValue));
                ddlEvent.DataSource     = objIncidentEvent;
                ddlEvent.DataValueField = "ID";
                ddlEvent.DataTextField  = "Incident_Event1";
                ddlEvent.DataBind();
                ddlEvent.SelectedValue = actMonitor.Incident.ToString();

                List <ActivityType> objActivityType = objCarDetails.GetActivityType(Convert.ToInt32(ddlEvent.SelectedValue));
                ddlAct.DataSource     = objActivityType;
                ddlAct.DataValueField = "ID";
                ddlAct.DataTextField  = "ActivityType1";
                ddlAct.DataBind();
                ddlAct.SelectedValue = actMonitor.Type_of_Activity.ToString();
            }
            catch (Exception Err) {
                lblError.Visible = true;
                lblError.Text    = Err.ToString();
            }
        }
Exemple #4
0
        // Created By PVMS
        // Set values for ActMonitor
        private ActMonitor CreateActMonitor()
        {
            ActMonitor a = new ActMonitor();

            a.Scheduled_Today_ = System.DateTime.Now.ToString();
            a.Date_and_Time_of_CAR_Submission = System.DateTime.Now;
            a.Unique_CAR_ID         = Guid.NewGuid().ToString();
            a.Network_Grid_BA       = Convert.ToInt32(ddlNetworkGrid.SelectedValue);
            a.Business_Zone__Grid   = Convert.ToInt32(ddlBusinessZone.SelectedValue);
            a.DMZ__Facility         = Convert.ToInt32(ddlDMZ.SelectedValue);
            a.Location              = txtLocation.Text;
            a.Affected_Barangay_s_  = txtBrgy.Text;
            a.Affected_Municipality = txtMunicipality.Text;
            a.List_of_Affected_MRUs = txtMRU.Text;
            a.List_of_Affected_DMAs = txtDMA.Text;
            if (txtHousehold.Text.ToString().Trim() == "")
            {
                a.Number_of_Affected_Households = 0;
            }
            else
            {
                a.Number_of_Affected_Households = Convert.ToInt32(txtHousehold.Text);
            }
            a.Classification                 = Convert.ToInt32(ddlClassification.SelectedValue);
            a.Incident                       = Convert.ToInt32(ddlEvent.SelectedValue);
            a.Type_of_Activity               = Convert.ToInt32(ddlAct.SelectedValue);
            a.Equipment__Appurtenance        = Convert.ToInt32(ddlEquip.SelectedValue);
            a.Type_of_Equipment_Appurtenance = Convert.ToInt32(ddlType.SelectedValue);
            a.Size                  = Convert.ToInt32(ddlSize.SelectedValue);
            a.Affected_Area         = Convert.ToString(ddlArea.SelectedValue);
            a.Contractor            = Convert.ToInt32(ddlContractor.SelectedValue);
            a.Means_of_Notification = ddlMeans.SelectedIndex;
            a.Need_Media_Advisory   = 1;
            a.OIM = "OIM";
            a.SIM = "SIM";
            a.CIM = "CIM";
            a.Remarks__Comments       = txtRemarks.Text;
            a.Prework_Completion      = Convert.ToDateTime("1999-12-10");
            a.Interruption_of_Service = Convert.ToDateTime("2018-05-02");
            a.Physical_Completion     = Convert.ToDateTime("2018-05-02");
            a.Return_of_Service       = Convert.ToDateTime("2018-05-02");
            a.Duration = 1;
            a.Sender_Receiver__Date_Time = "sample";
            a.Classification1            = "sample";
            a.Status = "In Progress";
            //a.Actual_Date_and_Time_of_Start = Convert.ToDateTime("2018-05-02");
            //a.Actual_Date_and_Time_of_Completion = Convert.ToDateTime("2018-05-02");
            a.Actual_Date_and_Time_of_Service_Interruption = "Sample";
            a.Actual_Date_and_Time_of_Service_Return       = Convert.ToDateTime("2018-05-02");
            a.Actual_Duration_of_Activity__in_hours_       = 100;
            a.Variance_in_Duration__Agreed_vs_Actual_      = 100;
            a.Reported_by_and_time_of_sign_on__            = "sample";
            a.Closed_out_by_and_time_of_sign_off           = "sample";
            a.Initial_Alert_Level_             = "sample";
            a.Incident_Escalation___Yes_or_No_ = "yes";
            a.With_or_without_service_interruption___Yes_or_No_ = "yes";
            a.Duty__last_update_ = "sample";
            a.Findings           = "sample";
            return(a);
        }
        //Created by PS2019
        //Private Method to update Actual Start Date
        private void UpdateActualStartDateTime(DateTime dtActual)
        {
            ActMonitorModel model         = new ActMonitorModel();
            ActMonitor      objActMonitor = new ActMonitor();

            objActMonitor.CAR_Number = Convert.ToInt32(txtCarID.Text);
            objActMonitor.Actual_Date_and_Time_of_Start = dtActual;
            int id = Convert.ToInt32(txtCarID.Text);

            model.UpdateActualStartDateTime(id, Session["UserName"].ToString(), objActMonitor);
        }
        /* Written by PS2019*/
        /* Cancel Milestone with Database operation */
        private void CancelMileStone(string _ActualDTServIntrp)
        {
            ActMonitorModel oActMonitorModel = new ActMonitorModel();
            ActMonitor      oActMonitor      = new ActMonitor();

            oActMonitor.CAR_Number = Convert.ToInt32(txtCarID.Text);
            oActMonitor.Actual_Date_and_Time_of_Service_Interruption = _ActualDTServIntrp;
            oActMonitor.Status = "Cancelled";
            oActMonitorModel.CancelActMonitor(Convert.ToInt32(txtCarID.Text), Session["UserName"].ToString(), oActMonitor);
            ViewState["IncidentStatus"] = "Cancelled";
            CancelMileStone();
            grvUpdates.DataBind();
        }
Exemple #7
0
 public ActMonitor RetrieveData(int id)
 {
     try
     {
         using (IncidentEntities db = new IncidentEntities())
         {
             ActMonitor actmonitor = db.ActMonitors.Find(id);
             return(actmonitor);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
Exemple #8
0
 public string DeleteActMonitor(int ActMonitor)
 {
     try
     {
         IncidentEntities db         = new IncidentEntities();
         ActMonitor       actmonitor = db.ActMonitors.Find(ActMonitor);
         db.ActMonitors.Attach(actmonitor);
         db.ActMonitors.Remove(actmonitor);
         db.SaveChanges();
         return(actmonitor.Incident + "was successfully removed");
     }
     catch (Exception e)
     {
         return("Error" + e);
     }
 }
Exemple #9
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ActMonitorModel model = new ActMonitorModel();
            ActMonitor      act   = CreateActMonitor();

            string strMsg = "";

            if (model.InsertActMonitor(act, ref strMsg) == true)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('Car details are added sucessfully');window.location.href ='Default.aspx'", true); //window.location ='frmDisplayUsers.aspx';
                //Response.Redirect("~/Default.aspx");
            }
            else
            {
                lblResult.Text = strMsg;
            }
        }
Exemple #10
0
        public void UpdateActualStartDateTime(int id, string _UserName, ActMonitor objActMonitor) //Tama bang ActMonitor yung primary key ng ActMonitor Table?
        {
            try
            {
                IncidentEntities db          = new IncidentEntities();
                ActMonitor       _ActMonitor = db.ActMonitors.Find(id);
                _ActMonitor.Actual_Date_and_Time_of_Start = objActMonitor.Actual_Date_and_Time_of_Start;
                db.SaveChanges();

                //CarUpdates _CarUpdates = new CarUpdates();
                //_CarUpdates.CarNumber = id;
                //_CarUpdates.CreatedBy = _UserName;
                //_CarUpdates.Details = "As of " + objActMonitor.Actual_Date_and_Time_of_Start.ToString() + " Car Incident has been started";
                //_CarUpdates.DateCreated = objActMonitor.Actual_Date_and_Time_of_Start;
                //db.CarUpdates.Add(_CarUpdates);
                //db.SaveChanges();
            }
            catch (Exception e)
            {
            }
        }
Exemple #11
0
        public void UpdateActualCompletionDateTime(int id, string _UserName, ActMonitor objActMonitor)
        {
            try
            {
                IncidentEntities db          = new IncidentEntities();
                ActMonitor       _ActMonitor = db.ActMonitors.Find(id);
                _ActMonitor.Actual_Date_and_Time_of_Completion = objActMonitor.Actual_Date_and_Time_of_Completion;
                _ActMonitor.Status = objActMonitor.Status;
                db.SaveChanges();

                CarUpdates _CarUpdates = new CarUpdates();
                _CarUpdates.CarNumber   = id;
                _CarUpdates.CreatedBy   = _UserName;
                _CarUpdates.Details     = "As of " + objActMonitor.Actual_Date_and_Time_of_Completion.ToString() + " Car Incident has been completed";
                _CarUpdates.DateCreated = objActMonitor.Actual_Date_and_Time_of_Completion;
                db.CarUpdates.Add(_CarUpdates);
                db.SaveChanges();
            }
            catch (Exception e)
            {
            }
        }
Exemple #12
0
        public void CancelActMonitor(int id, string _UserName, ActMonitor objActMonitor)
        {
            try
            {
                IncidentEntities db          = new IncidentEntities();
                ActMonitor       _ActMonitor = db.ActMonitors.Find(id);
                _ActMonitor.Status = objActMonitor.Status;
                _ActMonitor.Actual_Date_and_Time_of_Service_Interruption = objActMonitor.Actual_Date_and_Time_of_Service_Interruption;
                db.SaveChanges();

                CarUpdates _CarUpdates = new CarUpdates();
                _CarUpdates.CarNumber   = id;
                _CarUpdates.CreatedBy   = _UserName;
                _CarUpdates.Details     = "As of " + objActMonitor.Actual_Date_and_Time_of_Service_Interruption.ToString() + " Car Incident has been Cancelled";
                _CarUpdates.DateCreated = DateTime.Parse(objActMonitor.Actual_Date_and_Time_of_Service_Interruption);
                db.CarUpdates.Add(_CarUpdates);
                db.SaveChanges();
            }
            catch (Exception e)
            {
            }
        }
Exemple #13
0
        public bool InsertActMonitor(ActMonitor actmonitor, ref string errMsg)
        {
            try
            {
                IncidentEntities db = new IncidentEntities();
                db.ActMonitors.Add(actmonitor);
                db.SaveChanges();
                var maxID = db.Details_Milestones.OrderByDescending(x => x.ID).FirstOrDefault().ID;
                Details_Milestones milestone1 = new Details_Milestones()
                {
                    CarNo = actmonitor.CAR_Number, MilestoneNumber = 1, ID = maxID + 1
                };
                Details_Milestones milestone2 = new Details_Milestones()
                {
                    CarNo = actmonitor.CAR_Number, MilestoneNumber = 2, ID = maxID + 2
                };
                Details_Milestones milestone3 = new Details_Milestones()
                {
                    CarNo = actmonitor.CAR_Number, MilestoneNumber = 3, ID = maxID + 3
                };
                Details_Milestones milestone4 = new Details_Milestones()
                {
                    CarNo = actmonitor.CAR_Number, MilestoneNumber = 4, ID = maxID + 4
                };
                db.Details_Milestones.Add(milestone1);
                db.Details_Milestones.Add(milestone2);
                db.Details_Milestones.Add(milestone3);
                db.Details_Milestones.Add(milestone4);

                db.SaveChanges();
                return(true);
            }
            catch (Exception e)
            {
                errMsg = "Error" + e;
                return(false);
            }
        }
Exemple #14
0
        public bool DeleteIncident(int carID)
        {
            bool                                  success                 = false;
            IncidentEntities                      db                      = new IncidentEntities();
            ActMonitor                            objActMonitor           = db.ActMonitors.Where(x => x.CAR_Number == carID).FirstOrDefault();
            List <Details_WhatIFs>                objWhatIfs              = db.Details_WhatIFs.Where(x => x.CARID == carID).ToList();
            List <Details_Materials>              objMaterials            = db.Details_Materials.Where(x => x.CARID == carID).ToList();
            List <Details_Health_Safety>          objHealthSafety         = db.Details_Health_Safety.Where(x => x.CARID == carID).ToList();
            List <Details_ToolsEquipment>         objTools                = db.Details_ToolsEquipment.Where(x => x.CARID == carID).ToList();
            List <Details_ManPower>               objManPower             = db.Details_ManPower.Where(x => x.CARID == carID).ToList();
            List <Details_Methodology>            objMethodology          = db.Details_Methodology.Where(x => x.CARID == carID).ToList();
            List <Details_ValveManipulationTable> objdtlValueManipulation = db.Details_ValveManipulationTable.Where(x => x.CARID == carID).ToList();

            db.Details_WhatIFs.RemoveRange(objWhatIfs);
            db.Details_Materials.RemoveRange(objMaterials);
            db.Details_Health_Safety.RemoveRange(objHealthSafety);
            db.Details_ToolsEquipment.RemoveRange(objTools);
            db.Details_ManPower.RemoveRange(objManPower);
            db.Details_Methodology.RemoveRange(objMethodology);
            db.Details_ValveManipulationTable.RemoveRange(objdtlValueManipulation);
            db.ActMonitors.Remove(objActMonitor);
            db.SaveChanges();
            return(success);
        }
Exemple #15
0
        public bool UpdateActMonitor(int id, ActMonitor actmonitor, ref string errMsg) //Tama bang ActMonitor yung primary key ng ActMonitor Table?
        {
            try
            {
                IncidentEntities db = new IncidentEntities();

                //Fetching

                ActMonitor a = db.ActMonitors.Find(id);

                //Lagay dito lahat ng parameter na need ichange :((


                a.Scheduled_Today_ = actmonitor.Scheduled_Today_;
                //a.Date_and_Time_of_CAR_Submission = actmonitor.Date_and_Time_of_CAR_Submission;
                a.Unique_CAR_ID                 = actmonitor.Unique_CAR_ID;
                a.Network_Grid_BA               = actmonitor.Network_Grid_BA;
                a.Business_Zone__Grid           = actmonitor.Business_Zone__Grid;
                a.DMZ__Facility                 = actmonitor.Business_Zone__Grid;
                a.Location                      = actmonitor.Location;
                a.Affected_Barangay_s_          = actmonitor.Affected_Barangay_s_;
                a.Affected_Municipality         = actmonitor.Affected_Municipality;
                a.List_of_Affected_MRUs         = actmonitor.List_of_Affected_MRUs;
                a.List_of_Affected_DMAs         = actmonitor.List_of_Affected_DMAs;
                a.Number_of_Affected_Households = actmonitor.Number_of_Affected_Households;
                a.Need_Media_Advisory           = actmonitor.Need_Media_Advisory;
                a.OIM = actmonitor.OIM;
                a.SIM = actmonitor.SIM;
                a.CIM = actmonitor.CIM;
                a.Remarks__Comments       = actmonitor.Remarks__Comments;
                a.Prework_Completion      = actmonitor.Prework_Completion;
                a.Interruption_of_Service = actmonitor.Interruption_of_Service;
                a.Physical_Completion     = actmonitor.Physical_Completion;
                a.Return_of_Service       = actmonitor.Return_of_Service;
                a.Duration = actmonitor.Duration;
                a.Sender_Receiver__Date_Time = actmonitor.Sender_Receiver__Date_Time;

                a.Status = actmonitor.Status;
                //a.Actual_Date_and_Time_of_Start = actmonitor.Actual_Date_and_Time_of_Start;
                //a.Actual_Date_and_Time_of_Completion = actmonitor.Actual_Date_and_Time_of_Completion;
                a.Actual_Date_and_Time_of_Service_Interruption = actmonitor.Actual_Date_and_Time_of_Service_Interruption;
                a.Actual_Date_and_Time_of_Service_Return       = actmonitor.Actual_Date_and_Time_of_Service_Return;
                a.Actual_Duration_of_Activity__in_hours_       = actmonitor.Actual_Duration_of_Activity__in_hours_;
                a.Variance_in_Duration__Agreed_vs_Actual_      = actmonitor.Variance_in_Duration__Agreed_vs_Actual_;
                a.Reported_by_and_time_of_sign_on__            = actmonitor.Reported_by_and_time_of_sign_on__;
                a.Closed_out_by_and_time_of_sign_off           = actmonitor.Closed_out_by_and_time_of_sign_off;
                a.Initial_Alert_Level_             = actmonitor.Initial_Alert_Level_;
                a.Incident_Escalation___Yes_or_No_ = actmonitor.With_or_without_service_interruption___Yes_or_No_;
                a.With_or_without_service_interruption___Yes_or_No_ = actmonitor.With_or_without_service_interruption___Yes_or_No_;
                a.Duty__last_update_ = actmonitor.Duty__last_update_;
                a.Findings           = actmonitor.Findings;

                a.Classification                 = actmonitor.Classification;
                a.Incident                       = actmonitor.Incident;
                a.Type_of_Activity               = actmonitor.Type_of_Activity;
                a.Equipment__Appurtenance        = actmonitor.Equipment__Appurtenance;
                a.Type_of_Equipment_Appurtenance = actmonitor.Type_of_Equipment_Appurtenance;
                a.Size          = actmonitor.Size;
                a.Affected_Area = actmonitor.Affected_Area;  //Di pa gagana kasi wala data source
                a.Contractor    = actmonitor.Contractor;
                //a.Means_of_Notification = actmonitor.Means_of_Notification;  //Di pa gagana kasi wala table

                db.SaveChanges();
                return(true); //"Update successfully!";
            }
            catch (Exception e)
            {
                errMsg = "Error" + e;
                return(false);
            }
        }
Exemple #16
0
        private ActMonitor CreateActMonitor()
        {
            ActMonitor a;

            if (Session["CARID"] == null)
            {
                a = new ActMonitor();
                a.Scheduled_Today_ = System.DateTime.Now.ToString();                      //"9999-12-31"; // should be bool (yes / no)
                                                                                          // a.Date_and_Time_of_CAR_Submission = Convert.ToDateTime("2018-05-02");
                a.Unique_CAR_ID         = Guid.NewGuid().ToString();                      //"sample"; // generate format ("first letters of incident" - "month" - "sequnce")
                a.Network_Grid_BA       = Convert.ToInt32(ddlNetworkGrid.SelectedValue);  // add in interface --done
                a.Business_Zone__Grid   = Convert.ToInt32(ddlBusinessZone.SelectedValue); // add in interface --done
                a.DMZ__Facility         = Convert.ToInt32(ddlDMZ.SelectedValue);          // add in interface --done
                a.Location              = txtLocation.Text;
                a.Affected_Barangay_s_  = txtBrgy.Text;
                a.Affected_Municipality = txtMunicipality.Text;
                a.List_of_Affected_MRUs = txtMRU.Text;
                a.List_of_Affected_DMAs = txtDMA.Text;
                if (txtHousehold.Text.Trim() == string.Empty)
                {
                    a.Number_of_Affected_Households = null;
                }
                else
                {
                    a.Number_of_Affected_Households = Convert.ToInt32(txtHousehold.Text);
                }
                a.Classification                 = Convert.ToInt32(ddlClassification.SelectedValue);
                a.Incident                       = Convert.ToInt32(ddlEvent.SelectedValue);
                a.Type_of_Activity               = Convert.ToInt32(ddlAct.SelectedValue);
                a.Equipment__Appurtenance        = Convert.ToInt32(ddlEquip.SelectedValue);
                a.Type_of_Equipment_Appurtenance = Convert.ToInt32(ddlType.SelectedValue);
                a.Size                  = Convert.ToInt32(ddlSize.SelectedValue);
                a.Affected_Area         = ddlArea.SelectedValue;
                a.Contractor            = Convert.ToInt32(ddlContractor.SelectedValue);
                a.Means_of_Notification = ddlMeans.SelectedIndex;
                a.Need_Media_Advisory   = 1;
                a.OIM = txtOimID.Text;
                a.SIM = txtSimID.Text;
                a.CIM = txtCimID.Text;
                a.Remarks__Comments = txtRemarks.Text;
                a.Date_and_Time_of_CAR_Submission = DateTime.Now;
                a.Prework_Completion      = null;                           // Convert.ToDateTime("1999-12-10"); //should be declared in details- milestone (add interface)
                a.Interruption_of_Service = null;                           // Convert.ToDateTime("2018-05-02"); //should be declared in details- milestone (add interface)
                a.Physical_Completion     = null;                           // Convert.ToDateTime("2018-05-02"); //should be declared in details- milestone (add interface)
                a.Return_of_Service       = null;                           // Convert.ToDateTime("2018-05-02"); //should be declared in details - milestones (add interface)
                a.Duration = null;                                          //computatin
                a.Sender_Receiver__Date_Time = null;                        // "sample";
                a.Classification1            = Convert.ToString(ddlClassification.SelectedItem);
                a.Status = "In Progress";                                   // "sample"; // condition to default on "In-progess" --data avaiable in database -- checking throughtime of start and completion (declared vs actual)
                                                                            // a.Actual_Date_and_Time_of_Start = null;// Convert.ToDateTime("2018-05-02"); // through interface (new page) user will activate or through update
                                                                            //a.Actual_Date_and_Time_of_Completion = null;// Convert.ToDateTime("2018-05-02"); // through interface (new page) user will activate or through update
                a.Actual_Date_and_Time_of_Service_Interruption = null;      // "Sample";// through interface (new page) user will activate or through update
                a.Actual_Date_and_Time_of_Service_Return       = null;      // Convert.ToDateTime("2018-05-02");// through interface (new page) user will activate or through update
                a.Actual_Duration_of_Activity__in_hours_       = null;      // 100; // computation
                a.Variance_in_Duration__Agreed_vs_Actual_      = null;      // 100; // computaion
                a.Reported_by_and_time_of_sign_on__            = null;      // "sample"; // fetch data of user login
                a.Closed_out_by_and_time_of_sign_off           = null;      // "sample"; // fetch data of user login - respinsible: OIM
                a.Initial_Alert_Level_             = null;                  // "sample"; // add code for conditions yellow and red alert based on affected area and incident
                a.Incident_Escalation___Yes_or_No_ = null;                  // "yes"; // check the ppt for conditon depends on incident
                a.With_or_without_service_interruption___Yes_or_No_ = null; // "yes"; // check the ppt for conditon depends on incident
                a.Duty__last_update_ = null;                                // "sample"; // fetch from update
                a.Findings           = null;                                // "sample";
            }
            else
            {
                IncidentEntities dbEntities = new IncidentEntities();
                a = dbEntities.ActMonitors.Where(x => x.CAR_Number == Convert.ToInt32(Session["CARID"].ToString())).FirstOrDefault();
            }

            return(a);
        }
        //Created by PS2019
        //Handle RowCommand event for MileStone grid for handling Start/Complete operation
        protected void grdMilestones_RowCommand(Object sender, GridViewCommandEventArgs e)
        {
            int                index           = Convert.ToInt32(e.CommandArgument);
            GridViewRow        row             = grdMilestones.Rows[index];
            CarDetails         objCarDetails   = new CarDetails();
            Details_Milestones objdtlMilestone = new Details_Milestones();
            Button             buttonCancel    = (Button)row.Cells[7].Controls[0];
            Button             buttonControl   = (Button)row.Cells[6].Controls[0];

            if (e.CommandName == "Start")
            {
                switch (((Button)row.Cells[6].Controls[0]).Text)
                {
                case "Cancel":
                    CancelMileStone(row.Cells[2].Text.ToString());
                    break;

                default:
                    if (ViewState["MileStoneStatus"].ToString() != "Complete")
                    {
                        row.Cells[5].Text = "In progress";
                        row.Cells[2].Text = System.DateTime.Now.ToString();
                        row.Cells[4].Text = SetDuration(DateTime.Now, DateTime.Parse(row.Cells[2].Text));
                        ((Button)row.Cells[6].Controls[0]).Text = "Cancel";
                        UpdateMileStone(Convert.ToInt32(row.Cells[0].Text), DateTime.Parse(row.Cells[2].Text), DateTime.Parse("1/1/0001"));
                    }

                    if (index == 0)
                    {
                        UpdateActualStartDateTime(DateTime.Parse(row.Cells[2].Text));
                    }
                    else if (index == 1)
                    {
                        ((Button)grdMilestones.Rows[0].Cells[6].Controls[0]).Text    = "Completed on time";
                        ((Button)grdMilestones.Rows[0].Cells[6].Controls[0]).Enabled = false;
                        grdMilestones.Rows[0].Cells[3].Text = System.DateTime.Now.ToString();
                        grdMilestones.Rows[0].Cells[4].Text = Convert.ToString((DateTime.Parse(grdMilestones.Rows[0].Cells[3].Text) - DateTime.Parse(grdMilestones.Rows[0].Cells[2].Text)).Seconds);
                        SetStatus(DateTime.Parse(grdMilestones.Rows[0].Cells[1].Text), DateTime.Parse(grdMilestones.Rows[0].Cells[2].Text), 0);
                        UpdateMileStone(Convert.ToInt32(grdMilestones.Rows[0].Cells[0].Text), DateTime.Parse(grdMilestones.Rows[0].Cells[2].Text), DateTime.Parse(grdMilestones.Rows[0].Cells[3].Text));
                        grdMilestones.Rows[0].Cells[4].Text = SetDuration(DateTime.Parse(grdMilestones.Rows[0].Cells[3].Text), DateTime.Parse(grdMilestones.Rows[0].Cells[2].Text));
                    }
                    else if (index == 2)
                    {
                        ((Button)grdMilestones.Rows[0].Cells[6].Controls[0]).Text    = "Completed on time";
                        ((Button)grdMilestones.Rows[0].Cells[6].Controls[0]).Enabled = false;
                        ((Button)grdMilestones.Rows[1].Cells[6].Controls[0]).Text    = "Completed on time";
                        ((Button)grdMilestones.Rows[1].Cells[6].Controls[0]).Enabled = false;
                        grdMilestones.Rows[1].Cells[3].Text = System.DateTime.Now.ToString();
                        grdMilestones.Rows[1].Cells[4].Text = Convert.ToString((DateTime.Parse(grdMilestones.Rows[1].Cells[3].Text) - DateTime.Parse(grdMilestones.Rows[1].Cells[2].Text)).Seconds);

                        SetStatus(DateTime.Parse(grdMilestones.Rows[0].Cells[1].Text), DateTime.Parse(grdMilestones.Rows[0].Cells[2].Text), 0);
                        SetStatus(DateTime.Parse(grdMilestones.Rows[1].Cells[1].Text), DateTime.Parse(grdMilestones.Rows[1].Cells[2].Text), 1);
                        UpdateMileStone(Convert.ToInt32(grdMilestones.Rows[1].Cells[0].Text), DateTime.Parse(grdMilestones.Rows[1].Cells[2].Text), DateTime.Parse(grdMilestones.Rows[1].Cells[3].Text));

                        grdMilestones.Rows[0].Cells[4].Text = SetDuration(DateTime.Parse(grdMilestones.Rows[0].Cells[3].Text), DateTime.Parse(grdMilestones.Rows[0].Cells[2].Text));
                        grdMilestones.Rows[1].Cells[4].Text = SetDuration(DateTime.Parse(grdMilestones.Rows[1].Cells[3].Text), DateTime.Parse(grdMilestones.Rows[1].Cells[2].Text));
                    }
                    else if (index == 3)
                    {
                        ((Button)grdMilestones.Rows[0].Cells[6].Controls[0]).Enabled = false;
                        ((Button)grdMilestones.Rows[1].Cells[6].Controls[0]).Enabled = false;
                        ((Button)grdMilestones.Rows[2].Cells[6].Controls[0]).Enabled = false;
                        ((Button)grdMilestones.Rows[3].Cells[6].Controls[0]).Text    = "Complete";

                        SetStatus(DateTime.Parse(grdMilestones.Rows[0].Cells[1].Text), DateTime.Parse(grdMilestones.Rows[0].Cells[2].Text), 0);
                        SetStatus(DateTime.Parse(grdMilestones.Rows[1].Cells[1].Text), DateTime.Parse(grdMilestones.Rows[1].Cells[2].Text), 1);
                        SetStatus(DateTime.Parse(grdMilestones.Rows[2].Cells[1].Text), DateTime.Parse(grdMilestones.Rows[2].Cells[2].Text), 2);

                        if (ViewState["MileStoneStatus"].ToString() == "Complete")
                        {
                            row.Cells[3].Text = System.DateTime.Now.ToString();
                            row.Cells[4].Text = SetDuration(DateTime.Now, DateTime.Parse(row.Cells[2].Text));
                            SetStatus(DateTime.Parse(grdMilestones.Rows[3].Cells[1].Text), DateTime.Parse(grdMilestones.Rows[3].Cells[2].Text), 3);
                            ((Button)grdMilestones.Rows[3].Cells[6].Controls[0]).Enabled = false;
                            buttonCancel.Visible = false;
                            ActMonitorModel model         = new ActMonitorModel();
                            ActMonitor      objActMonitor = new ActMonitor();
                            int             id            = Convert.ToInt32(txtCarID.Text);
                            objActMonitor.CAR_Number = Convert.ToInt32(txtCarID.Text);
                            objActMonitor.Actual_Date_and_Time_of_Completion = DateTime.Parse(System.DateTime.Now.ToString());
                            if ((grdMilestones.Rows[0].Cells[5].Text == "Delayed") || (grdMilestones.Rows[1].Cells[5].Text == "Delayed") ||
                                (grdMilestones.Rows[2].Cells[5].Text == "Delayed") || (grdMilestones.Rows[3].Cells[5].Text == "Delayed"))
                            {
                                objActMonitor.Status = "Delayed";
                            }
                            else
                            {
                                objActMonitor.Status = "Completed on time";
                            }
                            UpdateMileStone(Convert.ToInt32(row.Cells[0].Text), DateTime.Parse(row.Cells[2].Text), DateTime.Parse(System.DateTime.Now.ToString()));
                            model.UpdateActualCompletionDateTime(id, Session["UserName"].ToString(), objActMonitor);
                            grvUpdates.DataBind();
                            disableScreen();
                        }
                        else
                        {
                            buttonCancel.Visible = true;
                            grdMilestones.Rows[2].Cells[3].Text = System.DateTime.Now.ToString();
                            grdMilestones.Rows[2].Cells[4].Text = SetDuration(DateTime.Parse(grdMilestones.Rows[2].Cells[3].Text), DateTime.Parse(row.Cells[2].Text));
                            grdMilestones.Rows[0].Cells[4].Text = SetDuration(DateTime.Parse(grdMilestones.Rows[0].Cells[3].Text), DateTime.Parse(grdMilestones.Rows[0].Cells[2].Text));
                            grdMilestones.Rows[1].Cells[4].Text = SetDuration(DateTime.Parse(grdMilestones.Rows[1].Cells[3].Text), DateTime.Parse(grdMilestones.Rows[1].Cells[2].Text));
                            grdMilestones.Rows[2].Cells[4].Text = SetDuration(DateTime.Parse(grdMilestones.Rows[2].Cells[3].Text), DateTime.Parse(grdMilestones.Rows[2].Cells[2].Text));
                            UpdateMileStone(Convert.ToInt32(grdMilestones.Rows[2].Cells[0].Text), DateTime.Parse(grdMilestones.Rows[2].Cells[2].Text), DateTime.Parse(grdMilestones.Rows[2].Cells[3].Text));
                            ViewState["MileStoneStatus"] = "Complete";
                        }
                    }
                    break;
                }
            }
            else if (e.CommandName == "Cancel")
            {
                CancelMileStone(row.Cells[2].Text.ToString());
            }
            hidTAB.Value = "#tab0default";
        }