Exemplo n.º 1
0
        public ActionResult Detail(int id)
        {
            try
            {
                SSMEntities           se          = new SSMEntities();
                Deal                  thisDeal    = se.Deals.Find(id);
                List <SelectListItem> productPlan = new List <SelectListItem>();
                foreach (productMarketPlan plan in thisDeal.productMarketPlan.softwareProduct.productMarketPlans.ToList())
                {
                    productPlan.Add(new SelectListItem()
                    {
                        Text = plan.Name, Value = plan.id + ""
                    });
                }
                ViewData["DealDetail"] = thisDeal;
                ViewData["PlanList"]   = productPlan;
                ViewData["TaskStatus"] = se.TaskStatus.ToList();
                ViewData["TaskTypes"]  = se.TaskTypes.ToList();
                softwareProduct thisproduct = thisDeal.PrePurchase_FollowUp_Plan.softwareProduct;

                foreach (PrePurchase_FollowUp_Plan plan in thisproduct.PrePurchase_FollowUp_Plan.ToList())
                {
                    if (plan.isOperation)
                    {
                        ViewData["ActiveFollowUpPlan"] = plan;
                    }
                }
            }
            catch (Exception e) { }

            return(View("Detail"));
        }
Exemplo n.º 2
0
        public ActionResult Detail(int id)
        {
            productRepository pr = new productRepository(new SSMEntities());

            try
            {
                softwareProduct product = pr.getById(id);
                if (product != null)
                {
                    List <double>   totalvalues = new List <double>();
                    ProductServices ps          = new ProductServices();
                    for (int i = 0; i < 12; i++)
                    {
                        totalvalues.Add(ps.getMonthValues(i, product.id));
                        System.Diagnostics.Debug.WriteLine("added " + ps.getMonthValues(i, product.id));
                    }
                    ViewData["productDetail"] = product;

                    ViewData["productperformance"] = totalvalues;
                    return(View("ProductDescription"));
                }
            }
            catch (Exception e)
            {
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        public ActionResult Detail(int id)
        {
            SSMEntities se       = new SSMEntities();
            Deal        thisDeal = se.Deals.Find(id);

            try
            {
                ViewData["DealDetail"] = thisDeal;

                List <SelectListItem> productPlan = new List <SelectListItem>();
                foreach (productMarketPlan plan in thisDeal.softwareProduct.productMarketPlans.ToList())
                {
                    productPlan.Add(new SelectListItem()
                    {
                        Text = plan.Name, Value = plan.id + ""
                    });
                }

                ViewData["PlanList"]   = productPlan;
                ViewData["TaskStatus"] = se.TaskStatus.ToList();
                ViewData["TaskTypes"]  = se.TaskTypes.ToList();



                softwareProduct thisproduct = thisDeal.softwareProduct;
                int             days        = 0;
                foreach (PrePurchase_FollowUp_Plan plan in thisproduct.PrePurchase_FollowUp_Plan.ToList())
                {
                    if (plan.isOperation)
                    {
                        foreach (Plan_Step step in plan.Plan_Step)
                        {
                            if (step.TimeFromLastStep != null)
                            {
                                days = days + (int)step.TimeFromLastStep;
                            }
                        }
                    }
                }
                System.Diagnostics.Debug.WriteLine("AAAAAAAAAAA " + days + " BBBBBB " + (DateTime.Today - thisDeal.StartDate).Days);
                ViewData["percentage"] = (DateTime.Today - thisDeal.StartDate).Days * 100 / days;
            }
            catch (Exception e) { }
            if (thisDeal.orders.Count() > 0)
            {
                return(View("Detail", thisDeal.orders.FirstOrDefault()));
            }
            return(View("Detail"));
        }
Exemplo 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));
 }
Exemplo n.º 5
0
        public double getMonthValues(int month, int productID)
        {
            double result = 0;

            try
            {
                SSMEntities     dbContext = new SSMEntities();
                softwareProduct product   = (softwareProduct)dbContext.softwareProducts.Find(productID);
                if (product != null)
                {
                    List <OrderItem> MPlist = dbContext.OrderItems.Where(u => u.productMarketPlan.softwareProduct.id == product.id).ToList();
                    foreach (OrderItem mp in MPlist)
                    {
                        if (mp.order.createDate.Month == month)
                        {
                            result = result + mp.SoldPrice;
                        }
                    }
                }
            }
            catch (Exception e) { }

            return(result);
        }
Exemplo n.º 6
0
        public double getMonthValues(int month, int productID)
        {
            double result = 0;

            try
            {
                SSMEntities     dbContext = new SSMEntities();
                softwareProduct product   = (softwareProduct)dbContext.softwareProducts.Find(productID);
                if (product != null)
                {
                    List <MarketPlanPurchased> MPlist = product.MarketPlanPurchaseds.ToList();
                    foreach (MarketPlanPurchased mp in MPlist)
                    {
                        if (mp.order.createDate.Month == month)
                        {
                            result = result + mp.SoldPrice;
                        }
                    }
                }
            }
            catch (Exception e) { }

            return(result);
        }
Exemplo n.º 7
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);
        }