public XmlDocument AddTemplate(string UserID, string Password, string TemplateName, string HtmlContent) { XmlDocument doc = new XmlDocument(); StringBuilder str = new StringBuilder(); str.Append("<TemplateInfo>"); string Con = GetConnectionString(UserID, Password); if (TemplateName.Trim().Length != 0 && Con.Trim().Length != 0 && HtmlContent.Trim().Length != 0) { TemplateMaster templateMaster = new TemplateMaster(Con); templateMaster.TemplateName = TemplateName; TemplateMasters tempMasters = TemplateMaster.SelectByField("TemplateName", TemplateName, Con); if (tempMasters.Count > 0) { str.Append("<Message>Template Name Already Existed</Message>"); } else { if (HtmlContent != "" && TemplateName != "") { templateMaster.HTMLContent = HtmlContent; templateMaster.CreatedDate = DateTime.Now; templateMaster.Insert(); str.Append("<Message>Template Added Successfully</Message>"); str.Append("</TemplateInfo>"); doc.LoadXml(str.ToString()); } else { str.Append("<Message>Please Enter Valid Inputs</Message>"); } } } else { str.Append("<Message>Please Enter Valid Inputs</Message>"); } str.Append("</TemplateInfo>"); doc.LoadXml(str.ToString()); return doc; }
//This method is modified by swaraj on 27 jan 2010 public void Save() { try { bool status; TemplateMaster templateMaster = new TemplateMaster(ConnectionString); string templatename = txtTemplateName.Text.Trim(); templateMaster.TemplateName = templatename; // txtTemplateName.Text; templateMaster.TemplateDescription = txtDescription.Text; //templateMaster.HTMLContent = RadEditor1.Content;//hdHtmlContent.Value.ToString(); if (RadEditor1.Content.Contains(verify))//(RadEditor1.Content.Contains("[!RPLINK:")) { htmlContent = ExtractLinks(RadEditor1.Content.ToString()); templateMaster.HTMLContent = htmlContent; } else { templateMaster.HTMLContent = RadEditor1.Content; } if (textRadEditor.Content.Contains(verify)) { textContent = ExtractLinks(textRadEditor.Content.ToString()); templateMaster.TextContent = textContent; } else { templateMaster.TextContent = textRadEditor.Content; } lblMessage.Visible = true; TemplateMasters tempMasters = TemplateMaster.SelectByField("TemplateName", templatename, ConnectionString); //txtTemplateName.Text); if (templateID == 0) { if (tempMasters.Count > 0) { templateMaster.TemplateId = templateID; lblMessage.Visible = true; lblMessage.ForeColor = System.Drawing.Color.Red; lblMessage.Text = "Template Name: " + txtTemplateName.Text + " exists already."; stat = false; return; } else { templateMaster.CreatedDate = System.DateTime.Now; //templateMaster.ModifiedDate = System.DateTime.Now; status = templateMaster.Insert(); if (status == true) { lblMessage.ForeColor = System.Drawing.Color.Green; lblMessage.Text = "Template Name: " + txtTemplateName.Text + " has been Created Successfully"; stat = true; insert = true; } } } else { templateMaster.TemplateId = Convert.ToInt64(templateID);//tempMasters[0].TemplateId; if (tempMasters.Count > 0 && tempMasters[0].TemplateId != Convert.ToInt64(templateID)) { lblMessage.Visible = true; lblMessage.ForeColor = System.Drawing.Color.Red; lblMessage.Text = "Template Name: " + txtTemplateName.Text + " exists already please select another Name."; stat = false; } else { TemplateMasters template = TemplateMaster.SelectByField("TemplateId", templateID, ConnectionString); templateMaster.CreatedDate = template[0].CreatedDate; templateMaster.ModifiedDate = System.DateTime.Now; status = templateMaster.Update(); if (status == true) { lblMessage.ForeColor = System.Drawing.Color.Green; lblMessage.Text = "Template Name: " + txtTemplateName.Text + " Updated Successfully."; stat = true; insert = false; } } } } catch (Exception ex) { throw ex; } }