예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string strSPContractorID = string.Empty;

                #region Dropdown Categories
                List <clsCategory> lstCategory = new List <clsCategory>();
                lstCategory = CategoryDAL.SelectDynamicCategory("(ACRDCategory = 'Contractor Accreditations') AND (IsActive = 1)", "ACRDCatID");
                if (lstCategory != null)
                {
                    if (lstCategory.Count > 0)
                    {
                        dropCategory.Items.Clear();
                        for (int i = 0; i < lstCategory.Count; i++)
                        {
                            dropCategory.Items.Add(new ListItem(
                                                       String.Format("{0}", SQLHelper.TrimAndReplaceEOF(lstCategory[i].CatTitle.ToString())), String.Format("{0}", SQLHelper.TrimAndReplaceEOF(lstCategory[i].ACRDCatID.ToString()))));
                        }
                    }
                }
                #endregion

                phWriteComment.Visible = false;

                strSPContractorID = Request["cgi"].ToString() == null ? string.Empty : Request["cgi"].ToString();
                if (GlobalMethods.ValueIsNull(strSPContractorID).Length > 0)
                {
                    strSPContractorID = objcryptoJS.AES_decrypt(HttpUtility.UrlEncode(Request["cgi"].ToString()), AppConstants.secretKey, AppConstants.initVec).ToString();
                }

                #region Getting all the Comments by Application Id.
                StringBuilder strMessenger = new StringBuilder("");
                List <clsContractor_Comment> lstComments = new List <clsContractor_Comment>();
                lstComments = Contractor_CommentDAL.SelectDynamicContractor_Comment("SPContractorID = " + strSPContractorID + "", "ContractorCommentId");
                if (lstComments != null)
                {
                    if (lstComments.Count > 0)
                    {
                        for (int i = 0; i < lstComments.Count; i++)
                        {
                            strMessenger.Append(GlobalMethods.Messenger(lstComments[i].CreatedBy.ToString(), Convert.ToDateTime(lstComments[i].CreatedDate).ToLongDateString(), lstComments[i].Comment.ToString()).ToString());
                        }
                    }
                }
                pnlComments.Controls.Add(new LiteralControl(strMessenger.ToString()));
                #endregion

                #region Checking if this is AssignedToMe Action
                bool IsAssignedToMe = false;
                List <clsContractor_Approval> lstContAppr = new List <clsContractor_Approval>();
                lstContAppr = Contractor_ApprovalDAL.SelectDynamicContractor_Approval("SPContractorID = " + strSPContractorID + "", "MDEContApprId");
                if (lstContAppr != null)
                {
                    if (lstContAppr.Count > 0)
                    {
                        IsAssignedToMe         = true;
                        phWriteComment.Visible = true;
                    }
                }
                #endregion



                var subject = _contractorRepository.Get(int.Parse(strSPContractorID));
                if (subject != null)
                {
                    var addresses = subject.ContractorAddresses;
                    var emplist   = subject.ContractorEmpList;
                    txtName.Text          = subject.SPName;
                    lblContractorApp.Text = subject.SPName;

                    if ((subject.ContactFirstName == null) && (subject.ContactLastName == null))
                    {
                        lblSignedBy.Text = subject.RepFirstName + " " + subject.RepLastName;
                    }
                    else
                    {
                        lblSignedBy.Text = subject.ContactFirstName + " " + subject.ContactLastName;
                    }
                    dropIsRenewal.SelectedValue = subject.IsRenewal.HasValue ? subject.IsRenewal.Value.ToString() : "0";
                    divIsRenewal.Visible        = subject.IsRenewal.Value == 1;
                    txtSDATNum.Text             = subject.SDATDepartmentId;
                    GlobalMethods.SDATVerify(txtSDATNum, subject.SDATDepartmentId);

                    txtEIN.Text = subject.SPTaxId;
                    GlobalMethods.TAXIDVerify(txtEIN, subject.SPTaxId);

                    txtMHICNumber.Text = subject.SPMHICNumber;
                    if (addresses.Count > 0)
                    {
                        var add1 = addresses.FirstOrDefault(x => x.AddressType == 1);
                        if (add1 != null)
                        {
                            txtAddress_1.Text = add1.Address_Line_1;
                            txtCity_1.Text    = add1.City;
                            txtState_1.Text   = add1.State;
                            txtZipCode_1.Text = add1.ZipCode;
                            if (add1.PublicListing.HasValue && add1.PublicListing.Value > 0)
                            {
                                dropPublicList.SelectedValue = add1.PublicListing.Value.ToString();
                            }
                        }

                        var add2 = addresses.FirstOrDefault(x => x.AddressType == 2);
                        if (add2 != null)
                        {
                            txtAddress_2.Text = add2.Address_Line_1;
                            txtCity_2.Text    = add2.City;
                            txtState_2.Text   = add2.State;
                            txtZipcode_2.Text = add2.ZipCode;
                            if (add2.PublicListing.HasValue && add2.PublicListing.Value > 0)
                            {
                                dropPublicList.SelectedValue = add2.PublicListing.Value.ToString();
                            }
                        }
                    }
                    divCatInspection.Visible  = subject.ACRDCatID == Category.Inspection;
                    divCatResidential.Visible = subject.ACRDCatID == Category.Residential;
                    divCatSteel.Visible       = subject.ACRDCatID == Category.Steel;
                    foreach (var each in emplist)
                    {
                        if (each.ACRDCatID == Category.Inspection)
                        {
                            showTable(pnlInspection, each);
                        }
                        if (each.ACRDCatID == Category.Residential)
                        {
                            showTable(pnlResidential, each);
                        }
                        if (each.ACRDCatID == Category.Steel)
                        {
                            showTable(pnlSteel, each);
                        }
                    }
                    txtPhone.Text = subject.SPPhone;
                    //txtFax.Text = objSPCont.;
                    txtEmailAddress.Text = subject.SPEmail;
                    txtACCID.Text        = subject.AccreditationID;
                    GlobalMethods.AccreditationNumVerify(txtACCID, subject.AccreditationID);

                    dropCategory.SelectedValue          = subject.ACRDCatID.HasValue ? subject.ACRDCatID.Value.ToString() : "";
                    lblCourseName.Text                  = dropCategory.SelectedItem.Text;
                    txtAccreditationExpirationDate.Text = subject.AccreditationExpirationDate.HasValue ? Convert.ToDateTime(subject.AccreditationExpirationDate.Value.ToString()).ToShortDateString() : "";
                    GlobalMethods.AccreditationExpireDateVerify(txtAccreditationExpirationDate, subject.AccreditationID, subject.AccreditationExpirationDate.HasValue ? Convert.ToDateTime(subject.AccreditationExpirationDate.Value.ToString()) : Convert.ToDateTime("1/1/1900"));

                    dropWaiverType.SelectedValue    = subject.Waiver.HasValue ? subject.Waiver.ToString() : "";
                    dropPublicListing.SelectedValue = subject.PublishOnMDEWebsite.HasValue ? subject.PublishOnMDEWebsite.ToString() : "";

                    txtContactFName.Text     = subject.ContactFirstName;
                    txtContactLName.Text     = subject.ContactLastName;
                    txtAuthRepContFName.Text = subject.RepFirstName;
                    txtAuthRepContLName.Text = subject.RepLastName;
                    lblContactInfo.Text      = subject.RepFirstName + " " + subject.RepLastName + " - " + subject.SPPhone + " - " + subject.SPEmail;
                    lblDateSigned.Text       = Convert.ToDateTime(subject.CreatedDate).ToShortDateString();

                    txtAuthRepContTitle.Text = subject.RepTitle;
                    chkIAgree.Checked        = subject.Agreed.HasValue ? subject.Agreed.Value == 1 : false;

                    string strEnContractId = objcryptoJS.AES_encrypt(HttpUtility.UrlEncode(subject.Id.ToString()), AppConstants.secretKey, AppConstants.initVec).ToString();
                    if (!IsAssignedToMe)
                    {
                        GlobalMethods.DisableControls(this.Page);
                        btnAddCourse.Visible = false;
                        pnlAppStatus.Controls.Add(new LiteralControl("<div class='input-group'><div class='input-group-btn'><a class='btn btn-primary2 open-AssignedToMe' href='#' data-id='" + strEnContractId + "' data-toggle='modal' >Assigned to Me</a>" + GlobalMethods.ContractorAppStatus(subject.IsActive.HasValue ? subject.IsActive.Value : 0, "bar", "") + "</div>"));
                    }
                    else
                    {
                        pnlAppStatus.Controls.Add(new LiteralControl("<div class='input-group'><div class='input-group-btn'><a class='btn btn-success open-Approve' title='Approve Application' href='#' data-id='" + strEnContractId + "' data-toggle='modal' >Approve</a>&nbsp;<a class='btn btn-danger open-Disapprove' href='#' title='Reject Application' data-id='" + strEnContractId + "' data-toggle='modal' >Reject</a>&nbsp;<a class='btn btn-primary open-Hold' href='#' title='Put Application On Hold' data-id='" + strEnContractId + "' data-toggle='modal' >On Hold</a>&nbsp;<a class='btn btn-primary open-Deficient' href='#' title='Application status is Deficient' data-id='" + strEnContractId + "' data-toggle='modal' >Deficient</a>" + GlobalMethods.ContractorAppStatus(subject.IsActive.HasValue ? subject.IsActive.Value : 0, "bar", "") + "</div>"));
                        phWriteComment.Visible = true;
                    }
                    foreach (var each in subject.ContractorRegions)
                    {
                        GenerateRadio(pnlRegions, each.Region.RegionName);
                    }

                    var i          = 0;
                    var strContent = new StringBuilder();

                    foreach (var each in subject.ContractorServices)
                    {
                        if (i % 4 == 0)
                        {
                            strContent.Append("<div class='row'>");
                            GenerateCheckBox(pnlServiceOffered, each.ServiceOffer.ServiceOffered);
                            if (i == 4)
                            {
                                strContent.Append("</div>");
                            }
                        }
                        else
                        {
                            GenerateCheckBox(pnlServiceOffered, each.ServiceOffer.ServiceOffered);
                        }
                        i++;
                    }
                    if (subject.ContractorServices.Count > 0)
                    {
                        strContent.Append("</div>");
                        pnlServiceOffered.Controls.Add(new LiteralControl(strContent.ToString()));
                    }

                    #region Getting all the Case files.
                    StringBuilder strMessengerUpload = new StringBuilder("");

                    foreach (var each in subject.ContractorFiles.OrderByDescending(x => x.Id))
                    {
                        strMessengerUpload.Append(GlobalMethods.UploadedFiles(each.CreatedBy.ToString(), Convert.ToDateTime(each.CreatedDate).ToLongDateString(), each.FileLocation.ToString()).ToString());
                    }
                    pnlUploads.Controls.Add(new LiteralControl(strMessengerUpload.ToString()));
                    #endregion
                }

                #region Making all the fields disabled.
                //GlobalMethods.EnableControl_TextBoxByID(txtComment);
                GlobalMethods.DisableControl_CheckBoxByID(chkIAgree);
                GlobalMethods.DisableControl_DropDownByID(dropCategory);
                GlobalMethods.DisableControl_DropDownByID(dropIsRenewal);
                GlobalMethods.DisableControl_DropDownByID(dropPublicList);
                GlobalMethods.DisableControl_DropDownByID(dropPublicListing);
                GlobalMethods.DisableControl_DropDownByID(dropWaiverType);
                #endregion
            }
        }