Beispiel #1
0
    protected void GrdLetter_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("Insert"))
        {
            DropDownList ddlLetterType       = (DropDownList)GrdLetter.FooterRow.FindControl("ddlNewLetterType");
            DropDownList ddlSite             = (DropDownList)GrdLetter.FooterRow.FindControl("ddlNewSite");
            TextBox      txtCode             = (TextBox)GrdLetter.FooterRow.FindControl("txtNewCode");
            TextBox      txtMessage          = (TextBox)GrdLetter.FooterRow.FindControl("txtNewMessage");
            TextBox      txtDocName          = (TextBox)GrdLetter.FooterRow.FindControl("txtNewDocName");
            CheckBox     chkIsSendToMedico   = (CheckBox)GrdLetter.FooterRow.FindControl("chkNewIsSendToMedico");
            CheckBox     chkIsAllowedReclaim = (CheckBox)GrdLetter.FooterRow.FindControl("chkNewIsAllowedReclaim");
            //CheckBox     chkIsManualOverride = (CheckBox)GrdLetter.FooterRow.FindControl("chkNewIsManualOverride");
            //DropDownList ddlNumCopiesToPrint = (DropDownList)GrdLetter.FooterRow.FindControl("ddlNewNumCopiesToPrint");

            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;
            }

            Organisation org     = IsValidFormOrgID() ? OrganisationDB.GetByID(GetFormOrgID()) : null;
            int          site_id = (GrdLetter.FooterRow.Cells[3].CssClass == "hiddencol") ? Convert.ToInt32(Session["SiteID"]) : Convert.ToInt32(ddlSite.SelectedValue);
            LetterDB.Insert((org == null) ? 0 : org.OrganisationID, Convert.ToInt32(ddlLetterType.SelectedValue), site_id, txtCode.Text, txtMessage.Text, txtDocName.Text.Trim(), chkIsSendToMedico.Checked, chkIsAllowedReclaim.Checked, false, 1, false);

            FillGrid();
        }
    }