Ejemplo n.º 1
0
        public ActionResult CreateNewProgress(FollowupProgressModel model)
        {
            PrePurchase_FollowUp_Plan plan = new PrePurchase_FollowUp_Plan();

            plan.Description = model.Desription;
            plan.name        = model.Name;
            plan.isActive    = true;
            plan.isOperation = false;
            plan.productID   = model.productID;

            plan.createDate = DateTime.Today;

            SSMEntities se = new SSMEntities();

            se.PrePurchase_FollowUp_Plan.Add(plan);
            se.SaveChanges();

            foreach (Plan_Step step in model.steps.ToList())
            {
                if (step.StepEmailContent == null)
                {
                    model.steps.Remove(step);
                }
                else if (step.StepEmailContent.Trim().Length == 0)
                {
                    model.steps.Remove(step);
                }
            }
            for (int i = 0; i < model.steps.Count(); i++)
            {
                Plan_Step step = model.steps[i];
                step.stepNo = (i + 1);
                step.planID = plan.id;
                se.Plan_Step.Add(step);
                se.SaveChanges();
            }
            for (int i = 0; i < model.steps.Count(); i++)
            {
                Plan_Step step = model.steps[i];
                if (i != 0)
                {
                    step.previousStep = model.steps[i - 1].id;
                }
                if (i != model.steps.Count() - 1)
                {
                    step.nextStep = model.steps[i + 1].id;
                }
                se.SaveChanges();
            }

            return(RedirectToAction("Detail", new { id = model.productID }));
        }
Ejemplo n.º 2
0
        public ActionResult EditPlan(int planID)
        {
            SSMEntities se = new SSMEntities();

            ViewData["MailCate"] = se.EMAIL_Category.ToList();
            PrePurchase_FollowUp_Plan preplan = se.PrePurchase_FollowUp_Plan.Find(planID);

            ViewData["planID"]  = preplan.id;
            ViewData["plan"]    = preplan;
            ViewData["Product"] = preplan.softwareProduct.id;
            ViewData["steps"]   = preplan.Plan_Step.ToList();
            preplan.productID   = planID;
            // return View("EditFollowUpPlan");
            return(View("FollowUpProgressEditor", new FollowupProgressModel(preplan)));
        }
Ejemplo n.º 3
0
        public ActionResult SetInactive(int planid, int productID)
        {
            try
            {
                SSMEntities se = new SSMEntities();
                PrePurchase_FollowUp_Plan plan = se.PrePurchase_FollowUp_Plan.Find(planid);
                plan.isActive = false;
                se.SaveChanges();
                System.Diagnostics.Debug.WriteLine("cccccccc " + productID);
                return(RedirectToAction("Detail", new { id = productID }));
            }
            catch (Exception e)
            {
            }

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 4
0
 public JsonResult PrePlanSwitchStatus(int id)
 {
     try
     {
         SSMEntities se = new SSMEntities();
         PrePurchase_FollowUp_Plan myplan   = se.PrePurchase_FollowUp_Plan.Find(id);
         softwareProduct           software = myplan.softwareProduct;
         foreach (PrePurchase_FollowUp_Plan plan in software.PrePurchase_FollowUp_Plan.ToList())
         {
             if (plan.id != id)
             {
                 plan.isOperation = false;
             }
         }
         myplan.isOperation = !myplan.isOperation;
         se.SaveChanges();
         return(Json(new { result = "succeed" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception e)
     {
     }
     return(Json(new { result = "fail" }, JsonRequestBehavior.AllowGet));
 }
Ejemplo n.º 5
0
        public FollowupProgressModel(PrePurchase_FollowUp_Plan plan)
        {
            this.Name       = plan.name;
            this.id         = plan.id;
            this.Desription = plan.Description;

            this.productID = plan.productID;
            steps          = new List <Plan_Step>();
            foreach (Plan_Step step in plan.Plan_Step)
            {
                steps.Add(step);
            }

            int count = steps.Count();

            for (int i = count + 1; i < 9; i++)
            {
                Plan_Step step = new Plan_Step();
                step.stepNo           = i;
                step.TimeFromLastStep = 0;
                steps.Add(step);
            }
            count = steps.Count();
        }
Ejemplo n.º 6
0
        public int createAndGetDealID(Deal deal, int productID, int plann)
        {
            SSMEntities     se      = new SSMEntities();
            softwareProduct product = se.softwareProducts.Find(productID);

            if (product != null)
            {
                deal.ProductID = productID;
            }
            deal.Creator         = User.Identity.GetUserId();
            deal.StartDate       = DateTime.Today;
            deal.Stage           = 1;
            deal.Probability     = 0;
            deal.CompleteOn      = null;
            deal.LastUpdateStage = null;
            deal.Status          = 1;
            deal.CurrentPlanID   = product.PrePurchase_FollowUp_Plan.Where(u => u.isOperation).FirstOrDefault().id;

            se.Deals.Add(deal);
            se.SaveChanges();
            Deal_Item         ite = new Deal_Item();
            productMarketPlan pla = se.productMarketPlans.Find(plann);

            ite.planID   = plann;
            ite.price    = pla.ceilPrice;
            ite.Quantity = 1;
            ite.dealID   = deal.id;
            se.Deal_Item.Add(ite);
            deal.Value = ite.price;
            se.SaveChanges();
            Deal_SaleRep_Respon dealrespont = new Deal_SaleRep_Respon();

            dealrespont.dealID = deal.id;
            dealrespont.userID = deal.Creator;
            se.Deal_SaleRep_Respon.Add(dealrespont);
            se.SaveChanges();
            contact contact = se.contacts.Find(deal.Client);
            int     day     = 0;
            PrePurchase_FollowUp_Plan plan = deal.softwareProduct.PrePurchase_FollowUp_Plan.Where(u => u.isOperation == true).FirstOrDefault();

            if (contact != null)
            {
                foreach (Plan_Step tep in plan.Plan_Step)
                {
                    if (tep.TimeFromLastStep == null)
                    {
                        tep.TimeFromLastStep = 0;
                    }
                    day = day + (int)tep.TimeFromLastStep;
                    DealTask task = new DealTask();
                    task.dealID          = deal.id;
                    task.TaskDescription = tep.StepEmailContent;
                    task.status          = 1;
                    if (tep.RequireMoreDetail)
                    {
                        task.status = 7;
                    }
                    task.Deadline    = DateTime.Now.AddDays(day);
                    task.CreateDate  = DateTime.Now;
                    task.TaskContent = tep.stepNo + "";
                    task.TaskName    = tep.subject + " [#:" + deal.id + "]";
                    task.type        = 8;
                    se.DealTasks.Add(task);
                    se.SaveChanges();
                    if (task.TaskDescription.Contains(se.ConfigureSys.Find(13).value))
                    {
                        String replaceall = "";
                        foreach (Deal_Item item in task.Deal.Deal_Item)
                        {
                            TrialAccount trial = item.productMarketPlan.TrialAccounts.Where(u => u.contactID == null).FirstOrDefault();
                            replaceall = replaceall + '\n' + "User Name for " + item.productMarketPlan.Name + ": " + trial.UserName + " Password: " + trial.Password;
                            TrialAccount trialupdate = se.TrialAccounts.Find(trial.AccountID);
                            trialupdate.contactID = task.Deal.contact.id;
                            se.SaveChanges();
                        }
                        task.TaskDescription = task.TaskDescription.Replace(se.ConfigureSys.Find(13).value, replaceall);
                    }
                    se.SaveChanges();
                }
            }


            return(deal.id);
        }
Ejemplo n.º 7
0
        public ActionResult FinishEditProgress(FollowupProgressModel model)
        {
            SSMEntities se = new SSMEntities();
            PrePurchase_FollowUp_Plan plan = se.PrePurchase_FollowUp_Plan.Find(model.id);

            if (plan != null)
            {
                plan.name        = model.Name;
                plan.Description = model.Desription;
                plan.lastUpdate  = DateTime.Today;
                foreach (Plan_Step step in plan.Plan_Step.ToList())
                {
                    step.previousStep = null;
                    step.nextStep     = null;
                    se.SaveChanges();
                    se.Plan_Step.Remove(step);
                }
                int index = 1;
                for (int i = 1; i < model.steps.Count() + 1; i++)
                {
                    Plan_Step step = model.steps[i - 1];
                    if (step.StepEmailContent != null)
                    {
                        step.planID = plan.id;
                        step.stepNo = i;

                        se.Plan_Step.Add(step);
                        se.SaveChanges();
                        index = index + 1;
                    }
                    else
                    {
                        model.steps.Remove(step);
                    }
                }
                for (int i = 1; i < model.steps.Count() + 1; i++)
                {
                    Plan_Step step = model.steps[i - 1];
                    try {
                        step.previousStep = model.steps[i - 2].id;
                    }
                    catch (Exception e) { step.previousStep = null; }
                    try
                    {
                        step.nextStep = model.steps[i].id;
                    }
                    catch (Exception e) { step.nextStep = null; }
                    try
                    {
                        if (step.previousStep == 0)
                        {
                            step.previousStep = null;
                        }
                    }
                    catch (Exception e) { }
                    try
                    {
                        if (step.nextStep == 0)
                        {
                            step.nextStep = null;
                        }
                    }
                    catch (Exception e) { }
                    se.SaveChanges();
                }
            }
            return(RedirectToAction("EditPlan", new { planID = plan.id }));
        }