protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string notes = txtHidData.Value.ToString();
                catalogueNotesBL = new CatalogueNotesBL();
                catalogueNotesBL.SaveCatalogueNotes(catNo, notes, Convert.ToString(Session["UserCode"]), out errorId);
                catalogueNotesBL = null;

                if (errorId == 2)
                {
                    ExceptionHandler("Error in saving notes", string.Empty);
                }
                else
                {
                    msgView.SetMessage("Catalogue notes saved successfully", MessageType.Warning, PositionType.Auto);
                }

                hdnIsDataChanged.Value = "N";
            }
            catch (Exception ex)
            {
                ExceptionHandler("Error in saving notes", ex.Message);
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                catNo          = Convert.ToString(Session["CatalogueNo"]);
                hdnCatNo.Value = string.Empty;
                ScriptManager.RegisterStartupScript(this, typeof(Page), "SetTxtNotesHeight", "SetTxtNotesHeight();", true);

                catalogueNotesBL = new CatalogueNotesBL();
                DataSet notesData = catalogueNotesBL.GetCatalogueNotes(catNo, out errorId);
                catalogueNotesBL = null;

                if (errorId != 2)
                {
                    //populate royaltor text field in parent page
                    hdnCatNo.Value = catNo;
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "PopulateCatNo", "iFramePopulateCatNo();", true);

                    if (notesData.Tables[0].Rows.Count != 0)
                    {
                        string notes = Convert.ToString(notesData.Tables[0].Rows[0][0]);
                        //old data which was saved using Power Builder was in Rich Text format(RTF)
                        //check if notes is in rich text format and extract only the text if so
                        if (notes != string.Empty && (notes.StartsWith("{\rtf1") || notes.StartsWith("{\\rtf1")))
                        {
                            System.Windows.Forms.RichTextBox rtBox = new System.Windows.Forms.RichTextBox();
                            rtBox.Rtf = Convert.ToString(notesData.Tables[0].Rows[0][0]);

                            //rtf new line does not work in HTML. replacing new line with HTML break
                            txtNotes.Text = rtBox.Text.Replace("\n", "<br>");
                        }
                        else
                        {
                            txtNotes.Text = notes;
                        }
                    }
                    else
                    {
                        txtNotes.Text = string.Empty;
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler("Error in loading Catalogue notes", ex.Message);
            }
        }