Esempio n. 1
0
    /// <summary>
    /// Call every time when user click on Save Details button.
    /// Update provider information in database
    /// </summary>
    /// <param name="sender">sender object</param>
    /// <param name="e">EventArgs</param>
    protected void btnSaveDetails_Click(object sender, EventArgs e)
    {
        if (Password.Text == PasswordConfirm.Text)
        {
            HidPass.Value = Password.Text;
        }
        //create Provider Data Access object
        ApprovedProviderDataAccess providerDA = new ApprovedProviderDataAccess();

        //Check for existence for Email address
        ApprovedProvider oProvider = providerDA.GetApprovedProviderByEmail(ApplicantEmail.Text);

        //provider in session
        ApprovedProvider sessionProvider = null;

        //now check weather it is in edit provider mode
        if (Session[LACESConstant.SessionKeys.LOGEDIN_APPROVED_PROVIDER] != null)
        {
            //get the provider from session
            sessionProvider = (ApprovedProvider)Session[LACESConstant.SessionKeys.LOGEDIN_APPROVED_PROVIDER]; // Get provider information from Session

            //provider changed email and that is set for other provider
            if (oProvider != null && oProvider.ID != sessionProvider.ID)
            {
                //The email is already used, so not allowed
                lblMsg.Text      = "Email already exists. Please provide another email.<br /><br />";
                lblMsg.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                sessionProvider = FIllApprovedProviderObjectByFormValues(sessionProvider);

                //update provider contact info
                ApprovedProvider currentProvider = providerDA.UpdateApprovedProvider(sessionProvider);

                if (currentProvider == null)
                {
                    //exception occured
                    lblMsg.Text      = "Contact information information cannot be saved.<br /><br />";
                    lblMsg.ForeColor = System.Drawing.Color.Red;
                }
                else
                {
                    //update the current provider information in the session
                    Session[LACESConstant.SessionKeys.LOGEDIN_APPROVED_PROVIDER] = currentProvider;

                    //data saved successfully
                    lblMsg.Text      = "Contact information updated successfully.<br /><br />";
                    lblMsg.ForeColor = System.Drawing.Color.Green;
                }
            }
        }
    }
Esempio n. 2
0
    /// <summary>
    /// Update provider info
    /// </summary>
    private void SaveProvider()
    {
        try
        {
            //get id from query string
            if (Request.QueryString[LACESConstant.QueryString.PROVIDER_ID] != null)
            {
                int providerID = 0;

                int.TryParse(Request.QueryString[LACESConstant.QueryString.PROVIDER_ID].ToString(), out providerID);

                if (providerID > 0)
                {
                    ApprovedProviderDataAccess providerDA      = new ApprovedProviderDataAccess();
                    ApprovedProvider           currentProvider = providerDA.GetApprovedProviderByID(providerID); // Get provider by id


                    //if provider exists
                    if (currentProvider != null)
                    {
                        //if currently provider status is pending or inactive and admin manually
                        //activates him/her, his/her NextRenewalDate will be set to 1 yr later from today
                        if (currentProvider.Status != LACESConstant.ProviderStatus.ACTIVE &&
                            pvStatus.SelectedValue == LACESConstant.ProviderStatus.ACTIVE)
                        {
                            currentProvider.NextRenewalDate = DateTime.Now.AddYears(1);
                        }
                        if (uiLblNextRenewalDate.Text.Length > 0)
                        {
                            DateTime dtNextRen;
                            if (DateTime.TryParse(uiLblNextRenewalDate.Text, out dtNextRen))
                            {
                                currentProvider.NextRenewalDate = dtNextRen;
                            }
                        }
                        currentProvider.Status = pvStatus.SelectedValue;

                        if (ApprovalDate.Text != "")
                        {
                            currentProvider.ApprovalDate = Convert.ToDateTime(ApprovalDate.Text);
                        }

                        if (DeferralDate.Text != "")
                        {
                            currentProvider.DeferralDate = Convert.ToDateTime(DeferralDate.Text);
                        }

                        //if (DenialDate.Text != "")
                        //    currentProvider.DenialDate = Convert.ToDateTime(DenialDate.Text);
                        if (uiTxtApplicationReceiveDate.Text != "")
                        {
                            currentProvider.ApplicationReceivedDate = Convert.ToDateTime(uiTxtApplicationReceiveDate.Text);
                        }
                        if (uiTxtCommitteeReviewDate.Text != "")
                        {
                            currentProvider.CommiteeApprovedDate = Convert.ToDateTime(uiTxtCommitteeReviewDate.Text);
                        }
                        if (uiTxtRenewalDate.Text != "")
                        {
                            currentProvider.RenewalDate = Convert.ToDateTime(uiTxtRenewalDate.Text);
                        }
                        if (uiTxtPayment.Text != "")
                        {
                            currentProvider.Payment = uiTxtPayment.Text;
                        }
                        if (uiTxtYearMonitored.Text != "")
                        {
                            currentProvider.YearMonitored = uiTxtYearMonitored.Text;
                        }
                        if (uiTxtNotes.Text != "")
                        {
                            currentProvider.Notes = uiTxtNotes.Text;
                        }
                        // if (ExpirationDate.Text != "")
                        //     currentProvider.ExpirationDate = Convert.ToDateTime(ExpirationDate.Text);

                        if (WithdrawalDate.Text != "")
                        {
                            currentProvider.WithdrawalDate = Convert.ToDateTime(WithdrawalDate.Text);
                        }

                        currentProvider.isPaymentExempt = uiChkIsPaymentExempt.Checked;

                        if (providerDA.UpdateApprovedProvider(currentProvider) != null)
                        {
                            Response.Redirect("../Admin/ProviderUpdatedSuccessfully.aspx?Status=" + currentProvider.Status, true);
                        }
                        else
                        {
                            lblMsg.Text      = "Provider information cannot be updated.";
                            lblMsg.ForeColor = System.Drawing.Color.Red;
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
            Response.End();
        }
    }