public AllocationModel ResetAllocation(AllocationModel objAllocationModel)
 {
     #region Call API
     objAllocationModel = WebApiLogic.GetPostComplexTypeToAPI <AllocationModel>(objAllocationModel, "ResetAllocation", "Allocation");
     #endregion
     return(objAllocationModel);
 }
 public AllocationModel LoadAllocationDetails(AllocationModel objAllocationModel)
 {
     #region Call API
     objAllocationModel = WebApiLogic.GetPostComplexTypeToAPI <AllocationModel>(objAllocationModel, "LoadAllocationDetails", "Allocation");
     #endregion
     return(objAllocationModel);
 }
Exemple #3
0
        public Error InsertOrUpdateAllocation(AllocationModel allocation, UserModel user, string lockGuid)
        {
            var error = validateModel(allocation);

            if (!error.IsError)
            {
                // Check that the lock is still current
                if (!db.IsLockStillValid(typeof(Allocation).ToString(), allocation.Id, lockGuid))
                {
                    error.SetError(EvolutionResources.errRecordChangedByAnotherUser, "");
                }
                else
                {
                    Allocation temp = null;
                    if (allocation.Id != 0)
                    {
                        temp = db.FindAllocation(allocation.Id);
                    }
                    if (temp == null)
                    {
                        temp = new Allocation();
                    }

                    temp = Mapper.Map <AllocationModel, Allocation>(allocation);

                    db.InsertOrUpdateAllocation(temp);
                    allocation.Id = temp.Id;
                }
            }
            return(error);
        }
Exemple #4
0
        // GET: Project/Edit/5
        public ActionResult Edit(int?id)
        {
            AllocationModel empModel = new AllocationModel();

            try
            {
                InitializePageData();

                if (!id.HasValue)
                {
                    DisplayWarningMessage("Looks like, the required data is not available with your request");
                    return(RedirectToAction("List"));
                }

                if (!allocationService.Exists(id.Value))
                {
                    DisplayWarningMessage($"Sorry, we couldn't find the allocation details with ID: {id.Value}");
                    return(RedirectToAction("List"));
                }

                ProjectAllocationDto emp = allocationService.GetByID(id.Value);
                empModel = Mapper.Map <ProjectAllocationDto, AllocationModel>(emp);
            }
            catch (Exception exp)
            {
                DisplayReadErrorMessage(exp);
            }

            return(View(empModel));
        }
Exemple #5
0
        public ActionResult Edit(AllocationModel allocation)
        {
            try
            {
                InitializePageData();

                if (ModelState.IsValid)
                {
                    if (IsValidAllocation(allocation) == false)
                    {
                        return(View(allocation));
                    }

                    if (allocation.AllocationEndDate <= allocation.AllocationStartDate)
                    {
                        DisplayWarningMessage("The End date should be greater than the Start date");
                        return(View(allocation));
                    }

                    ProjectAllocationDto projectDto = Mapper.Map <AllocationModel, ProjectAllocationDto>(allocation);
                    allocationService.Update(projectDto);
                    DisplaySuccessMessage($"Project allocation details have been updated for {allocation.EmployeeName}");
                    return(RedirectToAction("List"));
                }
            }
            catch (Exception exp)
            {
                DisplayUpdateErrorMessage(exp);
            }
            return(View(allocation));
        }
        public ActionResult Edit(AllocationModel allocation, string filterType, string filterValue, string sortBy, string sortType, int?page)
        {
            try
            {
                InitializePageData();

                if (ModelState.IsValid)
                {
                    if (IsValidAllocation(allocation) == false)
                    {
                        return(View(allocation));
                    }

                    if (allocation.AllocationEndDate <= allocation.AllocationStartDate)
                    {
                        DisplayWarningMessage("The End date should be greater than the Start date");
                        return(View(allocation));
                    }

                    ProjectAllocationDto projectDto = Mapper.Map <AllocationModel, ProjectAllocationDto>(allocation);
                    allocationService.Update(projectDto);
                    DisplaySuccessMessage($"Project allocation details have been updated successfully.");
                    return(RedirectToAction("List", new { filterType, filterValue, sortBy, sortType, page }));
                }
            }
            catch (Exception exp)
            {
                DisplayUpdateErrorMessage(exp);
            }
            return(View(allocation));
        }
Exemple #7
0
    protected void ShowAllocationData()
    {
        AllocationBllAction allocationBllAction = new AllocationBllAction();
        AllocationModel     allocationModel     = new AllocationModel();

        allocationModel                  = allocationBllAction.ReturnAllocatonModel("aid='" + base.Request.QueryString["ic"] + "' ");
        this.lblAllocationNo.Text        = allocationModel.Acode;
        this.FileLink1.FID               = allocationModel.Acode;
        this.txtOutDepository.Text       = allocationBllAction.GetTreasuryNameByCode(allocationModel.TCodea).Rows[0][0].ToString();
        this.txtInDepository.Text        = allocationBllAction.GetTreasuryNameByCode(allocationModel.TCodeb).Rows[0][0].ToString();
        this.txtInDate.Text              = allocationModel.InTime;
        this.txtOutAllocationPerson.Text = allocationBllAction.GetUserNameByCode(allocationModel.OutAllocationPerson);
        this.txtInAllocationPerson.Text  = allocationBllAction.GetUserNameByCode(allocationModel.InAllocationPerson);
        this.txtRemark.Text              = allocationModel.Explain;
        this.HdnTCodea.Value             = allocationModel.TCodea;
        this.HdnAcode.Value              = allocationModel.Acode;
        DataTable allocationStockList = allocationBllAction.GetAllocationStockList(allocationModel.TCodea, "acode='" + allocationModel.Acode + "'");

        this.GVMaterialList.DataSource = allocationStockList;
        this.GVMaterialList.DataBind();
        if (allocationStockList.Rows.Count > 0)
        {
            string total = Convert.ToDecimal(allocationStockList.Compute("SUM(Total)", string.Empty)).ToString("0.000");
            GridViewUtility.AddTotalRow(this.GVMaterialList, total, 11);
        }
        this.lblBllProducer.Text = PageHelper.QueryUser(this, base.UserCode);
        this.lblPrintDate.Text   = DateTime.Now.ToShortDateString();
    }
Exemple #8
0
        public void DeleteAllocationTest()
        {
            // Get a test user
            var testUser    = GetTestUser();
            var testCompany = GetTestCompany(testUser);

            // Create a record
            var productList = FindProductsForTest(db.FindParentCompany(), 1);

            Assert.IsTrue(productList.Count() > 0, "Error: No products were returned for the parent company. This could be because the parent company has not been flagged or it has no allocations");

            AllocationModel model = createAllocation(testCompany, productList[0]);

            var error = AllocationService.InsertOrUpdateAllocation(model, testUser, "");

            Assert.IsTrue(!error.IsError, error.Message);

            // Check that it was written
            var result = db.FindAllocation(model.Id);
            var test   = AllocationService.MapToModel(result);

            AreEqual(model, test);

            // Now delete it
            AllocationService.DeleteAllocation(model.Id);

            // And check that is was deleted
            result = db.FindAllocation(model.Id);
            Assert.IsTrue(result == null, "Error: A non-NULL value was returned when a NULL value was expected - record delete failed");
        }
Exemple #9
0
        private bool IsValidAllocation(AllocationModel allocation)
        {
            ProjectDto project = projectService.GetByID(allocation.ProjectID);

            if (allocation.AllocationStartDate < project.StartDate)
            {
                DisplayWarningMessage("Allocation Start Date should be equal to or above the Project Start Date");
                return(false);
            }

            if (allocation.AllocationEndDate > project.EndDate)
            {
                DisplayWarningMessage("Allocation End Date should be within the Project End Date");
                return(false);
            }

            if (allocation.AllocationEndDate < allocation.AllocationStartDate || allocation.AllocationEndDate < project.StartDate)
            {
                DisplayWarningMessage("Allocation End Date should be within the range of Project Start & End Dates");
                return(false);
            }

            EmployeeDto emp = empService.GetEmployee(allocation.EmployeeID);

            if (allocation.AllocationStartDate < emp.DateOfJoin)
            {
                DisplayWarningMessage($"Selected Employee's DoJ is {emp.DateOfJoin.ToString("MM/dd/yyyy")}. Allocation Start Date should be above that");
                return(false);
            }

            return(true);
        }
Exemple #10
0
        public void GetAllocationByAllocationResultId_GivenResultFound_ReturnsContentResult()
        {
            //Arrange
            string allocationResultId = "12345";

            IHeaderDictionary headerDictionary = new HeaderDictionary();

            headerDictionary.Add("Accept", new StringValues("application/json"));

            HttpRequest request = Substitute.For <HttpRequest>();

            request
            .Headers
            .Returns(headerDictionary);

            PublishedProviderResult publishedProviderResult = CreatePublishedProviderResult();

            publishedProviderResult.FundingStreamResult.AllocationLineResult.Current.FeedIndexId = allocationResultId;

            IPublishedResultsService resultsService = CreateResultsService();

            resultsService
            .GetPublishedProviderResultByVersionId(Arg.Is(allocationResultId))
            .Returns(publishedProviderResult);

            AllocationsService service = CreateService(resultsService);

            //Act
            IActionResult result = service.GetAllocationByAllocationResultId(allocationResultId, request);

            //Assert
            result
            .Should()
            .BeOfType <ContentResult>();

            ContentResult contentResult = result as ContentResult;

            AllocationModel allocationModel = JsonConvert.DeserializeObject <AllocationModel>(contentResult.Content);

            allocationModel
            .Should()
            .NotBeNull();

            allocationModel.AllocationResultId.Should().Be(allocationResultId);
            allocationModel.AllocationStatus.Should().Be("Published");
            allocationModel.AllocationAmount.Should().Be(50);
            allocationModel.FundingStream.Id.Should().Be("fs-1");
            allocationModel.FundingStream.Name.Should().Be("funding stream 1");
            allocationModel.Period.Id.Should().Be("Ay12345");
            allocationModel.Provider.UkPrn.Should().Be("1111");
            allocationModel.Provider.Upin.Should().Be("2222");
            allocationModel.Provider.OpenDate.Should().NotBeNull();
            allocationModel.AllocationLine.Id.Should().Be("AAAAA");
            allocationModel.AllocationLine.Name.Should().Be("test allocation line 1");
            allocationModel.ProfilePeriods.Should().HaveCount(1);

            AssertProviderVariationValuesNotSet(allocationModel.Provider.ProviderVariation);
        }
Exemple #11
0
        private AllocationModel createAllocation(CompanyModel company, ProductModel product)
        {
            AllocationModel model = new AllocationModel {
                CompanyId = company.Id,
                ProductId = product.Id
            };

            return(model);
        }
Exemple #12
0
 protected void btnDel_Click(object sender, EventArgs e)
 {
     using (SqlConnection sqlConnection = new SqlConnection(SqlHelper.ConnectionString))
     {
         sqlConnection.Open();
         SqlTransaction sqlTransaction = sqlConnection.BeginTransaction();
         List <string>  list           = new List <string>();
         try
         {
             foreach (GridViewRow gridViewRow in this.gvPurchaseplan.Rows)
             {
                 CheckBox checkBox = gridViewRow.FindControl("cbBox") as CheckBox;
                 if (checkBox != null && checkBox.Checked)
                 {
                     sm_receiveNote  modelByrnId = this.receiveNote.GetModelByrnId(checkBox.ToolTip);
                     OutReserveModel modelByIc   = this.outReserveBll.GetModelByIc(modelByrnId.soId);
                     if (modelByIc != null)
                     {
                         this.outStockBll.DeleteByWhere(sqlTransaction, " where orcode ='" + modelByIc.orcode + "'");
                         this.outReserveBll.Delete(sqlTransaction, modelByIc.orcode);
                     }
                     StorageModel modelBySid = this.storage.GetModelBySid(modelByrnId.stId);
                     if (modelBySid != null)
                     {
                         list.Add(modelBySid.scode);
                     }
                     if (!string.IsNullOrEmpty(modelByrnId.SAllocationId))
                     {
                         AllocationBllAction allocationBllAction = new AllocationBllAction();
                         AllocationModel     allocationModel     = new AllocationModel();
                         allocationModel = allocationBllAction.ReturnAllocatonModel(" aid='" + modelByrnId.SAllocationId + "'");
                         if (allocationModel != null)
                         {
                             allocationBllAction.DelAllocationStockByAcode(sqlTransaction, allocationModel.Acode);
                             allocationBllAction.Delete(sqlTransaction, allocationModel.Acode);
                         }
                     }
                     this.receiveGoods.Delete(sqlTransaction, modelByrnId.rnId);
                     this.receiveNote.Delete(sqlTransaction, modelByrnId.rnId);
                     this.sendNote.UpdateStateNo(sqlTransaction, modelByrnId.snId);
                 }
             }
             if (list.Count != 0)
             {
                 this.storage.DelByTrans(sqlTransaction, list);
             }
             sqlTransaction.Commit();
             this.BindGv();
         }
         catch
         {
             sqlTransaction.Rollback();
             base.RegisterScript("alert('系统提示:\\n\\n对不起撤销失败!');");
         }
     }
 }
Exemple #13
0
        public int Update(SqlTransaction trans, AllocationModel model)
        {
            int num = 0;

            if (model.Acode != "")
            {
                num = AllocationAction.Update(trans, model);
            }
            return(num);
        }
        public object GetExamples()
        {
            AllocationModel allocation = JsonConvert.DeserializeObject <AllocationModel>(Properties.Resources.V2_Sample_Allocation);

            // Provider ID is XML ignored and json ignored, so provider ID does not get set from the value in the resources sample json
            allocation.Provider.ProviderId = allocation.Provider.UkPrn;

            allocation.Provider.ProviderVariation = ProviderVariationExample.GetProviderVariationExample();

            return(allocation);
        }
Exemple #15
0
        public void GetAllocationByAllocationResultId_GivenMajorMinorFeatureToggleOn_ReturnsMajorMinorVersions()
        {
            //Arrange
            string allocationResultId = "12345";

            IHeaderDictionary headerDictionary = new HeaderDictionary
            {
                { "Accept", new StringValues("application/json") }
            };

            HttpRequest request = Substitute.For <HttpRequest>();

            request
            .Headers
            .Returns(headerDictionary);

            PublishedProviderResult publishedProviderResult = CreatePublishedProviderResult();

            IPublishedResultsService resultsService = CreateResultsService();

            resultsService
            .GetPublishedProviderResultByVersionId(Arg.Is(allocationResultId))
            .Returns(publishedProviderResult);

            AllocationsService service = CreateService(resultsService);

            //Act
            IActionResult result = service.GetAllocationByAllocationResultId(allocationResultId, request);

            //Assert
            result
            .Should()
            .BeOfType <ContentResult>();

            ContentResult contentResult = result as ContentResult;

            string id = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{publishedProviderResult.SpecificationId}{publishedProviderResult.ProviderId}{publishedProviderResult.FundingStreamResult.AllocationLineResult.AllocationLine.Id}"));

            AllocationModel allocationModel = JsonConvert.DeserializeObject <AllocationModel>(contentResult.Content);

            allocationModel
            .Should()
            .NotBeNull();

            allocationModel.AllocationMajorVersion.Should().Be(1);
            allocationModel.AllocationMinorVersion.Should().Be(1);

            AssertProviderVariationValuesNotSet(allocationModel.Provider.ProviderVariation);
        }
        public AllocationModel ResetAllocation(AllocationModel objAllocationModel)
        {
            try
            {
                using (AVOAIALifeEntities Context = new AVOAIALifeEntities())
                {
                    List <string> UWNames = objAllocationModel.objUWdetails.Where(a => a.IsChecked == true).Select(a => a.UWName).ToList();
                    if (UWNames != null)
                    {
                        string UserInfo = string.Empty;
                        #region Coma Seperated User Ids

                        int Count = 0;
                        foreach (string Userid in Context.AspNetUsers.Where(a => UWNames.Contains(a.UserName)).Select(a => a.Id).ToList())
                        {
                            if (Count == 0)
                            {
                                UserInfo = Userid;
                            }
                            else
                            {
                                UserInfo = "," + Userid;
                            }
                            Count++;
                        }
                        #endregion


                        var idParam = new SqlParameter
                        {
                            ParameterName = "UserId",
                            Value         = UserInfo
                        };


                        var Result = Context.Database.SqlQuery <string>(
                            "exec usp_UnAllocateProposals @UserId ", idParam).FirstOrDefault();
                    }
                }
                objAllocationModel.Message = "Success";
            }
            catch (Exception ex)
            {
                log4net.GlobalContext.Properties["ErrorCode"] = Codes.GetErrorCode();
                Logger.Error(ex);
                objAllocationModel.Message = "Error";
            }
            return(objAllocationModel);
        }
Exemple #17
0
 public void SuperDelete(object key)
 {
     using (SqlConnection connection = new SqlConnection(SqlHelper.ConnectionString))
     {
         connection.Open();
         SqlTransaction trans          = connection.BeginTransaction();
         List <string>  lstStorageCode = new List <string>();
         try
         {
             sm_receiveNote  modelByrnId = this.receiveNote.GetModelByrnId(key.ToString());
             OutReserveModel modelByIc   = this.outReserveBll.GetModelByIc(modelByrnId.soId);
             if (modelByIc != null)
             {
                 this.outStockBll.DeleteByWhere(trans, " where orcode ='" + modelByIc.orcode + "'");
                 this.outReserveBll.Delete(trans, modelByIc.orcode);
             }
             StorageModel modelBySid = this.storage.GetModelBySid(modelByrnId.stId);
             if (modelBySid != null)
             {
                 lstStorageCode.Add(modelBySid.scode);
             }
             if (!string.IsNullOrEmpty(modelByrnId.SAllocationId))
             {
                 AllocationBllAction action = new AllocationBllAction();
                 AllocationModel     model3 = new AllocationModel();
                 model3 = action.ReturnAllocatonModel(" aid='" + modelByrnId.SAllocationId + "'");
                 if (model3 != null)
                 {
                     action.DelAllocationStockByAcode(trans, model3.Acode);
                     action.Delete(trans, model3.Acode);
                 }
             }
             this.receiveGood.Delete(trans, modelByrnId.rnId);
             this.receiveNote.Delete(trans, modelByrnId.rnId);
             this.sendnote.UpdateStateNo(trans, modelByrnId.snId);
             if (lstStorageCode.Count != 0)
             {
                 this.storage.DelByTrans(trans, lstStorageCode);
             }
             trans.Commit();
         }
         catch
         {
             trans.Rollback();
             base.RegisterScript(@"alert('系统提示:\n\n对不起撤销失败!');");
         }
     }
 }
Exemple #18
0
        public IActionResult GetAllocationByAllocationResultId(string allocationResultId, HttpRequest httpRequest)
        {
            Guard.IsNullOrWhiteSpace(allocationResultId, nameof(allocationResultId));
            Guard.ArgumentNotNull(httpRequest, nameof(httpRequest));

            PublishedProviderResult publishedProviderResult = _publishedResultsService.GetPublishedProviderResultByVersionId(allocationResultId);

            if (publishedProviderResult == null)
            {
                return(new NotFoundResult());
            }

            AllocationModel allocation = CreateAllocation(publishedProviderResult);

            return(Formatter.ActionResult <AllocationModel>(httpRequest, allocation));
        }
        public AllocationModel LoadAllocationDetails(AllocationModel objAllocationModel)
        {
            try
            {
                using (AVOAIALifeEntities Context = new AVOAIALifeEntities())
                {
                    string RoleID  = Context.AspNetRoles.Where(a => a.Name == "UW User").FirstOrDefault().Id;
                    var    idParam = new SqlParameter
                    {
                        ParameterName = "@RoleId",
                        Value         = RoleID
                    };
                    List <string> UserIDs = Context.Database.SqlQuery <string>(
                        "exec GetUsersByRoleId @RoleId", idParam).ToList();

                    if (UserIDs != null)
                    {
                        objAllocationModel.objUWdetails = (from aspnetusers in Context.AspNetUsers.Where(a => UserIDs.Contains(a.Id))
                                                           join userdetails in Context.tblUserDetails
                                                           on aspnetusers.UserName equals userdetails.LoginID
                                                           select new UWDetails
                        {
                            UWName = aspnetusers.UserName,
                            ID = aspnetusers.Id,
                            Availabiliy = false
                        }).ToList();
                    }
                    objAllocationModel.objChannelDetails = (from objchannel in Context.tblmasChannels
                                                            select new ChannelDetails
                    {
                        ChannelName = objchannel.ChannelName,
                        ChannelId = objchannel.ChannelID,
                        Availabiliy = false
                    }).ToList();

                    objAllocationModel.Message = "Success";
                    return(objAllocationModel);
                }
            }
            catch (Exception ex)
            {
                log4net.GlobalContext.Properties["ErrorCode"] = Codes.GetErrorCode();
                Logger.Error(ex);
                objAllocationModel.Message = "Error";
                return(objAllocationModel);
            }
        }
Exemple #20
0
        // GET: Project/Create
        public ActionResult Create()
        {
            AllocationModel project = new AllocationModel
            {
                AllocationStartDate    = DateTime.Now,
                AllocationEndDate      = DateTime.Now,
                PercentageOfAllocation = 100
            };

            try
            {
                InitializePageData();
            }
            catch (Exception exp)
            {
                DisplayLoadErrorMessage(exp);
            }

            return(View(project));
        }
Exemple #21
0
        public AllocationModel ReturnAllocatonModel(string strWhere)
        {
            AllocationModel model          = new AllocationModel();
            DataTable       allocationList = new DataTable();

            allocationList = AllocationAction.GetAllocationList(strWhere);
            if (allocationList.Rows.Count > 0)
            {
                model.Aid                 = allocationList.Rows[0]["aid"].ToString();
                model.Acode               = allocationList.Rows[0]["acode"].ToString();
                model.TCodea              = allocationList.Rows[0]["tcodea"].ToString();
                model.TCodeb              = allocationList.Rows[0]["tcodeb"].ToString();
                model.IsOutA              = Convert.ToBoolean(allocationList.Rows[0]["isouta"].ToString());
                model.IsInB               = Convert.ToBoolean(allocationList.Rows[0]["isinb"].ToString());
                model.Person              = allocationList.Rows[0]["person"].ToString();
                model.InTime              = allocationList.Rows[0]["intime"].ToString();
                model.Explain             = allocationList.Rows[0]["explain"].ToString();
                model.OutAllocationPerson = allocationList.Rows[0]["OutAllocationPerson"].ToString();
                model.InAllocationPerson  = allocationList.Rows[0]["InAllocationPerson"].ToString();
            }
            return(model);
        }
        private bool IsValidAllocation(AllocationModel allocation)
        {
            ProjectDto project = projectService.GetByID(allocation.ProjectID);

            if (allocation.AllocationTypeID == 4 &&
                (project.ProjectName.ToLower().Contains("lab") || project.ProjectName.ToLower().Contains("management")))
            {
                DisplayWarningMessage("An employee can't be allocated with a billable position for the Management/Lab project");
                return(false);
            }

            if (allocation.AllocationStartDate < project.StartDate)
            {
                DisplayWarningMessage("Allocation Start Date should be equal to or above the Project Start Date");
                return(false);
            }

            if (allocation.AllocationEndDate > project.EndDate)
            {
                DisplayWarningMessage("Allocation End Date should be within the Project End Date");
                return(false);
            }

            if (allocation.AllocationEndDate < allocation.AllocationStartDate || allocation.AllocationEndDate < project.StartDate)
            {
                DisplayWarningMessage("Allocation End Date should be within the range of Project Start & End Dates");
                return(false);
            }

            EmployeeDto emp = empService.GetEmployee(allocation.EmployeeID);

            if (allocation.AllocationStartDate < emp.DateOfJoin)
            {
                DisplayWarningMessage($"Selected Employee's DoJ is {emp.DateOfJoin.ToString("MM/dd/yyyy")}. Allocation Start Date should be above that");
                return(false);
            }

            return(true);
        }
Exemple #23
0
        public int InDepositoryConfirm(string acode, string yhdm)
        {
            DataTable         table = AllocationAction.GetAllocation_StockList("sma.acode='" + acode + "' and flowstate=1 and isouta=1 ");
            int               num   = 0;
            TreasuryPermitBll bll   = new TreasuryPermitBll();
            AllocationModel   model = new AllocationModel();

            model = this.ReturnAllocatonModel(" acode='" + acode + "' ");
            if (!bll.IsPermitAccept(model.Acode, yhdm))
            {
                return(0);
            }
            if (table.Rows.Count > 0)
            {
                TreasuryStock      stock  = new TreasuryStock();
                TreasuryStockModel model2 = new TreasuryStockModel();
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    model2.corp    = table.Rows[i]["corp"].ToString();
                    model2.incode  = acode;
                    model2.intime  = DateTime.Now;
                    model2.intype  = 0;
                    model2.Type    = "A";
                    model2.isfirst = false;
                    model2.scode   = table.Rows[i]["scode"].ToString();
                    model2.snumber = decimal.Parse(table.Rows[i]["number"].ToString());
                    model2.sprice  = decimal.Parse(table.Rows[i]["sprice"].ToString());
                    model2.tcode   = table.Rows[i]["tcodeb"].ToString();
                    model2.tsid    = Guid.NewGuid().ToString();
                    if (stock.Add(model2) <= 0)
                    {
                        return(-1);
                    }
                    AllocationAction.UpdateState(true, true, acode, "In");
                    num = 1;
                }
            }
            return(num);
        }
Exemple #24
0
        public ActionResult Create(AllocationModel allocation)
        {
            try
            {
                InitializePageData();

                if (ModelState.IsValid)
                {
                    if (IsValidAllocation(allocation) == false)
                    {
                        return(View(allocation));
                    }

                    if (allocation.AllocationEndDate <= allocation.AllocationStartDate)
                    {
                        DisplayWarningMessage("The End date should be greater than the Start date");
                        return(View(allocation));
                    }

                    if (allocationService.AnyActiveAllocationInBenchProject(allocation.EmployeeID))
                    {
                        DisplayWarningMessage("There is an active allocation in Bench project for this employee. Please end the allocation for that project.");
                        return(View(allocation));
                    }

                    ProjectAllocationDto projectDto = Mapper.Map <AllocationModel, ProjectAllocationDto>(allocation);
                    allocationService.Add(projectDto);
                    DisplaySuccessMessage($"New project allocation has been created for {allocation.EmployeeName}");
                    return(RedirectToAction("List"));
                }
            }
            catch (Exception exp)
            {
                DisplayUpdateErrorMessage(exp);
            }
            return(View(allocation));
        }
Exemple #25
0
    protected void ShowAllocationData()
    {
        AllocationBllAction allocationBllAction = new AllocationBllAction();
        AllocationModel     allocationModel     = new AllocationModel();

        allocationModel                  = allocationBllAction.ReturnAllocatonModel("acode='" + ((base.Request.QueryString["ac"] == "") ? "0" : base.Request.QueryString["ac"]) + "' ");
        this.lblAllocationNo.Text        = allocationModel.Acode;
        this.txtOutDepository.Text       = allocationBllAction.GetTreasuryNameByCode(allocationModel.TCodea).Rows[0][0].ToString();
        this.HdnSelectOutDepo.Value      = allocationModel.TCodea;
        this.txtInDepository.Text        = allocationBllAction.GetTreasuryNameByCode(allocationModel.TCodeb).Rows[0][0].ToString();
        this.HdnIsTotal.Value            = allocationBllAction.GetTreasuryNameByCode(allocationModel.TCodea).Rows[0][1].ToString();
        this.HdnSecTotal.Value           = allocationBllAction.GetTreasuryNameByCode(allocationModel.TCodea).Rows[0][1].ToString();
        this.HdnSelectInDepo.Value       = allocationModel.TCodeb;
        this.txtInDate.Text              = allocationModel.InTime;
        this.txtOutAllocationPerson.Text = allocationBllAction.GetUserNameByCode(allocationModel.OutAllocationPerson);
        this.HdnSelectOutPer.Value       = allocationModel.OutAllocationPerson;
        this.txtInAllocationPerson.Text  = allocationBllAction.GetUserNameByCode(allocationModel.InAllocationPerson);
        this.HdnSelectInPer.Value        = allocationModel.InAllocationPerson;
        this.txtRemark.Text              = allocationModel.Explain;
        this.hdGuid.Value                = allocationModel.Aid;
        DataTable allocationStockList = allocationBllAction.GetAllocationStockList(allocationModel.TCodea, "acode='" + allocationModel.Acode + "'");

        if (allocationStockList != null && allocationStockList.Rows.Count > NBasePage.pagesize)
        {
            this.HdnIsPage.Value = "1";
        }
        this.ViewState["DataTable"] = allocationStockList;
        if (allocationStockList.Rows.Count > 0)
        {
            Common2.BindGvTable(allocationStockList, this.GVMaterialList, false);
            string total = Convert.ToDecimal(allocationStockList.Compute("SUM(Total)", string.Empty)).ToString("0.000");
            GridViewUtility.AddTotalRow(this.GVMaterialList, total, 12);
            return;
        }
        this.GVMaterialList.DataSource = allocationStockList;
        this.GVMaterialList.DataBind();
    }
Exemple #26
0
        private AllocationModel GetAllocationData()
        {
            AllocationModel model = new AllocationModel {
                Aid = Guid.NewGuid().ToString()
            };

            this.ReceiveNoteModel.SAllocationId = model.Aid;
            model.Acode               = DateTime.Now.ToString("yyyyMMddHHmmss");
            this.Acode                = model.Acode;
            model.Annex               = "";
            model.Explain             = "";
            model.FlowState           = 1;
            model.InAllocationPerson  = this.sendNoteMdoleInfo.snAddUser;
            model.OutAllocationPerson = this.ReceiveNoteModel.rnUser;
            model.Person              = this.sendNoteMdoleInfo.snAddUser;
            model.TCodea              = new cn.justwin.stockBLL.Treasury().GetTotalCode();
            model.TCodeb              = this.TreasuryCode;
            model.InTime              = DateTime.Now.ToShortDateString();
            model.IsOutA              = true;
            model.IsInB               = true;
            model.IsOutTime           = DateTime.Now.ToString();
            model.IsInTime            = DateTime.Now.ToString();
            return(model);
        }
        public AllocationModel ResetAllocation(AllocationModel objAllocationModel)
        {
            AllocationLogic objLogic = new AllocationLogic();

            return(objLogic.ResetAllocation(objAllocationModel));
        }
Exemple #28
0
        public object GetExamples()
        {
            AllocationModel allocation = JsonConvert.DeserializeObject <AllocationModel>(Properties.Resources.V1_Sample_Allocation);

            return(allocation);
        }
        public AllocationModel SaveAllocation(AllocationModel objAllocationModel)
        {
            AllocationLogic objLogic = new AllocationLogic();

            return(objLogic.SaveAllocation(objAllocationModel));
        }
        //AllocationModel.AllocationCount : Number of Allocations
        //AllocationModel.AllocationSize : Size of individual allocation
        //AllocationModel.DelayBetweenAllocations : Put n miliseconds delay between each allocation.
        //AllocationModel.AllocType : Type of the allocation. (String = 0,Char = 1,Integer = 2)
        //AllocationModel.AfterAlloc :  Shall we root the objects? (DontRootObjects = 0,RootObjects = 1)
        public string Alloc(AllocationModel _model)
        {
            string return_results = "";
            char   newAllocChar   = '@';

            int i, j;

            if (_model.AfterAlloc == AfterAllocation.RootObjects)
            {
                for (j = 0; j < _model.AllocationCount; j++)
                {
                    switch (_model.AllocType)
                    {
                    case AllocationType.String:
                        string new_str = new string(newAllocChar, _model.AllocationSize);
                        allocationRoot.Add(rootKeyIndex++, new_str);
                        break;

                    case AllocationType.Char:
                        char[] newAllocArr = new char[_model.AllocationSize];
                        for (i = 0; i < _model.AllocationSize; i++)
                        {
                            newAllocArr[i] = (char)Byte.Parse((i % 256).ToString());
                        }
                        allocationRoot.Add(rootKeyIndex++, newAllocArr);
                        break;

                    case AllocationType.Integer:
                        allocationRoot.Add(rootKeyIndex++, new int[_model.AllocationSize]);
                        break;

                    default:
                        break;
                    }
                    ;
                }
            }
            else if (_model.AfterAlloc == AfterAllocation.DontRootObjects)
            {
                for (j = 0; j < _model.AllocationCount; j++)
                {
                    switch (_model.AllocType)
                    {
                    case AllocationType.String:
                        string new_str = new string(newAllocChar, _model.AllocationSize);
                        break;

                    case AllocationType.Char:
                        char[] newAllocArr = new char[_model.AllocationSize];
                        newAllocArr = new char[_model.AllocationSize];
                        for (i = 0; i < _model.AllocationSize; i++)
                        {
                            newAllocArr[i] = (char)Byte.Parse((i % 256).ToString());
                        }
                        break;

                    case AllocationType.Integer:
                        int[] new_IntArr = new int[_model.AllocationSize];
                        break;

                    default:
                        break;
                    }
                    ;
                }
            }
            else
            {
                return_results = "Incorrect Parameters";
            }
            return_results = "\nAllocated " + _model.AllocType.ToString() + " number of " + _model.AllocType.ToString() + "objects. Root Key Index is now: " + rootKeyIndex.ToString();

            return(return_results);
        }