Ejemplo n.º 1
0
    protected void WzInspectionUpd_FinishButtonClick(object sender, WizardNavigationEventArgs e)
    {
        if (fldSelectedKey.Value != "")
        {
            Guid InspectionId = new Guid(fldSelectedKey.Value);

            Inspection objInspection = new Inspection();

            InspectionDetailsRow InspectionDetails = Inspection.GetInspectionDetailsRow();
            InspectionDetails.InspectionTypeId = new Guid(ddlInspectionTypeIdUpd.SelectedValue);
            InspectionDetails.InspectingOfficerId = new Guid(ddlInspectingOfficerIdUpd.SelectedValue);
            InspectionDetails.InspectorOfficeName = txtInspectorOfficeNameUpd.Text;
            InspectionDetails.InspectedOfficeId = new Guid(ddlInspectedOfficeIdUpd.SelectedValue);
            InspectionDetails.LicenseId = new Guid(ddlLicenseIdUpd.SelectedValue);
            InspectionDetails.IsDiscrepancyFound = IsdescripancyFoundUpd.Checked;
            InspectionDetails.Remarks = txtInspectionRemarksUpd.Text;

            Wizard Container = (Wizard) Master.FindControl("Main").FindControl("WzInspectionUpd");
            List<CheckListInspectionRow> CheckListRows = new List<CheckListInspectionRow>();

            string filename = Server.MapPath("~\\Inspection\\InspectionCheckList.xml");
            XmlDocument InspectionCheckListXml = new XmlDocument();
            InspectionCheckListXml.Load(filename);

            foreach (XmlNode Node in InspectionCheckListXml.SelectNodes("DocumentElement/Items"))
            {
                CheckListInspectionRow CheckListRow = Inspection.GetCheckListRow();
                TextBox txtRemarks = (TextBox) Container.FindControl("txt" + Node.Attributes["ItemId"].Value);
                CheckBox chkYesNo = (CheckBox) Container.FindControl("chk" + Node.Attributes["ItemId"].Value);

                CheckListRow.InspectionCheckListId = new Guid(Node.Attributes["ItemId"].Value);

                if (null != txtRemarks)
                    CheckListRow.Remarks = txtRemarks.Text;
                else
                    CheckListRow.SetRemarksNull();

                if (null != chkYesNo)
                    CheckListRow.Checked = chkYesNo.Checked;
                else
                    CheckListRow.Checked = false;

                CheckListRows.Add(CheckListRow);
            }

            DataTable InspectionQueries = (DataTable) ViewState["InspectionQueryListDetails"];

            objInspection.UpdateInspection(InspectionDetails, CheckListRows, InspectionQueries, InspectionId);

        }
    }