Ejemplo n.º 1
0
        public PurchaseRequest CreateNewPr(PurchaseRequest pr, string userName)
        {
            DateTime dt = DateTime.Now;

            Data.Models.PurchaseRequestModel.Add(pr, userName);

            var e = Data.Models.EmployeeModel.FindByUserId(userName);

            Workflow wf = new Workflow
             {
                 DateTime = dt,
                 ProcessTypeEnum = ProcessTypeEnum.PurchaseRequest,
                 ProcessStateEnum =ProcessStateEnum.DraftByRequestor,
                 //UserName = userName,
                 //Employee = e,
                 EmployeeId = e.Id,
                 EmployeePtjCode = e.PtjCode,
                  EmployeeUserName = e.UserId,
                   EmployeeFullName = e.FullName,
                 Description = "",
                 ProcessId = pr.Id,
             };
            Data.Models.WorkflowModel.Add(wf, userName);
            return pr;
        }
Ejemplo n.º 2
0
        public PurchaseRequest UpdatePrState(PurchaseRequest pr, ProcessStateEnum e, string detail, string userName)
        {
            pr.Status = e;
            if (e == ProcessStateEnum.SubmittedByRequestor)
            {
                if ((0 >= pr.TotalPrice) && (pr.TotalPrice <= 100000))
                {
                    pr.ProcessCategory = ProcessDetailCategory.PrValueUnder1k;
                    var pcs = Data.Models.ChecklistModel.FindAllByProcessCategory(pr.ProcessCategory);
                    foreach (var pc in pcs)
                    {
                        //Data.Models
                    }
                    //pr.Checklist.Add(pc);
                }
                if ((100000 > pr.TotalPrice) && (pr.TotalPrice <= 2000000))
                {
                    pr.ProcessCategory = ProcessDetailCategory.PrValueUnder20k;
                    var pcs = Data.Models.ChecklistModel.FindAllByProcessCategory(pr.ProcessCategory);
                    foreach (var pc in pcs)
                    {
                        //Data.Models
                    }
                        //pr.Checklist.Add(pc);
                }
                if ((2000000 > pr.TotalPrice) && (pr.TotalPrice <= 5000000))
                {
                    pr.ProcessCategory = ProcessDetailCategory.PrValueBetweek20kTo50k;
                }
                if (pr.TotalPrice > 5000000)
                {
                    pr.ProcessCategory = ProcessDetailCategory.PrValueMoreThan50k;
                }
            }
            Data.Models.PurchaseRequestModel.AddOrUpdate(pr, userName);
            Employee employee = Data.Models.EmployeeModel.FindByUserId(userName);
            Workflow wf = new Workflow
            {
                DateTime = DateTime.Now,
                ProcessTypeEnum = ProcessTypeEnum.PurchaseRequest,
                ProcessStateEnum = pr.Status,
                //UserName = userName,
                //Employee = employee,
                EmployeeFullName = employee.FullName,
                EmployeeUserName = employee.UserId,
                EmployeePtjCode = employee.PtjCode,
                EmployeeId = employee.Id,
                Description = "",
                ProcessId = pr.Id,
            };
            Data.Models.WorkflowModel.Add(wf, userName);

            return pr;
        }
        void SaveSubmitCancelPRMode(int Mode)
        {
            FormsIdentity id = (FormsIdentity)HttpContext.Current.User.Identity;
            FormsAuthenticationTicket ticket = id.Ticket;

            if (ticket.Expired)
            {
                cbp_PermohonanBelian_PrHeader.JSProperties["cpErrMsg"] = "Session Expired.";
                return;
            }

            string DbErr = string.Empty;

            try
            {
                Data.Entity.PurchaseRequest pr = new Data.Entity.PurchaseRequest
                {
                    RequestorId = Data.Models.EmployeeModel.FindByUserId(ticket.Name).Id,
                    Description = PRH_Purpose.Text.Trim(),
                    Instruction = PRH_DeliveryInstruction.Text.Trim(),
                    ProcurementCategoryId = PRH_ProcurementCatId.Value.ToString(),
                    ProcurementMethodId = PRH_ProcurementMethodId.Value.ToString(),
                    ProcurementTypeId = PRH_ProcurementITypeId.Value.ToString(),
                    SupplierId = PRH_SupplierCode.Value.ToString(),
                    RequestDate = deRequestDate.Date,
                    RequiredDate = deRequriredDate.Date

                };

                _prSvc.CreateNewPr(pr, ticket.Name);

                cbp_PermohonanBelian_PrHeader.JSProperties["cpReturnProcessId"] = pr.ProcessId;
                cbp_PermohonanBelian_PrHeader.JSProperties["cpReturnRevNumber"] = pr.RevisionNumber.ToString();
                cbp_PermohonanBelian_PrHeader.JSProperties["cpReturnPurchaseRequestId"] = pr.Id.ToString();
                cbp_PermohonanBelian_PrHeader.JSProperties["cpErrMsg"] = DbErr;
            }
            catch (Exception err)
            {
                cbp_PermohonanBelian_PrHeader.JSProperties["cpErrMsg"] = err.Message;
            }
            finally
            { }
        }