예제 #1
0
파일: PlanBl.cs 프로젝트: binumon/Binu
        public int UpdatePlan(PlanModel Plan)
        {
            PlanDal Dal = new PlanDal();

            Dal.UpdatePlan(Plan);
            return(1);
        }
예제 #2
0
파일: PlanBl.cs 프로젝트: binumon/Binu
        public int AddPlan(PlanModel Plan)
        {
            PlanDal Dal = new PlanDal();

            Dal.AddPlan(Plan);
            return(1);
        }
예제 #3
0
        public ActionResult Details(string id)
        {
            RecipeModel details = recipeDal.RecipeDetail(Convert.ToInt32(id));

            details.TagsList   = recipeDal.GetTagsFromId(Convert.ToInt32(id));
            details.Categories = recipeDal.GetCatsFromId(Convert.ToInt32(id));
            if (Authorize.Registered((int?)Session["authorizationlevel"]) == true || Authorize.Admin((int?)Session["authorizationlevel"]) == true)
            {
                UserModel     user  = Session["user"] as UserModel;
                PlanModel     p     = new PlanModel();
                DropDownPlans model = new DropDownPlans();

                model.selectedRecipe = Convert.ToInt32(id);
                List <PlanModel> plans = planDal.GetAllUserPlans(user.UserID);
                foreach (PlanModel plan in plans)
                {
                    string planname = planDal.GetPlanName(plan.PlanId);
                    plan.PlanName = planname;
                }
                List <string> days  = p.Days;
                List <string> meals = p.Meals;

                //model.Recipes = recipes;
                model.PlanModels    = plans;
                model.Days          = days;
                model.Meals         = meals;
                Session["dropDown"] = model;
            }

            return(View(details));
        }
예제 #4
0
        public ActionResult DeletePlans(string Plan_ID)
        {
            objResponse Response = new objResponse();

            try
            {
                Response = objSubscriptionManager.DeletePlan(Convert.ToInt64(Plan_ID));

                if (Response.ErrorCode == 0)
                {
                    var planService = new StripePlanService();
                    planService.Delete(Plan_ID);

                    PlanModel objPlanModel = new PlanModel();
                    objPlanModel.plans = objSubscriptionManager.GetPlans();
                    return(View("AjaxAddPlan", objPlanModel));
                }
                else
                {
                    return(Json("", JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                BAL.Common.LogManager.LogError("DeletePlan Post method", 1, Convert.ToString(ex.Source), Convert.ToString(ex.StackTrace), Convert.ToString(ex.Message));
                return(Json("", JsonRequestBehavior.AllowGet));
            }
        }
예제 #5
0
        public ActionResult AddMealToPlan()
        {
            UserModel     user  = Session["user"] as UserModel;
            PlanModel     p     = new PlanModel();
            DropDownPlans model = new DropDownPlans();

            List <RecipeModel> recipes = recipeDal.GetRecipes();
            List <PlanModel>   plans   = planDal.GetAllUserPlans(user.UserID);

            foreach (PlanModel plan in plans)
            {
                string planname = planDal.GetPlanName(plan.PlanId);
                plan.PlanName = planname;
            }
            List <string> days  = p.Days;
            List <string> meals = p.Meals;

            model.Recipes    = recipes;
            model.PlanModels = plans;
            model.Days       = days;
            model.Meals      = meals;



            return(View(model));
        }
예제 #6
0
        public void addNewPlan(PlanModel plan)
        {
            if (plan.component_id < 1)
            {
                throw new Exception("Please select component");
            }
            if (String.IsNullOrEmpty(plan.model_name) || String.IsNullOrWhiteSpace(plan.model_name))
            {
                throw new Exception("Plan model cannot leave empty");
            }
            if (plan.plan_data < 0)
            {
                throw new Exception("Plan data must greater than 0");
            }
            if (plan.plan_line < 0)
            {
                throw new Exception("Plan line must greater than 0");
            }
            decimal model_id = BomModelModelDAO.getInstance().getIdByName(plan.model_name);

            plan.model_id = model_id;
            if (PlanDao.getInstance().isExist(plan))
            {
                throw new Exception("Plan existed");
            }
            PlanDao.getInstance().add(plan);
        }
예제 #7
0
        public static void ReadDataFromFile()
        {
            using (var db = new PlanContext())
            {
                string       html = @"C:\Program Files (x86)\IIS Express\StartPage.html";
                HtmlDocument doc  = new HtmlDocument();

                StreamReader reader = new StreamReader(html, Encoding.UTF8);
                doc.Load(reader);

                var nodes = doc.DocumentNode.Descendants().Where(n => n.Name == "a").Select(n => new { Name = n.InnerText, value = n.Attributes[0].Value }).ToList();

                string tempLink;

                foreach (var item in nodes)
                {
                    tempLink = "http://plany.ath.bielsko.pl/" + item.value + "&winW=500&winH=300&loadBG=000000";

                    GetFile(tempLink, item.Name);

                    var t = new PlanModel
                    {
                        Name     = item.Name,
                        Link     = tempLink,
                        FileName = @"C:\ICSFiles\" + item.Name + ".ics"
                    };
                    db.PlanModel.Add(t);
                }
                db.SaveChanges();
            }
        }
예제 #8
0
        public ActionResult Edit(PlanModel model, bool continueEditing, FormCollection form)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageHyip))
            {
                return(AccessDeniedView());
            }

            var plan = _planService.GetPlanById(model.Id);

            if (plan == null || plan.Deleted)
            {
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                plan = model.ToEntity(plan);

                _planService.UpdatePlan(plan);

                _eventPublisher.Publish(new ModelBoundEvent(model, plan, form));

                //activity log
                _customerActivityService.InsertActivity("EditPlan", _localizationService.GetResource("ActivityLog.EditCategory"), plan.Name);

                NotifySuccess(_localizationService.GetResource("Admin.Catalog.Categories.Updated"));
                return(continueEditing ? RedirectToAction("Edit", plan.Id) : RedirectToAction("List"));
            }

            return(View(model));
        }
        /// <summary>
        /// Udate existing Plan in client model session
        /// </summary>
        /// <param name="model">Existing plan instance to update</param>
        /// <returns>Returns true if updating was succesfull. Otherwise false.</returns>
        public bool UpdatePlanToClientModelSession(PlanModel model)
        {
            ClientFullModel fullModel = GetFullModelFromClientModel();

            if (fullModel != null)
            {
                var record = fullModel.Plan.Where(p => p.idPlan == model.idPlan).FirstOrDefault();
                if (record != null)
                {
                    int index = fullModel.Plan.IndexOf(record);
                    if (index != -1)
                    {
                        fullModel.Plan[index] = model;
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }

                AddValueToSession(Enums.ClientSession.ClientModel, fullModel);

                return(true);
            }
            return(false);
        }
        public IActionResult AddNew([FromBody] PlanModel userInput)
        {
            try
            {
                PlanModel NewPlan = new PlanModel()
                {
                    Type        = userInput.Type,
                    Description = userInput.Description,
                    Day1        = userInput.Day1,
                    Day2        = userInput.Day2,
                    Day3        = userInput.Day3,
                    Day4        = userInput.Day4,
                    Day5        = userInput.Day5,
                    Day6        = userInput.Day6,
                    Day7        = userInput.Day7
                };

                _planData.AddPlan(NewPlan);

                return(Ok($"Plan added with and have the Id {NewPlan.Id} and type {NewPlan.Type}"));
            }
            catch (Exception ex)
            {
                _apiErrorHandler.CreateError(ex.Source, ex.StackTrace, ex.Message);
            }

            return(StatusCode(500));
        }
예제 #11
0
        public ResponseModel AddPlan([FromBody] PlanModel planModel)
        {
            FeaturePlanCaller newFeaturePlanCaller = new FeaturePlanCaller();
            ResponseModel     objResponseModel     = new ResponseModel();
            int    statusCode    = 0;
            string statusMessage = "";

            try
            {
                ////Get token (Double encrypted) and get the tenant id
                string       token        = Convert.ToString(Request.Headers["X-Authorized-Token"]);
                Authenticate authenticate = new Authenticate();
                authenticate = SecurityService.GetAuthenticateDataFromTokenCache(Cache, SecurityService.DecryptStringAES(token));

                planModel.CreatedBy = authenticate.UserMasterID;

                int result = newFeaturePlanCaller.AddPlan(new FeaturePlanService(Cache, Db), planModel);

                statusCode = result == 0 ? (int)EnumMaster.StatusCode.RecordNotFound : (int)EnumMaster.StatusCode.Success;

                statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode);

                objResponseModel.Status       = true;
                objResponseModel.StatusCode   = statusCode;
                objResponseModel.Message      = statusMessage;
                objResponseModel.ResponseData = result;
            }
            catch (Exception)
            {
                throw;
            }

            return(objResponseModel);
        }
예제 #12
0
        public PlanModel ViewPlan(PlanModel model)
        {
            if (model != null && model.Id != 0)
            {
                using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db)))
                {
                    var p = new DynamicParameters();
                    p.Add("@Id", model.Id);

                    model = connection.Query <PlanModel>("dbo.spPlan_GetById", p, commandType: CommandType.StoredProcedure).First();

                    model.FoodList = connection.Query <FoodModel>("dbo.spPlanItems_GetFood", p, commandType: CommandType.StoredProcedure).ToList();

                    model.RecipeList = connection.Query <RecipeModel>("dbo.spPlanItems_GetRecipe", p, commandType: CommandType.StoredProcedure).ToList();

                    foreach (RecipeModel r in model.RecipeList)
                    {
                        p = new DynamicParameters();
                        p.Add("@Id", r.Id);

                        r.FoodList = connection.Query <FoodModel>("dbo.spRecipeItems_GetFood", p, commandType: CommandType.StoredProcedure).ToList();
                    }
                }
            }

            return(model);
        }
예제 #13
0
        //done ??? code review
        public PlanModel GetMeal(int mealID)
        {
            PlanModel p = new PlanModel();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand(GetMealSql, conn);
                    cmd.Parameters.AddWithValue("@mealid", mealID);
                    SqlDataReader results = cmd.ExecuteReader();
                    while (results.Read())
                    {
                        p.Meal = Convert.ToString(results["meal_name"]);
                        p.Day  = Convert.ToString(results["day_of_week"]);
                    }
                }
            }
            catch (SqlException ex)
            {
                throw;
            }

            return(p);
        }
예제 #14
0
 public HttpResponseMessage UpdatePlan(PlanModel Model)
 {
     try
     {
         PlanBl Bl     = new PlanBl();
         int    Status = Bl.UpdatePlan(Model);
         if (Status == 1)
         {
             return(new Response <string>("Added Succesfully", "", HttpStatusCode.Created));
         }
         else if (Status == 2)
         {
             return(new Response <string>("already exist", "", HttpStatusCode.Ambiguous));
         }
         else if (Status == 3)
         {
             return(new Response <string>("updated Successfully", "", HttpStatusCode.Created));
         }
         else if (Status == 4)
         {
             return(new Response <string>("Not found", "", HttpStatusCode.NotFound));
         }
         else
         {
             return(new Response <string>("Failed", "", HttpStatusCode.NotImplemented));
         }
     }
     catch (Exception ex)
     {
         return(new Response <string>("Something went wrong", "", HttpStatusCode.ServiceUnavailable));
     }
 }
예제 #15
0
        public static ICollection <PlanModel> GetAll()
        {
            ICollection <PlanModel> results = new List <PlanModel>();
            var conStr = DbHelper.GetConnectionString();
            var query  = "usp_plan_GetAll";

            using (var conn = new SqlConnection(conStr))
            {
                var cmd = new SqlCommand(query, conn);
                cmd.CommandType = CommandType.StoredProcedure;
                SqlDataReader dr = null;
                conn.Open();
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    var obj = new PlanModel();
                    obj.PlanId     = Convert.ToInt32(dr["ID"]);
                    obj.PlanName   = dr["plan_Name"].ToString();
                    obj.Descr      = dr["plan_descr"].ToString();
                    obj.Deductable = Convert.ToDouble(dr["plan_deduct"]);
                    results.Add(obj);
                }
            }

            return(results);
        }
예제 #16
0
        public static bool Update(PlanModel obj)
        {
            var           result = false;
            SqlConnection conn   = null;

            try
            {
                var conStr = DbHelper.GetConnectionString();
                var query  = "usp_plan_update";
                conn = new SqlConnection(conStr);
                var cmd = new SqlCommand(query, conn);
                cmd.Parameters.AddWithValue("PlanId", obj.PlanId);
                cmd.Parameters.AddWithValue("PlanName", obj.PlanName);
                cmd.Parameters.AddWithValue("PlanDescr", obj.Descr);
                cmd.Parameters.AddWithValue("PlanDeduct", obj.Deductable);

                cmd.CommandType = CommandType.StoredProcedure;
                conn.Open();
                result = cmd.ExecuteNonQuery() > 0 ? true : false;
                conn.Close();
            }

            catch (Exception ex)
            {
            }
            finally
            {
                conn?.Close();
            }
            return(result);
        }
예제 #17
0
        public void ClosePlanTest()
        {
            const string accountName = "ExpenseManagerAccount01";
            const string typeName    = "Food";
            var          account     = new AccountModel
            {
                Badges = new List <AccountBadgeModel>(),
                Costs  = new List <CostInfoModel>(),
                Name   = accountName
            };
            var type = new CostTypeModel
            {
                Name         = typeName,
                CostInfoList = new EditableList <CostInfoModel>(),
                Account      = account
            };
            var plan = new PlanModel
            {
                Description  = "I want money for food!",
                PlanType     = PlanTypeModel.Save,
                PlannedMoney = 10000,
                IsCompleted  = false,
            };

            using (
                var db =
                    new ExpenseDbContext(
                        Effort.DbConnectionFactory.CreatePersistent(TestInstaller.ExpenseManagerTestDbConnection)))
            {
                db.Accounts.Add(account);
                db.CostTypes.Add(type);
                db.SaveChanges();
                var accountId = account.Id;
                plan.AccountId   = accountId;
                plan.PlannedType = type;
                db.Plans.Add(plan);
                db.SaveChanges();
                var item = new CostInfoModel()
                {
                    Description          = "bread",
                    AccountId            = accountId,
                    TypeId               = type.Id,
                    IsIncome             = true,
                    Money                = 10001,
                    Created              = DateTime.Now.Subtract(new TimeSpan(100, 0, 0, 0)),
                    Account              = db.Accounts.Find(accountId),
                    Type                 = db.CostTypes.Find(type.Id),
                    Periodicity          = PeriodicityModel.None,
                    PeriodicMultiplicity = 3
                };
                db.CostInfos.Add(item);
                db.SaveChanges();
            }
            var closeable = _balanceFacade.ListAllCloseablePlans(account.Id);
            var balance   = _balanceFacade.GetBalance(account.Id);

            Assert.IsTrue(closeable.Count == 1, "Plan not found as closeable");
            _balanceFacade.ClosePlan(closeable.Single());
            Assert.IsTrue(balance == _expenseFacade.ListItems(null, null, null, null, null, null, null, false, null).Single().Money + _balanceFacade.GetBalance(account.Id));
        }
예제 #18
0
        public void CheckAllMaxSpendDeadlinesTest()
        {
            const string accountName = "ExpenseManagerAccount01";
            const string typeName    = "Food";
            var          account     = new AccountModel
            {
                Badges = new List <AccountBadgeModel>(),
                Costs  = new List <CostInfoModel>(),
                Name   = accountName
            };
            var type = new CostTypeModel
            {
                Name         = typeName,
                CostInfoList = new EditableList <CostInfoModel>(),
                Account      = account
            };
            var plan = new PlanModel
            {
                Description  = "I want money for food!",
                PlanType     = PlanTypeModel.MaxSpend,
                PlannedMoney = 10000,
                PlannedType  = type,
                IsCompleted  = false,
                Start        = DateTime.Now.Subtract(new TimeSpan(100, 0, 0, 0)),
                Deadline     = DateTime.Now.Add(new TimeSpan(0, 0, 1, 0))
            };

            using (
                var db =
                    new ExpenseDbContext(
                        Effort.DbConnectionFactory.CreatePersistent(TestInstaller.ExpenseManagerTestDbConnection)))
            {
                db.Accounts.Add(account);
                db.CostTypes.Add(type);
                db.SaveChanges();
                var accountId = account.Id;
                plan.AccountId   = accountId;
                plan.PlannedType = type;
                db.Plans.Add(plan);
                db.SaveChanges();
                var item = new CostInfoModel()
                {
                    Description          = "bread",
                    AccountId            = accountId,
                    TypeId               = type.Id,
                    IsIncome             = true,
                    Money                = 999,
                    Created              = DateTime.Now.Subtract(new TimeSpan(100, 0, 0, 0)),
                    Account              = db.Accounts.Find(accountId),
                    Type                 = db.CostTypes.Find(type.Id),
                    Periodicity          = PeriodicityModel.None,
                    PeriodicMultiplicity = 3
                };
                db.CostInfos.Add(item);
                db.SaveChanges();
            }
            _balanceFacade.CheckAllMaxSpendDeadlines();
            Assert.IsTrue(_balanceFacade.ListPlans(null, null).Count == 1);
            Assert.IsTrue(_balanceFacade.ListPlans(null, null).Single().IsCompleted);
        }
        public async Task <IResult> UpdateAsync(PlanModel model)
        {
            var validation = await new UpdatePlanModelValidator().ValidateAsync(model);

            if (validation.Failed)
            {
                return(Result.Fail(validation.Message));
            }

            var plan = await _repository.GetAsync(model.Id);

            if (plan == default)
            {
                return(Result.Success());
            }
            if (model.Status == (int)Status.Active)
            {
                plan.Activate();
            }
            else
            {
                plan.Inactivate();
            }

            await _repository.UpdateStatusAsync(plan);

            await _unitOfWork.SaveChangesAsync();

            return(Result.Success());
        }
예제 #20
0
        protected void btnCreate_Click(object sender, EventArgs e)
        {
            IAction <PlanModel> actionobj = new PlanAction();
            var model = new PlanModel();

            model.PlanName = txtPlanName.Text;
            model.Descr    = txtDescr.Text;

            if (txtDetuc.Text == string.Empty)
            {
                txtDetuc.Text = "";
            }

            int val;
            var result = int.TryParse(txtDetuc.Text, out val);

            if (!result)
            {
                return;
            }

            model.Deductable = Convert.ToDouble(txtDetuc.Text);

            if (actionobj.Insert(model) == true)
            {
                lblResult.Text = "Plan Has Been Added Successfully! ";
            }
            else
            {
                lblResult.Text = "Plan Is Not Added ";
            }
        }
        public void UpdatePlan(PlanModel p)
        {
            Plan ph = db.Plans.GetItem(p.Plan_PK);

            db.Plans.Update(toPlan(ph, p));
            db.Save();
        }
예제 #22
0
        public ActionResult ListCommission(GridCommand command, PlanModel model)
        {
            var gridModel = new GridModel <PlanModel>();

            if (_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
            {
                var plancommission = _planService.GetPlanCommissionPlanId(model.PlanId);
                gridModel.Data = plancommission.Select(x =>
                {
                    var planModel        = new PlanModel();
                    planModel.Id         = x.Id;
                    planModel.PlanId     = x.PlanId;
                    planModel.Commission = x.CommissionPercentage;
                    planModel.LevelId    = x.LevelId;
                    planModel.Name       = _planService.GetPlanById(x.PlanId).Name;
                    return(planModel);
                });

                gridModel.Total = plancommission.Count;
            }
            else
            {
                gridModel.Data = Enumerable.Empty <PlanModel>();

                NotifyAccessDenied();
            }

            return(new JsonResult
            {
                Data = gridModel
            });
        }
예제 #23
0
        public ActionResult Plans()
        {
            PlanModel objPlanModel = new PlanModel();

            objPlanModel.plans = objSubscriptionManager.GetPlans();
            return(View(objPlanModel));
        }
예제 #24
0
        public List <PlanModel> GetAllUserPlans(int userID)
        {
            List <PlanModel> result = new List <PlanModel>();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand(getAllUserUserPlansSql, conn);
                    cmd.Parameters.AddWithValue("@userid", userID);
                    SqlDataReader results = cmd.ExecuteReader();
                    while (results.Read())
                    {
                        PlanModel p = new PlanModel();
                        p.PlanId = Int32.Parse((results["plan_id"].ToString()));
                        result.Add(p);
                    }
                }
            }
            catch (SqlException ex)
            {
                throw;
            }
            return(result);
        }
예제 #25
0
        public int AddPlan(PlanModel plan)
        {
            int result = 0;

            try
            {
                conn = Db.Connection;
                MySqlCommand cmd = new MySqlCommand("SP_AddPlan", conn);
                cmd.Connection  = conn;
                cmd.CommandType = CommandType.StoredProcedure;
                //cmd.Parameters.AddWithValue("@Tenant_ID", TenantId);
                cmd.Parameters.AddWithValue("@UserID", plan.CreatedBy);
                cmd.Parameters.AddWithValue("@Planname", plan.PlanName);
                cmd.Parameters.AddWithValue("@MonthlyPlanPrice", plan.MonthlyAmount);
                cmd.Parameters.AddWithValue("@YearlyPlanPrice", plan.YearlyAmount);
                cmd.Parameters.AddWithValue("@TotalUsers", plan.TotalUsers);
                cmd.Parameters.AddWithValue("@IsPublish", plan.IsPublished);
                cmd.Parameters.AddWithValue("@IsMostPopular", plan.IsMostPopular);
                cmd.Parameters.AddWithValue("@FeatureID", plan.FeatureID);
                cmd.Parameters.AddWithValue("@AddOnsID", plan.AddOnsID);


                result = Convert.ToInt32(cmd.ExecuteNonQuery());
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(result);
        }
예제 #26
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            var obj = new PlanModel();


            obj.Descr      = descr.Text;
            obj.Deductable = Convert.ToDouble(dectVal.Text);

            obj.PlanName = ddlPlan.SelectedItem.Text;
            obj.PlanId   = Convert.ToInt32(ViewState["Plan_id"]);

            var result = new PlanAction().Update(obj);

            if (result)
            {
                Label1.Text = "Plan Has Been Updated Successfully!";
            }
            else
            {
                Label1.Text = "Error to delete -> " + result;
            }

            BindData();
            udp.Update();
        }
예제 #27
0
        private int UpdatePlanWithNewPlanId(PlanModel existingPlanModel)
        {
            Plan objNewPlan = new Plan();


            objNewPlan.PlanName  = existingPlanModel.PlanName;
            objNewPlan.Price     = existingPlanModel.Price;
            objNewPlan.NoOfUsers = existingPlanModel.NoOfUsers;

            objNewPlan.CreatedBy    = existingPlanModel.CreatedBy;
            objNewPlan.CreatedDate  = DateTime.UtcNow;
            objNewPlan.ModifiedBy   = existingPlanModel.ModifiedBy;
            objNewPlan.ModifiedDate = DateTime.UtcNow;
            objNewPlan.PlanModules  = new List <PlanModule>();

            if (existingPlanModel.PlanModulesModel != null)
            {
                List <PlanModuleModel> listPlanModulesModel = existingPlanModel.PlanModulesModel.ToList();

                for (int i = 0; i < listPlanModulesModel.Count(); i++)
                {
                    PlanModule objPlanModule = new PlanModule();
                    objPlanModule.PlanId                  = listPlanModulesModel[i].PlanId;
                    objPlanModule.ModuleId                = listPlanModulesModel[i].ModuleId;
                    objPlanModule.HasPermission           = listPlanModulesModel[i].HasPermission;
                    objPlanModule.HasPermissionAfterTrail = listPlanModulesModel[i].HasPermissionAfterTrail;

                    objNewPlan.PlanModules.Add(objPlanModule);
                }
            }

            planRepository.Insert(objNewPlan);
            return(objNewPlan.PlanId);
        }
예제 #28
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string sPlanId = this.Request["PlanId"];

            List <Tbl_User> lUsers = ViewState["lUsers"] as List <Tbl_User>;

            int iPlanAdm   = 1;
            int iDesignAdm = lUsers[DropDownList2.SelectedIndex].ID;

            int iProductAdm = lUsers[DropDownList3.SelectedIndex].ID;

            int iCenterStorateAdm = lUsers[DropDownList4.SelectedIndex].ID;

            int iSiteStorageAdm = lUsers[DropDownList5.SelectedIndex].ID;

            Tbl_Plan oPlan = new Tbl_Plan();

            oPlan.PlanID           = int.Parse(sPlanId);
            oPlan.ProjectName      = txtProjectName.Text;
            oPlan.DesignAdm        = iDesignAdm;
            oPlan.ProductAdm       = iProductAdm;
            oPlan.CenterStorageAdm = iCenterStorateAdm;
            oPlan.SiteStorageAdm   = iSiteStorageAdm;

            Msg msg = PlanModel.EditPlan(oPlan);

            if (msg.Status)
            {
                PageHelper.ShowAlertMsg(this, "您已成功提交项目");
            }
            else
            {
                PageHelper.ShowAlertMsg(this, msg.Message);
            }
        }
예제 #29
0
        public bool AddUpdatePlan(PlanModel planModel)
        {
            Plan objPlan = new Plan();

            if (planModel.PlanId == 0)
            {
                AutoMapper.Mapper.Map(planModel, objPlan);

                planRepository.Insert(objPlan);
            }
            else
            {
                objPlan = planRepository.SingleOrDefault(x => x.PlanId == planModel.PlanId);
                if (objPlan != null)
                {
                    bool planchanged = false;

                    if (planModel.PlanName.Trim().ToLower() != objPlan.PlanName.Trim().ToLower())
                    {
                        planchanged = true;
                    }
                    else if (!planchanged && planModel.Price != objPlan.Price)
                    {
                        planchanged = true;
                    }

                    else if (!planchanged && planModel.NoOfUsers != objPlan.NoOfUsers)
                    {
                        planchanged = true;
                    }

                    if (planchanged && objPlan.CompanyPlans.Count > 0)
                    {
                        UpdatePlanWithNewPlanId(planModel);

                        //DeaActivate the old plan

                        objPlan.Active       = false;
                        objPlan.ModifiedBy   = planModel.ModifiedBy;
                        objPlan.ModifiedDate = DateTime.UtcNow;
                    }
                    else
                    {
                        //DeaActivate the old plan
                        objPlan.PlanName     = planModel.PlanName;
                        objPlan.Description  = planModel.Description;
                        objPlan.Price        = planModel.Price;
                        objPlan.NoOfUsers    = planModel.NoOfUsers;
                        objPlan.Active       = planModel.Active;
                        objPlan.ModifiedBy   = planModel.ModifiedBy;
                        objPlan.ModifiedDate = DateTime.UtcNow;

                        planRepository.Update(objPlan);
                    }
                }
            }

            return(true);
        }
예제 #30
0
        public PlanModel CreatePlan(PlanModel plan, APIRequest apiRequest)
        {
            apiRequest.RouteName = "import/plans";
            _ihttp.ApiRequest    = apiRequest;
            var response = _ihttp.Post <PlanModel, PlanModel>(plan);

            return(response);
        }
        public SchedulingProblemFrame(MdiContainer parent, PlanModel planModel, NewProblemModel initialData)
        {
            InitializeComponent();
            this.parent = parent;

            LayoutRoot.DataContext = model = planModel ?? CreateFakePlanModel();
            this.initialData = initialData;
        }
        private PlanModel CreateFakePlanModel()
        {
            var firstJob = new Job(1, 10, null, .1, 2);
            var secondJob = new Job(2, 10, new List<int> {1}, .1, 2);
            var thirdJob = new Job(3, 20, new List<int> {1, 2}, .1, 2);
            var fourthJob = new Job(4, 20, null, .1, 2);
            var jobs = new List<Job> {firstJob, secondJob, thirdJob, fourthJob};
            var resource1 = new Resource(1, 20);
            var resources = new List<Resource> {resource1};
            var dependencies = new List<double[]> {new double[] {7}, new double[] {14}, new double[] {10}, new double[] {6}};
            var planBuilder = new JobPlanBuilder();

            var plan = planBuilder.GetBasePlan(resources, jobs, dependencies);

            var planModel = new PlanModel(plan);

            return planModel;
        }