private void GrdPointRepairsAdd()
        {
            Page.Validate("repairsFooter");
            if (Page.IsValid)
            {
                if (ValidateFooter())
                {
                    Guid id = (Guid)Session["lfsMasterAreaId"];
                    int companyId = Convert.ToInt32(Session["companyID"]);
                    string repairSize = ""; if (((TextBox)grdPointRepairs.FooterRow.FindControl("tbxSizeFooter")).Text != "") repairSize = ((TextBox)grdPointRepairs.FooterRow.FindControl("tbxSizeFooter")).Text.Trim();
                    DateTime? installDate = null; if (((RadDatePicker)grdPointRepairs.FooterRow.FindControl("tkrdpInstallDateFooter")).SelectedDate.HasValue) installDate = ((RadDatePicker)grdPointRepairs.FooterRow.FindControl("tkrdpInstallDateFooter")).SelectedDate.Value;
                    string distance = ""; if (((TextBox)grdPointRepairs.FooterRow.FindControl("tbxDistanceFooter")).Text != "") distance = ((TextBox)grdPointRepairs.FooterRow.FindControl("tbxDistanceFooter")).Text.Trim();
                    int? reinstates = null; if (((TextBox)grdPointRepairs.FooterRow.FindControl("tbxReinstatesFooter")).Text != "") reinstates = Int32.Parse(((TextBox)grdPointRepairs.FooterRow.FindControl("tbxReinstatesFooter")).Text.Trim());
                    string ltAtMh = ""; if (((TextBox)grdPointRepairs.FooterRow.FindControl("tbxLtMhFooter")).Text != "") ltAtMh = ((TextBox)grdPointRepairs.FooterRow.FindControl("tbxLtMhFooter")).Text.Trim();
                    string vtAtMh = ""; if (((TextBox)grdPointRepairs.FooterRow.FindControl("tbxVtMhFooter")).Text != "") vtAtMh = ((TextBox)grdPointRepairs.FooterRow.FindControl("tbxVtMhFooter")).Text.Trim();
                    string linerDistance = ""; if (((TextBox)grdPointRepairs.FooterRow.FindControl("tbxLinerDistanceFooter")).Text != "") linerDistance = ((TextBox)grdPointRepairs.FooterRow.FindControl("tbxLinerDistanceFooter")).Text.Trim();
                    string direction = ""; if (((DropDownList)grdPointRepairs.FooterRow.FindControl("ddlDirectionFooter")).SelectedValue != "") direction = ((DropDownList)grdPointRepairs.FooterRow.FindControl("ddlDirectionFooter")).SelectedValue;
                    string mhShot = ""; if (((DropDownList)grdPointRepairs.FooterRow.FindControl("ddlMhShotFooter")).SelectedValue != "") mhShot = ((DropDownList)grdPointRepairs.FooterRow.FindControl("ddlMhShotFooter")).SelectedValue;
                    string comments = ""; if (((TextBox)grdPointRepairs.FooterRow.FindControl("tbxCommentFooter")).Text != "") comments = ((TextBox)grdPointRepairs.FooterRow.FindControl("tbxCommentFooter")).Text.Trim();
                    bool deleted = false;
                    bool extraRepair = ((CheckBox)grdPointRepairs.FooterRow.FindControl("ckbxExptraRepairFooter")).Checked;
                    bool cancelled = ((CheckBox)grdPointRepairs.FooterRow.FindControl("ckbxCancelledFooter")).Checked;
                    bool approved = ((CheckBox)grdPointRepairs.FooterRow.FindControl("ckbxApprovedFooter")).Checked;
                    bool notApproved = ((CheckBox)grdPointRepairs.FooterRow.FindControl("ckbxNotApprovedFooter")).Checked;
                    bool archived = false;
                    bool inDatabase = false;
                    decimal? cost = null;

                    AddRecordPointRepairs model = new AddRecordPointRepairs(addRecordTDS);
                    model.Insert(id, repairSize, installDate, distance, cost, reinstates, ltAtMh, vtAtMh, linerDistance, direction, mhShot, comments, deleted, extraRepair, cancelled, approved, notApproved, archived, companyId, addRecordTDS, inDatabase);

                    Session.Remove("pointRepairDummy");
                    Session["addRecordTDS"] = addRecordTDS;

                    grdPointRepairs.DataBind();
                    grdPointRepairs.PageIndex = grdPointRepairs.PageCount - 1;
                }
            }
        }
        protected void grdPointRepairs_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            Guid id = new Guid(((Label)grdPointRepairs.Rows[e.RowIndex].Cells[0].FindControl("lblId")).Text);
            int refId = Int32.Parse(((Label)grdPointRepairs.Rows[e.RowIndex].Cells[1].FindControl("lblRefId")).Text);
            int companyId = Int32.Parse(((Label)grdPointRepairs.Rows[e.RowIndex].Cells[3].FindControl("lblCOMPANY_ID")).Text);

            AddRecordPointRepairs model = new AddRecordPointRepairs(addRecordTDS);
            model.Delete(id, refId, companyId);

            Session["addRecordTDS"] = addRecordTDS;
        }
        protected void grdPointRepairs_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            Page.Validate("repairsEdit");
            if (Page.IsValid)
            {
                Guid id = new Guid(((Label)grdPointRepairs.Rows[e.RowIndex].Cells[0].FindControl("lblId")).Text);
                int refId = Int32.Parse(((Label)grdPointRepairs.Rows[e.RowIndex].Cells[1].FindControl("lblRefId")).Text);
                int companyId = Int32.Parse(((Label)grdPointRepairs.Rows[e.RowIndex].Cells[2].FindControl("lblCOMPANY_ID")).Text);

                string linerDistance = ((TextBox)grdPointRepairs.Rows[e.RowIndex].Cells[3].FindControl("tbxLinerDistanceEdit")).Text.Trim();
                string direction = ((DropDownList)grdPointRepairs.Rows[e.RowIndex].Cells[3].FindControl("ddlDirectionEdit")).SelectedValue;
                int? reinstates = null; if (((TextBox)grdPointRepairs.Rows[e.RowIndex].Cells[3].FindControl("tbxReinstatesEdit")).Text != "") reinstates = Int32.Parse(((TextBox)grdPointRepairs.Rows[e.RowIndex].Cells[3].FindControl("tbxReinstatesEdit")).Text);
                string ltMh = ((TextBox)grdPointRepairs.Rows[e.RowIndex].Cells[3].FindControl("tbxLtMhEdit")).Text.Trim();
                string vtMh = ((TextBox)grdPointRepairs.Rows[e.RowIndex].Cells[3].FindControl("tbxVtMhEdit")).Text.Trim();
                DateTime? installDate = null; if (((RadDatePicker)grdPointRepairs.Rows[e.RowIndex].Cells[3].FindControl("tkrdpInstallDateEdit")).SelectedDate.HasValue) installDate = ((RadDatePicker)grdPointRepairs.Rows[e.RowIndex].Cells[3].FindControl("tkrdpInstallDateEdit")).SelectedDate.Value;
                string distance = ((TextBox)grdPointRepairs.Rows[e.RowIndex].Cells[3].FindControl("tbxDistanceEdit")).Text.Trim();
                string size = ((TextBox)grdPointRepairs.Rows[e.RowIndex].Cells[3].FindControl("tbxSizeEdit")).Text.Trim();
                string mhShot = ((DropDownList)grdPointRepairs.Rows[e.RowIndex].Cells[3].FindControl("ddlMhShotEdit")).SelectedValue;
                bool extraRepair = ((CheckBox)grdPointRepairs.Rows[e.RowIndex].Cells[3].FindControl("ckbxExptraRepairEdit")).Checked;
                bool cancelled = ((CheckBox)grdPointRepairs.Rows[e.RowIndex].Cells[3].FindControl("ckbxCancelledEdit")).Checked;
                bool approved = ((CheckBox)grdPointRepairs.Rows[e.RowIndex].Cells[3].FindControl("ckbxApprovedEdit")).Checked;
                bool notApproved = ((CheckBox)grdPointRepairs.Rows[e.RowIndex].Cells[3].FindControl("ckbxNotApprovedEdit")).Checked;

                AddRecordPointRepairs model = new AddRecordPointRepairs(addRecordTDS);
                model.Update(id, refId, companyId, linerDistance, direction, reinstates, ltMh, vtMh, installDate, distance, size, mhShot, extraRepair, cancelled, approved, notApproved);

                Session["addRecordTDS"] = addRecordTDS;
            }
            else
            {
                e.Cancel = true;
            }
        }
        protected void grdPointRepairs_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Edit) || (e.Row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate))))
            {
                // Initialize values
                Guid id = new Guid(((Label)e.Row.FindControl("lblId")).Text);
                int refId = Int32.Parse(((Label)e.Row.FindControl("lblRefId")).Text);
                int companyId = Int32.Parse(((Label)e.Row.FindControl("lblCOMPANY_ID")).Text);

                AddRecordPointRepairsGateway addRecordPointRepairsGateway = new AddRecordPointRepairsGateway(addRecordTDS);

                // ... for direction
                if (addRecordPointRepairsGateway.GetDirection(id, refId, companyId) != "")
                {
                    ((DropDownList)e.Row.FindControl("ddlDirectionEdit")).SelectedValue = addRecordPointRepairsGateway.GetDirection(id, refId, companyId);
                }
                else
                {
                    ((DropDownList)e.Row.FindControl("ddlDirectionEdit")).SelectedIndex = 4;
                }

                // ... for MhShoot
                if (addRecordPointRepairsGateway.GetMHShot(id, refId, companyId) != "")
                {
                    ((DropDownList)e.Row.FindControl("ddlMhShotEdit")).SelectedValue = addRecordPointRepairsGateway.GetMHShot(id, refId, companyId);
                }
                else
                {
                    ((DropDownList)e.Row.FindControl("ddlMhShotEdit")).SelectedIndex = 2;
                }

                // ... For Install Date
                if (addRecordPointRepairsGateway.Table.Rows.Count > 0)
                {
                    if (addRecordPointRepairsGateway.GetInstallDate(id, refId, companyId).HasValue)
                    {
                        ((RadDatePicker)e.Row.FindControl("tkrdpInstallDateEdit")).SelectedDate = (DateTime)addRecordPointRepairsGateway.GetInstallDate(id, refId, companyId);
                    }
                }
            }

            if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Normal) || (e.Row.RowState == (DataControlRowState.Normal | DataControlRowState.Alternate))))
            {
                // Validation of permissions
                if (Convert.ToBoolean(Session["sgLFS_APP_EDIT"]))
                {
                    // Button Validation
                    e.Row.FindControl("ibtnEdit").Visible = true;
                    e.Row.FindControl("ibtnDelete").Visible = true;
                }
                else
                {
                    // Button validation
                    e.Row.FindControl("ibtnEdit").Visible = false;
                    e.Row.FindControl("ibtnDelete").Visible = false;
                }
            }

            if (e.Row.RowType == DataControlRowType.Footer)
            {
                if (Convert.ToBoolean(Session["sgLFS_APP_EDIT"]))
                {
                    // Initialize variables
                    ((DropDownList)e.Row.FindControl("ddlMhShotFooter")).SelectedIndex = 2;
                    ((DropDownList)e.Row.FindControl("ddlDirectionFooter")).SelectedIndex = 4;

                    // If the limit is reached
                    AddRecordPointRepairs addRecordPointRepairs = new AddRecordPointRepairs(addRecordTDS);
                    string newDetailId = addRecordPointRepairs.GetNewPointRepairsDetailId(addRecordTDS);

                    if (newDetailId == "-1")
                    {
                        ((RadDatePicker)e.Row.FindControl("tkrdpInstallDateFooter")).Visible = false;
                        ((TextBox)e.Row.FindControl("tbxLinerDistanceFooter")).Visible = false;
                        ((CheckBox)e.Row.FindControl("ddlDirectionFooter")).Visible = false;
                        ((TextBox)e.Row.FindControl("tbxLtMhFooter")).Visible = false;
                        ((TextBox)e.Row.FindControl("tbxVtMhFooter")).Visible = false;
                        ((TextBox)e.Row.FindControl("tbxDistanceFooter")).Visible = false;
                        ((TextBox)e.Row.FindControl("tbxSizeFooter")).Visible = false;
                        ((DropDownList)e.Row.FindControl("ddlMhShotFooter")).Visible = false;
                        ((CheckBox)e.Row.FindControl("ckbxExptraRepairFooter")).Visible = false;
                        ((CheckBox)e.Row.FindControl("ckbxCancelledFooter")).Visible = false;
                        ((CheckBox)e.Row.FindControl("ckbxApprovedFooter")).Visible = false;
                        ((CheckBox)e.Row.FindControl("ckbxNotApprovedFooter")).Visible = false;
                        ((TextBox)e.Row.FindControl("tbxCommentFooter")).Visible = false;
                        e.Row.FindControl("ibtnAdd").Visible = false;
                        lblMaxNumber.Visible = true;
                    }
                    else
                    {
                        ((RadDatePicker)e.Row.FindControl("tkrdpInstallDateFooter")).Visible = true;
                        ((TextBox)e.Row.FindControl("tbxLinerDistanceFooter")).Visible = true;
                        ((DropDownList)e.Row.FindControl("ddlDirectionFooter")).Visible = true;
                        ((TextBox)e.Row.FindControl("tbxLtMhFooter")).Visible = true;
                        ((TextBox)e.Row.FindControl("tbxVtMhFooter")).Visible = true;
                        ((TextBox)e.Row.FindControl("tbxDistanceFooter")).Visible = true;
                        ((TextBox)e.Row.FindControl("tbxSizeFooter")).Visible = true;
                        ((DropDownList)e.Row.FindControl("ddlMhShotFooter")).Visible = true;
                        ((CheckBox)e.Row.FindControl("ckbxExptraRepairFooter")).Visible = true;
                        ((CheckBox)e.Row.FindControl("ckbxCancelledFooter")).Visible = true;
                        ((CheckBox)e.Row.FindControl("ckbxApprovedFooter")).Visible = true;
                        ((CheckBox)e.Row.FindControl("ckbxNotApprovedFooter")).Visible = true;
                        ((TextBox)e.Row.FindControl("tbxCommentFooter")).Visible = true;
                        e.Row.FindControl("ibtnAdd").Visible = true;
                        lblMaxNumber.Visible = false;
                    }
                }
                else
                {
                    ((RadDatePicker)e.Row.FindControl("tkrdpInstallDateFooter")).Visible = false;
                    ((TextBox)e.Row.FindControl("tbxLinerDistanceFooter")).Visible = false;
                    ((TextBox)e.Row.FindControl("tbxDirectionFooter")).Visible = false;
                    ((TextBox)e.Row.FindControl("tbxLtMhFooter")).Visible = false;
                    ((TextBox)e.Row.FindControl("tbxVtMhFooter")).Visible = false;
                    ((TextBox)e.Row.FindControl("tbxDistanceFooter")).Visible = false;
                    ((TextBox)e.Row.FindControl("tbxSizeFooter")).Visible = false;
                    ((DropDownList)e.Row.FindControl("ddlMhShotFooter")).Visible = false;
                    ((CheckBox)e.Row.FindControl("ckbxExptraRepairFooter")).Visible = false;
                    ((CheckBox)e.Row.FindControl("ckbxCancelledFooter")).Visible = false;
                    ((CheckBox)e.Row.FindControl("ckbxApprovedFooter")).Visible = false;
                    ((CheckBox)e.Row.FindControl("ckbxNotApprovedFooter")).Visible = false;
                    ((TextBox)e.Row.FindControl("tbxCommentFooter")).Visible = false;
                    e.Row.FindControl("ibtnAdd").Visible = false;
                    lblMaxNumber.Visible = false;
                }
            }
        }
예제 #5
0
        //
        // UpdateRecord2
        //
        // Updates the database from a typed dataset containing a row for LFS_MASTER_AREA,
        // and zero or more rows for LFS_M2_TABLES.
        //
        public void UpdateRecord2(TDSLFSRecord dataSet, int companyId, AddRecordTDS addRecordTDS, ViewFullLengthLiningTDS viewFullLengthLiningTDS, ViewJLinersheetTDS viewJLinersheetTDS, string tdsToWork)
        {
            //--- Prepare transaction
            //--- ... Open connection and start transaction
            dcConnection.Open();
            SqlTransaction transaction2 = dcConnection.BeginTransaction();

            //... Assign transaction to data adapters
            this.daLFSMasterArea.InsertCommand.Transaction = transaction2;
            this.daLFSMasterArea.UpdateCommand.Transaction = transaction2;
            this.daLFSMasterArea.DeleteCommand.Transaction = transaction2;

            this.daLFSJunctionLiner2.InsertCommand.Transaction = transaction2;
            this.daLFSJunctionLiner2.UpdateCommand.Transaction = transaction2;
            this.daLFSJunctionLiner2.DeleteCommand.Transaction = transaction2;

            this.daLfsMasterAreaRct.InsertCommand.Transaction = transaction2;
            this.daLfsMasterAreaRct.UpdateCommand.Transaction = transaction2;
            this.daLfsMasterAreaRct.DeleteCommand.Transaction = transaction2;

            this.daLfsJunctionLinerRct.InsertCommand.Transaction = transaction2;
            this.daLfsJunctionLinerRct.UpdateCommand.Transaction = transaction2;
            this.daLfsJunctionLinerRct.DeleteCommand.Transaction = transaction2;

            try
            {
                //Update database

                //... deletes
                daLFSJunctionLiner2.Update(dataSet.LFS_JUNCTION_LINER2.Select("", "", DataViewRowState.Deleted));
                daLFSMasterArea.Update(dataSet.LFS_MASTER_AREA.Select("", "", DataViewRowState.Deleted));

                //... updates
                daLFSJunctionLiner2.Update(dataSet.LFS_JUNCTION_LINER2.Select("", "", DataViewRowState.ModifiedCurrent));
                daLFSMasterArea.Update(dataSet.LFS_MASTER_AREA.Select("", "", DataViewRowState.ModifiedCurrent));

                //... inserts
                // Point Repairs
                daLFSMasterArea.Update(dataSet.LFS_MASTER_AREA.Select("", "", DataViewRowState.Added));
                daLFSJunctionLiner2.Update(dataSet.LFS_JUNCTION_LINER2.Select("", "", DataViewRowState.Added));

                //... record change tracking records
                daLfsMasterAreaRct.Update(dataSet);

                //--- Commit transaction
                transaction2.Commit();

            }
            catch (DBConcurrencyException dBConcurrencyException)
            {
                //--- Rollback transaction
                transaction2.Rollback();

                //--- Throw exception
                throw new Exception("Concurrency error: Another user already updated the data you are working on.  Your operation has been cancelled.", dBConcurrencyException);
            }
            catch (SqlException sqlException)
            {
                //--- Rollback transaction
                transaction2.Rollback();

                //--- Throw exception
                byte severityLevel = sqlException.Class;
                if (severityLevel <= 16)
                {
                    throw new Exception("Low severity error. Your operation has been cancelled.  SQL Error " + severityLevel + ".");
                }
                if ((severityLevel >= 17) && (severityLevel <= 19))
                {
                    throw new Exception("Mid severity error. Your operation has been cancelled.  SQL Error " + severityLevel + ".");
                }
                if (severityLevel >= 20)
                {
                    throw new Exception("High severity error. Your operation has been cancelled.  SQL Error " + severityLevel + ".");
                }
            }
            catch (Exception e)
            {
                //--- Rollback transaction
                transaction2.Rollback();

                //--- Throw exception
                throw new Exception("Unknow error.  Your operation has been cancelled.", e);
            }
            finally
            {
                //--- Close connection
                if (dcConnection.State == System.Data.ConnectionState.Open)
                {
                    dcConnection.Close();
                }

                object[] array = dataSet.LFS_MASTER_AREA.Rows[0].ItemArray;
                Guid newId = (Guid)array.GetValue(0);

                if (tdsToWork == "addRecord")
                {
                    AddRecordPointRepairs addRecordPointRepairs = new AddRecordPointRepairs(addRecordTDS);
                    addRecordPointRepairs.Save(companyId, newId);
                }

                if (tdsToWork == "viewFullLengthLining")
                {
                    ViewFullLengthLiningLfsM2Tables viewFullLengthLiningLfsM2Tables = new ViewFullLengthLiningLfsM2Tables(viewFullLengthLiningTDS);
                    viewFullLengthLiningLfsM2Tables.Save(companyId, newId);
                }

                if (tdsToWork == "viewJLinersheet")
                {
                    ViewJLinersheetJunctionLiner viewJLinersheetJunctionLiner = new ViewJLinersheetJunctionLiner(viewJLinersheetTDS);
                    viewJLinersheetJunctionLiner.Save(companyId, newId);
                }
            }
        }
        protected void grdPointRepairs_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            Page.Validate("repairsEdit");
            if (Page.IsValid)
            {
                Guid id = new Guid(((Label)grdPointRepairs.Rows[e.RowIndex].Cells[0].FindControl("lblId")).Text.Trim());
                int refId = Int32.Parse(((Label)grdPointRepairs.Rows[e.RowIndex].Cells[1].FindControl("lblRefId")).Text.Trim());
                int companyId = Int32.Parse(((Label)grdPointRepairs.Rows[e.RowIndex].Cells[3].FindControl("lblCOMPANY_ID")).Text.Trim());

                string repairSize = ((TextBox)grdPointRepairs.Rows[e.RowIndex].Cells[6].FindControl("tbxRepairSizeEdit")).Text.Trim();
                DateTime? installDate = null; if (((RadDatePicker)grdPointRepairs.Rows[e.RowIndex].Cells[8].FindControl("tkrdpInstallDateEdit")).SelectedDate.HasValue) installDate = ((RadDatePicker)grdPointRepairs.Rows[e.RowIndex].Cells[8].FindControl("tkrdpInstallDateEdit")).SelectedDate.Value;
                string distance = ((TextBox)grdPointRepairs.Rows[e.RowIndex].Cells[5].FindControl("tbxDistanceEdit")).Text.Trim();
                decimal? cost = null; if (((TextBox)grdPointRepairs.Rows[e.RowIndex].Cells[9].FindControl("tbxCostEdit")).Text.Trim() != "") cost = Decimal.Parse(((TextBox)grdPointRepairs.Rows[e.RowIndex].Cells[9].FindControl("tbxCostEdit")).Text.Trim());
                int? reinstates = null; if (((TextBox)grdPointRepairs.Rows[e.RowIndex].Cells[7].FindControl("tbxReinstatesEdit")).Text.Trim() != "") reinstates = Int32.Parse(((TextBox)grdPointRepairs.Rows[e.RowIndex].Cells[7].FindControl("tbxReinstatesEdit")).Text.Trim());

                AddRecordPointRepairs model = new AddRecordPointRepairs(addRecordTDS);
                model.Update(id, refId, companyId, repairSize, installDate, distance, cost, reinstates);

                Session["addRecordTDS"] = addRecordTDS;
            }
            else
            {
                e.Cancel = true;
            }
        }
        protected void grdPointRepairs_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Edit) || (e.Row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate))))
            {
                // Initialize values
                Guid id = new Guid(((Label)e.Row.FindControl("lblId")).Text);
                int refId = Int32.Parse(((Label)e.Row.FindControl("lblRefId")).Text);
                int companyId = Int32.Parse(((Label)e.Row.FindControl("lblCOMPANY_ID")).Text);

                AddRecordPointRepairsGateway addRecordPointRepairsGateway = new AddRecordPointRepairsGateway(addRecordTDS);

                if (addRecordPointRepairsGateway.Table.Rows.Count > 0)
                {
                    if (addRecordPointRepairsGateway.GetInstallDate(id, refId, companyId).HasValue)
                    {
                        ((RadDatePicker)e.Row.FindControl("tkrdpInstallDateEdit")).SelectedDate = (DateTime)addRecordPointRepairsGateway.GetInstallDate(id, refId, companyId);
                    }
                }
            }

            if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Normal) || (e.Row.RowState == (DataControlRowState.Normal | DataControlRowState.Alternate))))
            {
                if (Convert.ToBoolean(Session["sgLFS_APP_EDIT"]))
                {
                    // Button Validation
                    e.Row.FindControl("ibtnEdit").Visible = true;
                    e.Row.FindControl("ibtnDelete").Visible = true;
                }
                else
                {
                    // Button validation
                    e.Row.FindControl("ibtnEdit").Visible = false;
                    e.Row.FindControl("ibtnDelete").Visible = false;
                }
            }

            if (e.Row.RowType == DataControlRowType.Footer)
            {
                if (Convert.ToBoolean(Session["sgLFS_APP_EDIT"]))
                {
                    // If the limit is reached
                    AddRecordPointRepairs addRecordPointRepairs = new AddRecordPointRepairs(addRecordTDS);
                    string newDetailId = addRecordPointRepairs.GetNewPointRepairsDetailId(addRecordTDS);

                    if (newDetailId == "-1")
                    {
                        ((RadDatePicker)e.Row.FindControl("tkrdpInstallDateFooter")).Visible = false;
                        ((TextBox)e.Row.FindControl("tbxRepairSizeFooter")).Visible = false;
                        ((TextBox)e.Row.FindControl("tbxDistanceFooter")).Visible = false;
                        ((TextBox)e.Row.FindControl("tbxCostFooter")).Visible = false;
                        ((TextBox)e.Row.FindControl("tbxReinstatesFooter")).Visible = false;
                        e.Row.FindControl("ibtnAdd").Visible = false;
                        lblMaxNumber.Visible = true;
                    }
                    else
                    {
                        ((RadDatePicker)e.Row.FindControl("tkrdpInstallDateFooter")).Visible = true;
                        ((TextBox)e.Row.FindControl("tbxRepairSizeFooter")).Visible = true;
                        ((TextBox)e.Row.FindControl("tbxDistanceFooter")).Visible = true;
                        ((TextBox)e.Row.FindControl("tbxCostFooter")).Visible = true;
                        ((TextBox)e.Row.FindControl("tbxReinstatesFooter")).Visible = true;
                        e.Row.FindControl("ibtnAdd").Visible = true;
                        lblMaxNumber.Visible = false;
                    }
                }
                else
                {
                    ((RadDatePicker)e.Row.FindControl("tkrdpInstallDateFooter")).Visible = false;
                    ((TextBox)e.Row.FindControl("tbxRepairSizeFooter")).Visible = false;
                    ((TextBox)e.Row.FindControl("tbxDistanceFooter")).Visible = false;
                    ((TextBox)e.Row.FindControl("tbxCostFooter")).Visible = false;
                    ((TextBox)e.Row.FindControl("tbxReinstatesFooter")).Visible = false;
                    e.Row.FindControl("ibtnAdd").Visible = false;
                    lblMaxNumber.Visible = false;
                }
            }
        }
예제 #8
0
        private void GrdPointRepairsAdd()
        {
            if (ValidateFooter())
            {
                Page.Validate("repairsFooter");
                if (Page.IsValid)
                {
                    Guid id = newId;
                    int companyId = Convert.ToInt32(Session["companyID"]);
                    string repairSize = ""; if (((TextBox)grdPointRepairs.FooterRow.FindControl("tbxRepairSizeFooter")).Text != "") repairSize = ((TextBox)grdPointRepairs.FooterRow.FindControl("tbxRepairSizeFooter")).Text;
                    DateTime? installDate = null; if (((RadDatePicker)grdPointRepairs.FooterRow.FindControl("tkrdpInstallDateFooter")).SelectedDate.HasValue) installDate = ((RadDatePicker)grdPointRepairs.FooterRow.FindControl("tkrdpInstallDateFooter")).SelectedDate.Value;
                    string distance = ""; if (((TextBox)grdPointRepairs.FooterRow.FindControl("tbxDistanceFooter")).Text != "") distance = ((TextBox)grdPointRepairs.FooterRow.FindControl("tbxDistanceFooter")).Text;
                    decimal? cost = null; if (((TextBox)grdPointRepairs.FooterRow.FindControl("tbxCostFooter")).Text != "") cost = Decimal.Parse(((TextBox)grdPointRepairs.FooterRow.FindControl("tbxCostFooter")).Text);
                    int? reinstates = null; if (((TextBox)grdPointRepairs.FooterRow.FindControl("tbxReinstatesFooter")).Text != "") reinstates = Int32.Parse(((TextBox)grdPointRepairs.FooterRow.FindControl("tbxReinstatesFooter")).Text);
                    string ltAtMh = "";
                    string vtAtMh = "";
                    string linerDistance = "";
                    string direction = "";
                    string mhShot = "";
                    string comments = "";
                    bool deleted = false;
                    bool extraRepair = false;
                    bool cancelled = false;
                    bool approved = false;
                    bool notApproved = false;
                    bool archived = false;
                    bool inDatabase = false;

                    AddRecordPointRepairs model = new AddRecordPointRepairs(addRecordTDS);
                    model.Insert(id, repairSize, installDate, distance, cost, reinstates, ltAtMh, vtAtMh, linerDistance, direction, mhShot, comments, deleted, extraRepair, cancelled, approved, notApproved, archived, companyId, addRecordTDS, inDatabase);

                    Session.Remove("pointRepairDummy");
                    Session["addRecordTDS"] = addRecordTDS;

                    grdPointRepairs.DataBind();
                    grdPointRepairs.PageIndex = grdPointRepairs.PageCount - 1;
                }
            }
        }