Esempio n. 1
0
 public Templats GetTemplate()
 {
     try
     {
         SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["CRMContext"].ConnectionString);
         con.Open();
         Templats   template = null;
         SqlCommand cmd      = new SqlCommand("spGetTemplate", con);
         cmd.CommandType = CommandType.StoredProcedure;
         SqlDataReader dr = cmd.ExecuteReader();
         if (dr.Read())
         {
             template          = new Templats();
             template.Name     = Convert.ToString(dr["Name"]);
             template.Template = Convert.ToString(dr["Template"]);
         }
         return(template);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 2
0
        public ActionResult Create(TicketCreateModel T)
        {
            Ticket            ticket            = new Ticket();
            TicketCreateModel ticketcreateModel = new TicketCreateModel();

            try
            {
                ticket.TicketNo     = T.TicketNo;
                ticket.Description  = T.Description;
                ticket.Title        = T.Title;
                ticket.VersionId    = T.VersionId;
                ticket.ProductId    = T.ProductId;
                ticket.CompanyId    = T.CompanyId;
                ticket.ComponentId  = T.ComponentId;
                ticket.SeviorityId  = T.SeviorityId;
                ticket.PriorityId   = T.PriorityId;
                ticket.TicketTypeId = T.TicketTypeId;
                ticket.CompanyId    = Convert.ToInt32(Session["CompanyId"]);
                ticket.CreatedBy    = Convert.ToInt64(Session["UID"]);
                TicketBiz  ticketbiz  = new TicketBiz();
                ProductBiz productbiz = new ProductBiz();
                ticketcreateModel.Products    = productbiz.GetProducts(Convert.ToInt64(Session["CompanyId"]));
                ticketcreateModel.Priorities  = ticketbiz.GetPriorities();
                ticketcreateModel.Seviorities = ticketbiz.GetSeviorities();
                ticketcreateModel.TicketTypes = ticketbiz.GetTicketTypes();
                int i = ticketbiz.AddTicket(ticket);
                if (i > 0)
                {
                    ViewBag.Message = "Ticket Successfully Insereted";
                    Templats  template = new Templats();
                    TicketBiz ticketbz = new TicketBiz();
                    ticketbiz.GetTicketNo();
                    ticketbiz.getTemplate();
                    MailMessage email = new MailMessage();
                    // Sender e-mail address.
                    email.From = new MailAddress("*****@*****.**");
                    // Recipient e-mail address.
                    email.To.Add("*****@*****.**");
                    email.Subject = "TicketCreated";
                    email.Body    = "Hi";
                    //  remote SMTP server IP.
                    SmtpClient smtp = new SmtpClient();
                    smtp.Host        = "smtp.1and1.com";
                    smtp.Port        = 587;
                    smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "welcomewelcome");

                    try
                    {
                        smtp.Send(email);
                        email = null;
                        //ClientScript.RegisterStartupScript(GetType(), "alert", "<script>alert('Mail Sent Successfully...!')</script>");
                    }
                    catch (Exception ex)
                    {
                        Exception ex2          = ex;
                        string    errorMessage = string.Empty;
                        while (ex2 != null)
                        {
                            errorMessage += ex2.ToString();
                            ex2           = ex2.InnerException;
                        }
                        //ClientScript.RegisterStartupScript(GetType(), "alert", "<script>alert('Failure To Send Mail...')</script>");
                    }
                }
                else
                {
                    ViewBag.ErrorMessage = " Inseret Failed";
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("IT", ex.Message);
            }
            return(View(ticketcreateModel));
        }