예제 #1
0
    protected void GrdLetter_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        Label lblId = (Label)GrdLetter.Rows[e.RowIndex].FindControl("lblId");

        DropDownList ddlLetterType       = (DropDownList)GrdLetter.Rows[e.RowIndex].FindControl("ddlLetterType");
        DropDownList ddlSite             = (DropDownList)GrdLetter.Rows[e.RowIndex].FindControl("ddlSite");
        TextBox      txtCode             = (TextBox)GrdLetter.Rows[e.RowIndex].FindControl("txtCode");
        TextBox      txtMessage          = (TextBox)GrdLetter.Rows[e.RowIndex].FindControl("txtMessage");
        TextBox      txtDocName          = (TextBox)GrdLetter.Rows[e.RowIndex].FindControl("txtDocName");
        CheckBox     chkIsSendToMedico   = (CheckBox)GrdLetter.Rows[e.RowIndex].FindControl("chkIsSendToMedico");
        CheckBox     chkIsAllowedReclaim = (CheckBox)GrdLetter.Rows[e.RowIndex].FindControl("chkIsAllowedReclaim");

        //CheckBox     chkIsManualOverride = (CheckBox)GrdLetter.Rows[e.RowIndex].FindControl("chkIsManualOverride");
        //DropDownList ddlNumCopiesToPrint = (DropDownList)GrdLetter.Rows[e.RowIndex].FindControl("ddlNumCopiesToPrint");

        txtDocName.Text = txtDocName.Text.Trim();
        if (txtDocName.Text.Length > 0 &&
            (!txtDocName.Text.EndsWith(".docx") &&
             !txtDocName.Text.EndsWith(".doc") &&
             !txtDocName.Text.EndsWith(".dot")))
        {
            SetErrorMessage("Only .docx, .doc, and .dot files allowed");
            return;
        }


        if (txtCode.Text.Length == 0 &&
            (Convert.ToInt32(ddlLetterType.SelectedValue) == 235 ||  // dva reject letter
             Convert.ToInt32(ddlLetterType.SelectedValue) == 234 ||  // medicare reject letter
             Convert.ToInt32(ddlLetterType.SelectedValue) == 214 ||  // organisation reject letter
             Convert.ToInt32(ddlLetterType.SelectedValue) == 3))     // patient reject letter
        {
            SetErrorMessage("Reject Code can not be empty for letters of type " + ddlLetterType.SelectedItem.Text);
            return;
        }

        int       letter_id = Convert.ToInt32(lblId.Text);
        DataTable dt        = Session["letter_data"] as DataTable;

        DataRow[] foundRows = dt.Select("letter_letter_id=" + letter_id.ToString());
        Letter    letter    = LetterDB.LoadAll(foundRows[0]);

        int orgID   = letter.Organisation == null ? 0 : letter.Organisation.OrganisationID;
        int site_id = (GrdLetter.Rows[e.RowIndex].Cells[3].CssClass == "hiddencol") ? letter.Site.SiteID : Convert.ToInt32(ddlSite.SelectedValue);

        LetterDB.Update(letter_id, orgID, Convert.ToInt32(ddlLetterType.SelectedValue), site_id, txtCode.Text, txtMessage.Text, txtDocName.Text.Trim(), chkIsSendToMedico.Checked, chkIsAllowedReclaim.Checked, false, 1, letter.IsDeleted);

        GrdLetter.EditIndex = -1;
        FillGrid();
    }