public ActionResult ProjectEventPaymentGenerator(int RepperID, int BudgetID)
        {
            if (RepperID > 0 && BudgetID > 0)
            {
                ReportPeriodListR repper = GetRepper(RepperID, BudgetID);

                ProjectEventService pes = new ProjectEventService();
                ProjectEvent        o   = new ProjectEvent();
                o.CompletedDate    = repper.PaymentDate;
                o.EventDescription = "Payment Request";
                o.ProjectID        = BudgetID;
                //o.EventType = GetPaymentEventType();
                o.EventTypeID    = GetPaymentEventType().EventTypeID;
                o.ReportPeriodID = RepperID;
                o.SSPOrGrantee   = true;
                o.EventStatus    = 0;
                pes.Insert(o);

                EventTemplate   eh = new EventTemplate();
                TemplateService ts = new TemplateService();

                TemplateDocument td1 = null;
                td1 = ts.GetTemplateDocument("Запрос на Оплату");
                if (td1 != null)
                {
                    eh.CreateFromTemplate(td1.TemplateDocsID, BudgetID, o.EventID, RepperID);
                }
            }

            return(RedirectToAction("Reppers", new { id = BudgetID }));
        }
        public ActionResult ProjectEventAcceptanceMemoGenerator(int RepperID, int BudgetID)
        {
            if (RepperID > 0 && BudgetID > 0)
            {
                ReportPeriodListR repper = GetRepper(RepperID, BudgetID);

                //Create Event.
                ProjectEventService pes = new ProjectEventService();
                ProjectEvent        o   = new ProjectEvent();
                o.CompletedDate    = repper.PaymentDate;
                o.EventDescription = "Letter to Grantee";
                o.ProjectID        = BudgetID;
                //o.EventType = GetPaymentEventType();
                o.EventTypeID    = GetPaymentEventType().EventTypeID;
                o.ReportPeriodID = RepperID;
                o.SSPOrGrantee   = true;
                o.EventStatus    = 0;

                pes.Insert(o);

                EventTemplate   eh = new EventTemplate();
                TemplateService ts = new TemplateService();

                //Generate Document.
                TemplateDocument td1 = null;
                td1 = ts.GetTemplateDocument("письмо о принятии отчета");
                if (td1 != null)
                {
                    eh.CreateFromTemplate(td1.TemplateDocsID, BudgetID, o.EventID, RepperID);
                }
            }

            return(RedirectToAction("Index", "Events", null));

            // return RedirectToAction("Reppers", new { id = BudgetID });
        }
        public ActionResult SelectTemplate(int TemplateDocsID, int ProjectID, int EventID, int?ReportPeriodID)
        {
            if (Session["ProposalID"] == null)
            {
                return(RedirectToAction("Search", "ProposalInfo"));
            }

            /*
             * TemplateService ts = new TemplateService();
             * string dir = ConfigurationManager.AppSettings["PhysicalPath"];
             * string WordDoc = ts.GenerateDocumentFromTemplateName(TemplateDocsID, EventID, ProjectID, dir, ReportPeriodID);
             *
             * TemplateFile tfile = ts.GetTemplateDocument(TemplateDocsID).TemplateFile;
             *
             * string virtdir = "files/A" + DateTime.Now.Year.ToString().Substring(2) + ProjectID.ToString()+"/";
             * dir += virtdir.Replace("/", "\\");
             *
             * if (!(Directory.Exists(dir)))
             * {
             *  Directory.CreateDirectory(dir);
             * }
             * string fileformat=EventID.ToString()+"_"+ProjectID.ToString()+"_";
             * int i;
             * for (i = 1; System.IO.File.Exists(dir+fileformat+i.ToString()+"."+tfile.fileextension); i++)
             * {
             * }
             * System.IO.File.WriteAllText(dir + fileformat + i.ToString() + "." + tfile.fileextension, WordDoc);
             * ProjectEventDocument docItem = new ProjectEventDocument();
             * docItem.Author = session.CurrentUser.FirstName + " " + session.CurrentUser.LastName + " " + session.CurrentUser.MiddleName;;
             * docItem.CreatedDate = DateTime.Now;
             * docItem.fileextension = tfile.fileextension;
             * docItem.FileName = fileformat + i.ToString() + "." + tfile.fileextension;
             * docItem.PhysicalAbsolutePath = dir + fileformat + i.ToString() + "." + tfile.fileextension;
             * docItem.PhysicalVirtualPath = "\\" + virtdir.Replace("/", "\\") + fileformat + i.ToString() + "." + tfile.fileextension;
             * docItem.UpdatedDate = docItem.CreatedDate;
             * docItem.WebVirtualPath = "/" + virtdir + fileformat + i.ToString() + "." + tfile.fileextension;
             * //docItem.
             * ProjectEventService pes = new ProjectEventService();
             * pes.InsertDocument(docItem, EventID);
             *
             *
             * TemplateDocument tdoc=ts.GetTemplateDocument(TemplateDocsID);
             * if (tdoc!=null)
             * {
             *  ProjectService projservice = new ProjectService();
             *
             *  //acknowledgement letter - completed project
             *  if (tdoc.TemplateDocName.ToLower().Contains("letter") && tdoc.TemplateDocName.ToLower().Contains("acknowledgement"))
             *  {
             *      AppDropDownsService apservice=new AppDropDownsService();
             *      ProposalStatusList psitem=apservice.ProposalStatusListGetItem("Completed");
             *
             *      //if we have needed status in DB then
             *      if (psitem != null)
             *      {
             *          Project _project = projservice.GetProposalInfo(ProjectID);
             *          ProposalStatus _prop = _project.ProposalStatus;
             *          _prop.PropStatusID = psitem.ProposalStatusID;
             *          projservice.ProposalStatusUpdate(_prop);
             *      }
             *
             *  }
             *
             *  //award letter - Active project
             *  if (tdoc.TemplateDocName.ToLower().Contains("letter") && tdoc.TemplateDocName.ToLower().Contains("award"))
             *  {
             *      AppDropDownsService apservice = new AppDropDownsService();
             *      ProposalStatusList psitem = apservice.ProposalStatusListGetItem("Active");
             *
             *      //if we have needed status in DB then
             *      if (psitem != null)
             *      {
             *          Project _project = projservice.GetProposalInfo(ProjectID);
             *          ProposalStatus _prop = _project.ProposalStatus;
             *          _prop.PropStatusID = psitem.ProposalStatusID;
             *          projservice.ProposalStatusUpdate(_prop);
             *      }
             *
             *  }
             *
             *  //close out letter - Closed project
             *  if (tdoc.TemplateDocName.ToLower().Contains("letter") && tdoc.TemplateDocName.ToLower().Contains("close") && tdoc.TemplateDocName.ToLower().Contains("out"))
             *  {
             *      AppDropDownsService apservice = new AppDropDownsService();
             *      ProposalStatusList psitem = apservice.ProposalStatusListGetItem("Closed");
             *
             *      //if we have needed status in DB then
             *      if (psitem != null)
             *      {
             *          Project _project = projservice.GetProposalInfo(ProjectID);
             *          ProposalStatus _prop = _project.ProposalStatus;
             *          _prop.PropStatusID = psitem.ProposalStatusID;
             *          projservice.ProposalStatusUpdate(_prop);
             *      }
             *
             *  }
             *
             *  //suspended letter - Active project
             *  if (tdoc.TemplateDocName.ToLower().Contains("letter") && tdoc.TemplateDocName.ToLower().Contains("suspended"))
             *  {
             *      AppDropDownsService apservice = new AppDropDownsService();
             *      ProposalStatusList psitem = apservice.ProposalStatusListGetItem("Suspended");
             *
             *      //if we have needed status in DB then
             *      if (psitem != null)
             *      {
             *          Project _project = projservice.GetProposalInfo(ProjectID);
             *          ProposalStatus _prop = _project.ProposalStatus;
             *          _prop.PropStatusID = psitem.ProposalStatusID;
             *          projservice.ProposalStatusUpdate(_prop);
             *      }
             *
             *  }
             *
             *  //reject letter - Rejected project
             *  if (tdoc.TemplateDocName.ToLower().Contains("letter") && tdoc.TemplateDocName.ToLower().Contains("reject"))
             *  {
             *      AppDropDownsService apservice = new AppDropDownsService();
             *      ProposalStatusList psitem = apservice.ProposalStatusListGetItem("Rejected");
             *
             *      //if we have needed status in DB then
             *      if (psitem != null)
             *      {
             *          Project _project = projservice.GetProposalInfo(ProjectID);
             *          ProposalStatus _prop = _project.ProposalStatus;
             *          _prop.PropStatusID = psitem.ProposalStatusID;
             *          projservice.ProposalStatusUpdate(_prop);
             *      }
             *
             *  }
             *
             *
             * }*/
            EventTemplate ehelper = new EventTemplate();

            ehelper.CreateFromTemplate(TemplateDocsID, ProjectID, EventID, ReportPeriodID);

            return(RedirectToAction("Index", new { id = EventID }));
        }