Ejemplo n.º 1
0
        public List<WFResolution> GetListByRoleAndResolutionUS(PurchaseRequest obj)
        {
            if (!obj.AssignRole.HasValue)
                return new List<WFResolution>();
            var list = GetListResolutionChangeByRole(obj.AssignRole.Value);
            if (obj.AssignRole == Constants.PR_REQUESTOR_ID_US)
            {
                if (obj.WFResolutionID == Constants.PRUS_RESOLUTION_REJECTED_TO_REQUESTOR)//case PR Reject
                {
                    list = list.Where(p => p.ID != Constants.PRUS_RESOLUTION_REJECTED_TO_CORP_CTRLER).ToList<WFResolution>();
                }
                else if (obj.WFResolutionID == Constants.PRUS_RESOLUTION_REJECTED_TO_DEPT_HEAD)
                {
                    list = list.Where(p => p.ID != Constants.PRUS_RESOLUTION_NEW &&
                      p.ID != Constants.PRUS_RESOLUTION_CANCELLED).ToList<WFResolution>();
                }
                else if (obj.WFResolutionID == Constants.PRUS_RESOLUTION_NEW)
                {
                    list = list.Where(p => p.ID != Constants.PR_RESOLUTION_REJECT
                      && p.ID != Constants.PRUS_RESOLUTION_REJECTED_TO_CORP_CTRLER &&
                      p.ID != Constants.PRUS_RESOLUTION_CANCELLED).ToList<WFResolution>();
                }
                else
                {
                    list = list.Where(p => p.ID != Constants.PRUS_RESOLUTION_CANCELLED
                        && p.ID != Constants.PRUS_RESOLUTION_REJECTED_TO_CORP_CTRLER).ToList<WFResolution>();
                }
            }
            else if (obj.AssignRole == Constants.PR_PURCHASING_ID_US)
            {
                if (obj.WFResolutionID == Constants.PRUS_RESOLUTION_REJECTED_TO_DEPT_HEAD)
                {
                    list = list.Where(p => p.ID == Constants.PRUS_RESOLUTION_WAITING_FOR_CORP_CTRLER_APPROVAL
                        || p.ID == Constants.PRUS_RESOLUTION_REJECTED_TO_REQUESTOR
                        || p.ID == Constants.PRUS_RESOLUTION_CANCELLED).ToList<WFResolution>();
                }
                else if (obj.WFResolutionID == Constants.PRUS_RESOLUTION_TO_BE_PROCESSED)
                {
                    list = list.Where(p => p.ID == Constants.PRUS_RESOLUTION_TO_BE_PROCESSED).ToList<WFResolution>();
                }
                else
                {
                    //case Requestor send PR to Group Purchasing
                    list = list.Where(p => p.ID == Constants.PRUS_RESOLUTION_WAITING_FOR_DEPT_HEAD_APPROVAL
                        || p.ID == Constants.PRUS_RESOLUTION_REJECTED_TO_REQUESTOR
                        || p.ID == Constants.PR_RESOLUTION_REJECT).ToList<WFResolution>();
                }
            }
            else
            {
                list = new List<WFResolution>();
                list.Add(obj.WFResolution);
            }

            return list;
        }
Ejemplo n.º 2
0
 // Methods
 override public void ProcessRequest( 
                           PurchaseRequest request )
 {
   if( request.Amount < 25000.0 )
     Console.WriteLine( "{0} {1} approved request# {2}", 
       this, name, request.Number);
   else
     if( successor != null )
       successor.ProcessRequest( request );
 }
Ejemplo n.º 3
0
 // Methods
 override public void ProcessRequest( 
                             PurchaseRequest request )
 {
   if( request.Amount < 100000.0 )
     Console.WriteLine( "{0} {1} approved request# {2}", 
       this, name, request.Number);
   else
     Console.WriteLine( "Request# {0} requires " +
       "an executive meeting!", request.Number );
 }
Ejemplo n.º 4
0
        private void btnRegistrarSolicitudCompra_Click(object sender, EventArgs e)
        {
            List <dynamic> lst = items.Select(x => new
            {
                idProduct             = x.idProduct,
                weight                = x.weight,
                remark                = x.remark,
                requiresRefrigeration = x.requieresRefrigerationBool
            }).Cast <dynamic>().ToList();

            //var lst1 = lst.Where(x => x.requieresRefrigeration == "Si").ToList();

            if (lst.Count == 0)
            {
                string text  = "Debe agregar productos para realizar esta acción";
                string title = "Información";
                MessageBox.Show(text, title, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                string token    = Session.Token;
                int    idClient = Session.IdProfile;

                dynamic objectAPI = new System.Dynamic.ExpandoObject();

                objectAPI.desiredDate = Convert.ToDateTime(dtpFechaDeseadaEntrega.Value);
                //objectAPI.pruebaDate =  DateTime.UtcNow.Subtract(new DateTime(dtpFechaDeseadaEntrega.Value,DateTimeKind.Utc)).TotalMilliseconds;
                objectAPI.idClient = idClient;
                objectAPI.idPurchaseRequestType   = 1;
                objectAPI.purchaseRequestProducts = lst;



                var createNewPurchaseRequest = VirtualFairIntegration.CreateNewPurchaseRequest(token, objectAPI);

                if (createNewPurchaseRequest.statusCode == 200)
                {
                    string text  = "Se deben completar todos los campos requeridos";
                    string title = "Información";
                    MessageBox.Show(text, title, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (createNewPurchaseRequest.statusCode == 201)
                {
                    string text  = createNewPurchaseRequest.message;
                    string title = "Información";
                    MessageBox.Show(text, title, MessageBoxButtons.OK, MessageBoxIcon.Information);

                    this.Hide();

                    var solicitudCompra = new PurchaseRequest();
                    solicitudCompra.Show();
                }
            }
        }
Ejemplo n.º 5
0
 public override void ProcessRequest(PurchaseRequest request)
 {
     if (request.Amount < 50000)
     {
         System.Console.WriteLine("Director {0} approve purchase request: {1}, Amount: {2}, purpose: {3}.", Name, request.Number, request.Amount, request.Purpose);
     }
     else
     {
         this.Successor.ProcessRequest(request);
     }
 }
Ejemplo n.º 6
0
        public void addPurchaseRequest(string name, int price, int quantity)
        {
            PurchaseRequest pr = new PurchaseRequest();

            pr.ItemName     = name;
            pr.ItemPrice    = price;
            pr.ItemQuantity = quantity;
            pr.Deleted      = 0;
            db.PurchaseRequest.Add(pr);
            db.SaveChanges();
        }
Ejemplo n.º 7
0
 public override void ProcessRequest(PurchaseRequest request)
 {
     if (request.Amount < 25000.0)
     {
         Console.WriteLine("{0}-{1} approved the request of purshing {2}", this, Name, request.ProductName);
     }
     else if (NextApprover != null)
     {
         NextApprover.ProcessRequest(request);
     }
 }
Ejemplo n.º 8
0
 public override void ProcessRequest(PurchaseRequest request)
 {
     if (request.Amount < 100000.0)
     {
         Console.WriteLine("{0}-{1} approved the request of purshing {2}", this, Name, request.ProductName);
     }
     else
     {
         Console.WriteLine("Request需要组织一个会议讨论");
     }
 }
        public static PurchaseRequest create(int departmentID, string information)
        {
            PurchaseRequest p = new PurchaseRequest();

            p.DepartmentId = departmentID;
            p.Information  = information;
            p.Date         = DateTime.Now;
            p.Status       = "Pending";
            p.Note         = "";
            return(p);
        }
Ejemplo n.º 10
0
 public IActionResult Purchase([FromBody] PurchaseRequest request)
 {
     try
     {
         var result = productsService.Purchase(request.ProductType, request.Coins.ToList());
         return(new OkObjectResult(new PurchaseResponse(result, productsService.GetProducts())));
     }
     catch (ArgumentException ex)
     {
         return(new BadRequestObjectResult(new ValidationError(ex.Message)));
     }
 }
Ejemplo n.º 11
0
        public void WhenPurchaseAnItem()
        {
            var requestBody = new PurchaseRequest
            {
                Item          = "m",
                PaymentTypeId = "adyenEPS",
                Cuntry        = "AT",
                LandingUrl    = "https://www.gametwist.com/en/?modal=shop"
            };

            PostRequestPurchase(requestBody);
        }
Ejemplo n.º 12
0
        public List<WFResolution> GetListByRoleAndResolution(PurchaseRequest obj)
        {
            if (!obj.AssignRole.HasValue)
                return new List<WFResolution>();
            var list = GetListResolutionChangeByRole(obj.AssignRole.Value);
            if (obj.AssignRole == Constants.PR_REQUESTOR_ID)
            {
                if (obj.WFResolutionID == Constants.PR_RESOLUTION_REJECT)//case PR Reject
                {
                    list = list.Where(p => p.ID != Constants.PR_RESOLUTION_NEW_ID &&
                        p.ID != Constants.PR_RESOLUTION_SR_MANAGER_REJECT_TO_REQUESTOR).ToList<WFResolution>();
                }
                else if (obj.WFResolutionID == Constants.PR_RESOLUTION_SR_MANAGER_REJECT_TO_REQUESTOR)
                {
                    list = list.Where(p => p.ID != Constants.PR_RESOLUTION_NEW_ID &&
                        p.ID != Constants.PR_RESOLUTION_REJECT).ToList<WFResolution>();
                }
                else if (obj.WFResolutionID == Constants.PR_RESOLUTION_NEW_ID)
                {
                    list = list.Where(p => p.ID != Constants.PR_RESOLUTION_REJECT
                      && p.ID != Constants.PR_RESOLUTION_SR_MANAGER_REJECT_TO_REQUESTOR &&
                      p.ID != Constants.PR_RESOLUTION_CANCEL).ToList<WFResolution>();
                }
                else
                {
                    list = list.Where(p => p.ID != Constants.PR_RESOLUTION_REJECT
                        && p.ID != Constants.PR_RESOLUTION_SR_MANAGER_REJECT_TO_REQUESTOR).ToList<WFResolution>();
                }
            }
            else if (obj.AssignRole == Constants.PR_PURCHASING_ID)
            {
                if (obj.WFResolutionID == Constants.PR_RESOLUTION_SR_MANAGER_REJECT_TO_PURCHASING)
                {
                    list = list.Where(p =>  p.ID == Constants.PR_RESOLUTION_TO_BE_APPROVED_BY_SR_MANAGER
                        || p.ID == Constants.PR_RESOLUTION_SR_MANAGER_REJECT_TO_PURCHASING
                        || p.ID == Constants.PR_RESOLUTION_REJECT).ToList<WFResolution>();
                }
                else
                {
                    //case Requestor send PR to Group Purchasing
                    list = list.Where(p => p.ID == Constants.PR_RESOLUTION_TO_BE_APPROVED_BY_PURCHASING
                        || p.ID == Constants.PR_RESOLUTION_TO_BE_APPROVED_BY_SR_MANAGER
                        || p.ID == Constants.PR_RESOLUTION_REJECT).ToList<WFResolution>();
                }
            }
            else
            {
                list = new List<WFResolution>();
                list.Add(obj.WFResolution);
            }

            return list;
        }
        public PurchaseResponse MakePurchase(PurchaseRequest purchaseRequest)
        {
            var purchaseResponse = new PurchaseResponse
                                       {
                                           CustomerId = purchaseRequest.CustomerId,
                                           Price = 100,
                                           Message = "Response",
                                           Visits = 10
                                       };

            var streamWriter = new StreamWriter(@"C:\Temp\WS.log", true);
            streamWriter.WriteLine(DateTime.Now + " " + purchaseRequest.CustomerId);
            streamWriter.Close();
            return purchaseResponse;
        }
Ejemplo n.º 14
0
        public static void Main(string[] args)
        {
            // https://developer.mastercard.com/portal/display/api/Software+Development+Kit
            // http://newsroom.mastercard.com/2014/07/11/masterpass-continues-global-expansion-product-enhancements-planned-for-august/

            {
                //FullName = System.Reflection.TargetInvocationException, InnerException = System.IO.FileNotFoundException: The JVM/ CLR feature is not available within this build.

                System.Console.WriteLine(
                   typeof(object).AssemblyQualifiedName
                );

                // jsc java natives/ where is the ctor we think of?
                PaymentClient client = new PaymentClient(getPrivateKey(), "my-client-id", false);
                PurchaseRequest purchaseRequest = new PurchaseRequest();

                Amount amount = new Amount();
                amount.setCurrency("GBP");
                amount.setValue(new BigInteger("441250"));
                purchaseRequest.setAmount(amount);

                MerchantIdentity merchantIdentity = new MerchantIdentity();
                merchantIdentity.setClientId("my-merchant-id");
                merchantIdentity.setPassword("my-merchant-password");

                purchaseRequest.setMerchantIdentity(merchantIdentity);
                purchaseRequest.setClientReference(getClientReference());

                Card card = new Card();
                card.setAccountNumber("6XXXXXXXXXXXXXXX");
                card.setExpiryMonth("01");
                card.setExpiryYear("11");
                card.setSecurityCode("111");

                purchaseRequest.setFundingCard(card);

                Purchase purchase = client.createPurchase(purchaseRequest);

                CLRProgram.CLRMain();
            }


        }
        public Error Validate(PurchaseRequest request)
        {
            if(!purchaseRepository.IsValidCustomer(request.customerId))
            {
                return new Error
                    {
                        Code = "1001",
                        Message = "Invalid Customer Id"
                    };
            }

            if(!purchaseRepository.IsValidProduct(request.productId))
            {
                return new Error
                           {
                               Code = "1002",
                               Message = "Invalid Product Id"
                           };
            }

            return null;
        }
Ejemplo n.º 16
0
 public bool IsInCCList(PurchaseRequest pr, string loginName)
 {
     int? result = dbContext.check_in_list_string(pr.CCList, loginName, Constants.SEPARATE_USER_ADMIN_USERNAME);
     return result.HasValue ? result.Value == 1 ? true : false : false;
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Delete purchase request
 /// </summary>
 /// <param name="objUI">PurchaseRequest</param>
 private void Delete(PurchaseRequest objUI)
 {
     if (objUI != null)
     {
         // Get current group in dbContext
         PurchaseRequest objDb = GetByID(objUI.ID);
         if (objDb != null)
         {
             // Set delete info
             objDb.DeleteFlag = true;
             objDb.UpdateDate = DateTime.Now;
             objDb.UpdatedBy = objUI.UpdatedBy;
             // Submit changes to dbContext
             dbContext.SubmitChanges();
         }
     }
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Write Insert Log For Employee
        /// </summary>
        /// <param name="objInfo"></param>
        /// <param name="logId"></param>
        public bool WriteLogForSetUpApproval(PurchaseRequest newInfo, List<PurchaseRequestApproval> listApproval, bool insertApproval)
        {
            bool isUpdated = false;
            try
            {
                MasterLog objMasterLog = new MasterLog();

                string logId = commonDao.UniqueId;

                commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.PurchaseRequest.ToString(), ELogAction.Update.ToString());
                // Get old info
                PurchaseRequest oldInfo = new PurchaseRequestDao().GetByID(newInfo.ID);

                if ((oldInfo != null) && (newInfo != null) && (logId != null))
                {
                    if (newInfo.WFResolutionID != oldInfo.WFResolutionID)
                    {
                        commonDao.InsertLogDetail(logId, "WFResolutionID", "Resolution", oldInfo.WFResolution.Name, new ResolutionDao().GetByID(newInfo.WFResolutionID).Name);
                        isUpdated = true;
                    }
                    if (newInfo.WFStatusID != oldInfo.WFStatusID)
                    {
                        commonDao.InsertLogDetail(logId, "WFStatusID", "Status", oldInfo.WFStatus.Name, new StatusDao().GetByID(newInfo.WFStatusID).Name);
                        isUpdated = true;
                    }
                    if (insertApproval)
                    {
                        foreach (PurchaseRequestApproval item in listApproval)
                        {
                            commonDao.InsertLogDetail(logId, "Approval", "Approval", string.Empty, new UserAdminDao().GetById(item.ApproverId).UserName +
                                " (" + new RoleDao().GetByID(item.ApproverGroup).Name + ")");
                            isUpdated = true;
                        }
                    }
                    else
                    {
                        if (newInfo.AssignRole != oldInfo.AssignRole || newInfo.AssignID != oldInfo.AssignID)
                        {
                            commonDao.InsertLogDetail(logId, "Assign", "Assign", oldInfo.UserAdmin.UserName + " (" + oldInfo.WFRole.Name + ")", ((newInfo.AssignID.HasValue ? new UserAdminDao().GetById(newInfo.AssignID.Value).UserName : string.Empty)
                                + " (" + (newInfo.AssignRole.HasValue ? new RoleDao().GetByID(newInfo.AssignRole.Value).Name : string.Empty) + ")"));
                            isUpdated = true;
                        }
                    }
                    if (isUpdated)
                    {
                        // Insert Key Name
                        string key = Constants.PER_REVIEW_EFORM_MASTER_PREFIX + oldInfo.ID.ToString();
                        commonDao.InsertLogDetail(logId, "ID", "Key for Update", key, null);
                    }
                    else
                    {
                        commonDao.DeleteMasterLog(logId);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return isUpdated;
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Update setup approval
        /// </summary>
        /// <param name="objUI">PurchaseRequest</param>
        /// <returns>Message</returns>
        public Message UpdateForSetupApproval(PurchaseRequest objUI,List<PurchaseRequestApproval> listApproval,bool insertApproval)
        {
            Message msg = null;
            try
            {

                if (objUI != null)
                {
                    PurchaseRequest objDb = GetByID(objUI.ID);
                    if (objDb != null)
                    {
                        if (objDb.UpdateDate.ToString() == objUI.UpdateDate.ToString())
                        {
                            if (insertApproval)
                            {
                                InsertMultiApproval(listApproval);
                            }
                            new PurchaseRequestLogDao().WriteLogForSetUpApproval(objUI, listApproval, insertApproval);
                            objDb.WFResolutionID = objUI.WFResolutionID;
                            objDb.AssignID = objUI.AssignID;
                            objDb.AssignRole = objUI.AssignRole;
                            objDb.InvolveID = objUI.InvolveID;
                            objDb.InvolveRole = objUI.InvolveRole;
                            objDb.InvolveDate = objUI.InvolveDate;
                            objDb.InvolveResolution = objUI.InvolveResolution;
                            objDb.UpdateDate = DateTime.Now;
                            dbContext.SubmitChanges();

                            msg = new Message(MessageConstants.I0001, MessageType.Info, "Purchase Request '" + Constants.PR_REQUEST_PREFIX + objUI.ID + "'", "updated");
                        }
                        else
                        {
                            msg = new Message(MessageConstants.E0025, MessageType.Error, "Purchase Request '" + Constants.PR_REQUEST_PREFIX + objUI.ID + "'");
                        }
                }
                }
            }
            catch
            {
                msg = new Message(MessageConstants.E0007, MessageType.Error);
            }

            return msg;
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Update setup approval
        /// </summary>
        /// <param name="objUI">PurchaseRequest</param>
        /// <returns>Message</returns>
        public Message UpdateForUSAccouting(PurchaseRequest objUI)
        {
            Message msg = null;
            try
            {

                if (objUI != null)
                {
                    PurchaseRequest objDb = GetByID(objUI.ID);
                    if (objDb != null)
                    {
                        if (objDb.UpdateDate.ToString() == objUI.UpdateDate.ToString())
                        {
                            new PurchaseRequestLogDao().WriteLogForPurchasingConfirm(objUI);
                            objDb.WFResolutionID = objUI.WFResolutionID;
                            objDb.AssignID = objUI.AssignID;
                            objDb.AssignRole = objUI.AssignRole;
                            objDb.InvolveID = objUI.InvolveID;
                            objDb.InvolveRole = objUI.InvolveRole;
                            objDb.InvolveDate = objUI.InvolveDate;
                            objDb.InvolveResolution = objUI.InvolveResolution;
                            objDb.USAccounting = objUI.USAccounting;
                            objDb.WFStatusID = objUI.WFStatusID;
                            objDb.UpdateDate = DateTime.Now;
                            dbContext.SubmitChanges();

                            msg = new Message(MessageConstants.I0001, MessageType.Info, "Purchase Request '" + Constants.PR_REQUEST_PREFIX + objUI.ID + "'", "updated");
                        }
                        else
                        {
                            msg = new Message(MessageConstants.E0025, MessageType.Error, "Purchase Request '" + Constants.PR_REQUEST_PREFIX + objUI.ID + "'");
                        }
                    }
                }
            }
            catch
            {
                msg = new Message(MessageConstants.E0007, MessageType.Error);
            }

            return msg;
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Update confirm
        /// </summary>
        /// <param name="objUI">PurchaseRequest</param>
        /// <param name="listInvoice">List<PurchaseInvoice></param>
        /// <returns>Message</returns>
        public Message UpdateConfirm(PurchaseRequest objUI, List<PurchaseInvoice> listInvoice)
        {
            Message msg = null;
            DbTransaction trans = null;
            try
            {
                dbContext.Connection.Open();
                trans = dbContext.Connection.BeginTransaction();
                dbContext.Transaction = trans;
                PurchaseRequest objDb = GetByID(objUI.ID);
                if (objDb != null)
                {
                    new PurchaseRequestLogDao().WriteLogForPurchasingConfirm(objUI);
                    objDb.PurchaseAppoval = objUI.PurchaseAppoval;
                    objDb.PaymentAppoval = objUI.PaymentAppoval;
                    if (objDb.WFResolutionID != 0 && objUI.WFResolutionID != 0)
                        objDb.WFResolutionID = objUI.WFResolutionID;
                    if (objDb.WFStatusID != 0 && objUI.WFStatusID != 0)
                        objDb.WFStatusID = objUI.WFStatusID;
                    objDb.AssignID = objUI.AssignID;
                    objDb.AssignRole = objUI.AssignRole;
                    objDb.InvolveID = objUI.InvolveID;
                    objDb.InvolveRole = objUI.InvolveRole;
                    objDb.InvolveDate = objUI.InvolveDate;
                    objDb.InvolveResolution = objUI.InvolveResolution;
                    objDb.UpdateDate = DateTime.Now;
                    objDb.UpdatedBy = objUI.UpdatedBy;
                    dbContext.SubmitChanges();
                    DeleteInvoices(objDb.ID);
                    InsertMultiInvoice(listInvoice);
                    msg = new Message(MessageConstants.I0001, MessageType.Info, "Purchase Request '" + Constants.PR_REQUEST_PREFIX + objUI.ID + "'", "updated");
                    trans.Commit();
                }
            }
            catch
            {
                if (trans != null) trans.Rollback();
                // Show system error
                msg = new Message(MessageConstants.E0007, MessageType.Error);
            }

            return msg;
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Update approval with comment
        /// </summary>
        /// <param name="objUI">PurchaseRequest</param>
        /// <param name="objComment">PurchaseComment</param>
        /// <returns>Message</returns>
        public Message UpdateForApproval(PurchaseRequest objUI, PurchaseComment objComment)
        {
            Message msg = null;
            DbTransaction trans = null;

            try
            {
                dbContext.Connection.Open();
                trans = dbContext.Connection.BeginTransaction();
                dbContext.Transaction = trans;
                if (objUI != null)
                {
                    PurchaseRequest objDb = GetByID(objUI.ID);
                    if (objDb != null)
                    {
                        #region Insert Comment
                        if (objComment != null && !string.IsNullOrEmpty(objComment.Contents))
                        {
                            PurchaseRequestCommentDao commentDao = new PurchaseRequestCommentDao();
                            commentDao.Insert(objComment);
                        }
                        #endregion
                        // Check valid update date
                        if (IsValidUpdateDate(objUI, objDb, out msg))
                        {
                            objDb.WFResolutionID = objUI.WFResolutionID;
                            objDb.AssignID = objUI.AssignID;
                            objDb.AssignRole = objUI.AssignRole;
                            objDb.InvolveID = objUI.InvolveID;
                            objDb.InvolveRole = objUI.InvolveRole;
                            objDb.InvolveDate = objUI.InvolveDate;
                            objDb.UpdateDate = DateTime.Now;
                            dbContext.SubmitChanges();

                            msg = new Message(MessageConstants.I0001, MessageType.Info, " Purchase Request '" + Constants.PR_REQUEST_PREFIX + objUI.ID + "'", "updated");
                            trans.Commit();
                        }
                        else
                        {
                            trans.Rollback();
                        }
                    }
                }
            }
            catch
            {
                // Rollback transaction
                if (trans != null)
                {
                    trans.Rollback();
                }
                // Show system error
                msg = new Message(MessageConstants.E0007, MessageType.Error);
            }
            finally
            {
                if ((trans.Connection != null) && (trans.Connection.State == System.Data.ConnectionState.Open))
                {
                    trans.Connection.Close();
                }
            }

            return msg;
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Write Insert Log For Employee
 /// </summary>
 /// <param name="objInfo"></param>
 /// <param name="logId"></param>
 private void WriteInsertLogForPurchaseRequest(PurchaseRequest objInfo, string logId)
 {
     try
     {
         if ((objInfo != null) && (logId != null))
         {
             // Insert to Log Detail
             commonDao.InsertLogDetail(logId, "ID", "ID", null, objInfo.ID.ToString());
             commonDao.InsertLogDetail(logId, "WFStatusID", "Status", null, objInfo.WFStatus.Name);
             commonDao.InsertLogDetail(logId, "WFResolutionID", "Resolution", null, objInfo.WFResolution.Name);
             commonDao.InsertLogDetail(logId, "Requestor", "Requestor", null, objInfo.UserAdmin1.UserName);
             commonDao.InsertLogDetail(logId, "RequestDate", "RequestDate", null, objInfo.RequestDate.ToString(Constants.DATETIME_FORMAT_VIEW));
             if (objInfo.ExpectedDate.HasValue)
             {
                 commonDao.InsertLogDetail(logId, "ExpectedDate", "Expected Date", null, objInfo.ExpectedDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW));
             }
             commonDao.InsertLogDetail(logId, "SubDepartment", "Sub Department", null, objInfo.Department.DepartmentName);
             commonDao.InsertLogDetail(logId, "Justification", "Justification", null, objInfo.Justification);
             commonDao.InsertLogDetail(logId, "BillableToClient", "BillableToClient", null, objInfo.BillableToClient ? "Yes" : "No");
             if (objInfo.Priority.HasValue)
             {
                 commonDao.InsertLogDetail(logId, "Priority", "Priority", null, objInfo.Priority.Value == 1 ? "Urgent" : string.Empty);
             }
             if (!string.IsNullOrEmpty(objInfo.VendorName))
             {
                 commonDao.InsertLogDetail(logId, "VendorName", "VendorName", null, objInfo.VendorName);
             }
             if (!string.IsNullOrEmpty(objInfo.VendorName))
             {
                 commonDao.InsertLogDetail(logId, "VendorPhone", "VendorPhone", null, objInfo.VendorPhone);
             }
             if (!string.IsNullOrEmpty(objInfo.VendorName))
             {
                 commonDao.InsertLogDetail(logId, "VendorEmail", "VendorEmail", null, objInfo.VendorEmail);
             }
             if (!string.IsNullOrEmpty(objInfo.VendorName))
             {
                 commonDao.InsertLogDetail(logId, "VendorAddress", "VendorAddress", null, objInfo.VendorAddress);
             }
             commonDao.InsertLogDetail(logId, "MoneyType", "Money Type", null, objInfo.MoneyType == Constants.TYPE_MONEY_USD ? "USD" : "VND");
             if (objInfo.OtherCost.HasValue)
             {
                 commonDao.InsertLogDetail(logId, "OtherCost", "Other Cost", null, objInfo.OtherCost.Value.ToString());
             }
             if (!string.IsNullOrEmpty(objInfo.SaleTaxName))
             {
                 commonDao.InsertLogDetail(logId, "SaleTaxName", "Sale Tax Name", null, objInfo.SaleTaxName);
             }
             if (objInfo.SaleTaxValue.HasValue)
             {
                 commonDao.InsertLogDetail(logId, "SaleTaxValue", "Sale Tax Value", null, objInfo.SaleTaxValue.Value.ToString());
             }
             if (objInfo.Shipping.HasValue)
             {
                 commonDao.InsertLogDetail(logId, "Shipping", "Shipping", null, objInfo.Shipping.Value.ToString());
             }
             if (objInfo.ServiceCharge.HasValue)
             {
                 commonDao.InsertLogDetail(logId, "ServiceCharge", "Service Charge", null, objInfo.ServiceCharge.Value.ToString());
             }
             if (objInfo.Discount.HasValue)
             {
                 commonDao.InsertLogDetail(logId, "Discount", "Discount", null, objInfo.Discount.Value.ToString());
             }
             if (!string.IsNullOrEmpty(objInfo.CCList))
             {
                 commonDao.InsertLogDetail(logId, "CCList", "CCList", null, objInfo.CCList);
             }
             if (objInfo.AssignID.HasValue && objInfo.AssignRole.HasValue)
             {
                 commonDao.InsertLogDetail(logId, "Assign", "Assign", null, objInfo.UserAdmin.UserName + " (" + objInfo.WFRole.Name + ")");
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 24
0
        /// <summary>
        /// Write Insert Log For Employee
        /// </summary>
        /// <param name="objInfo"></param>
        /// <param name="logId"></param>
        public bool WriteLogForPurchasingConfirm(PurchaseRequest newInfo)
        {
            bool isUpdated = false;
            try
            {
                MasterLog objMasterLog = new MasterLog();

                string logId = commonDao.UniqueId;

                commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.PurchaseRequest.ToString(), ELogAction.Update.ToString());
                // Get old info
                PurchaseRequest oldInfo = new PurchaseRequestDao().GetByID(newInfo.ID);

                if ((oldInfo != null) && (newInfo != null) && (logId != null))
                {
                    if (newInfo.WFResolutionID != oldInfo.WFResolutionID)
                    {
                        commonDao.InsertLogDetail(logId, "WFResolutionID", "Resolution", oldInfo.WFResolution.Name, new ResolutionDao().GetByID(newInfo.WFResolutionID).Name);
                        isUpdated = true;
                    }
                    if (newInfo.AssignRole != oldInfo.AssignRole || newInfo.AssignID != oldInfo.AssignID)
                    {
                        commonDao.InsertLogDetail(logId, "Assign", "Assign", oldInfo.UserAdmin.UserName + " (" + oldInfo.WFRole.Name + ")", ((newInfo.AssignID.HasValue ? new UserAdminDao().GetById(newInfo.AssignID.Value).UserName : string.Empty)
                            + " (" + (newInfo.AssignRole.HasValue ? new RoleDao().GetByID(newInfo.AssignRole.Value).Name : string.Empty) + ")"));
                        isUpdated = true;
                    }
                    if (!string.IsNullOrEmpty(newInfo.PurchaseAppoval) && newInfo.PurchaseAppoval != oldInfo.PurchaseAppoval)
                    {
                        commonDao.InsertLogDetail(logId, "PurchaseAppoval", "Purchase Appoval", oldInfo.PurchaseAppoval, newInfo.PurchaseAppoval);
                        isUpdated = true;
                    }
                    if (!string.IsNullOrEmpty(newInfo.PaymentAppoval) && newInfo.PaymentAppoval != oldInfo.PaymentAppoval)
                    {
                        commonDao.InsertLogDetail(logId, "PaymentAppoval", "Payment Appoval", oldInfo.PaymentAppoval, newInfo.PaymentAppoval);
                        isUpdated = true;
                    }
                    if (isUpdated)
                    {
                        // Insert Key Name
                        string key = Constants.PER_REVIEW_EFORM_MASTER_PREFIX + oldInfo.ID.ToString();
                        commonDao.InsertLogDetail(logId, "ID", "Key for Update", key, null);
                    }
                    else
                    {
                        commonDao.DeleteMasterLog(logId);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return isUpdated;
        }
Ejemplo n.º 25
0
        public void RenderRfq(Stream stream, VendorModel vendor, IEnumerable<ItemModel> items, UserModel user, int RfqNumber, PurchaseRequest Pr, DateTime DateRequested)
        {
            Document document = new Document(PageSize.LETTER);

            try {
                PdfWriter writer = PdfWriter.GetInstance(document, stream);
                document.Open();

                // Create a page in the document and add it to the bottom layer
                document.NewPage();
                //Pass Document to this
                CurrentDoc = document;

                page = writer.DirectContentUnder;
                page.BeginText();
                int top = (int)document.GetTop(0);
                SetFontSizeTo(16);
                PrintText("REQUEST FOR QUOTATION (THIS IS NOT AN ORDER)", 20, 10);
                SetFontSizeTo(10);

                //Header
                PrintText("Company Name: {0}".WithTokens(Pr.User.Company.Name), 20, 30); // Company Name
                PrintText("Address: 8th Floor Gedisco Tower, 534 Asuncion St., Binondo, Manila", 20, 45); // Company Address
                PrintText("Purchasing Department", 20, 60);
                PrintText("Issued By: {0} {1}".WithTokens(user.FirstName, user.LastName), 20, 75); // Requested By
                PrintTextRight("RFQ NO: {0}".WithTokens(RfqNumber), 70, 30); // RFQ Number
                PrintTextRight("Date: {0}".WithTokens(DateTime.Now.ToShortDateString()), 70, 45); // Date Created
                PrintTextRight("PR No: {0}".WithTokens(Pr.PRNo), 70, 60); // PR Number

                //Body
                SetFontSizeTo(14);
                PrintText("BID/OFFER/QUOTE MUST BE RECEIVED BY:", 20, 105); // Requested By
                PrintTextRight("Date: {0}".WithTokens(DateRequested.ToShortDateString()), 95, 105); // Date Required
                SetFontSizeTo(10);
                PrintText("Attention: {0} {1}".WithTokens(user.FirstName, user.LastName), 40, 125); // Vendor Contact Person
                PrintText("Tel No: {0}".WithTokens("+63 2 244 9296"), 40, 140); // Vendor Tel No
                PrintText("Email Address: {0}".WithTokens(user.Email), 40, 155); // Vendor Email
                PrintText("Fax No: {0}".WithTokens("+63 2 241 7826"), 240, 125); // Vendor Fax No
                SetFontSizeTo(8);
                PrintText("Unless otherwise requested, quote on each item separately. Unit Prices shall be shown. If unable to furnish", 20, 175); // Vendor Email
                PrintText("items as specified, submit sample and/or descriptive specifications of substitute offered.", 20, 185); // Vendor Email

                //Items
                SetFontSizeTo(8);
                PrintText("_______________________________________________________________________________________________________________________", 20, 210);
                PrintText("Item No.", 20, 205);
                PrintText("Item Description", 70, 205);
                PrintText("Quantity", 370, 205);
                PrintText("Unit Price", 420, 205);
                PrintText("Discount", 470, 205);
                PrintText("Total", 520, 205);

                //// Items..
                //int staryY = 225;
                //int itemCount = 1;
                //foreach (var item in items) {
                //    PrintItem(itemCount.ToString(), item.Description, item.Quantity.ToString(), ref staryY);
                //    itemCount++;
                //}
                //PrintText("********** NOTHING FOLLOWS **********", 75, staryY + 15);

                // START HERE ----------------------------
                Paragraph Grid = new Paragraph("\n\n\n\n\n\n\n\n\n");
                Grid.Alignment = 1;
                Grid.SpacingAfter = 35f;
                document.Add(Grid);

                Paragraph Grid2 = new Paragraph();
                Grid2.Alignment = 1;
                Grid2.SpacingBefore = 35f;
                //Start Table -----------------------------------
                PdfPTable rightTable = new PdfPTable(7);
                int[] widths = { 1, 1, 1, 7, 2, 2, 2 };
                rightTable.SetWidths(widths);
                rightTable.TotalWidth = 570f;
                rightTable.LockedWidth = true;
                Font tableFont = new Font(Font.FontFamily.HELVETICA, 8);

                rightTable.HorizontalAlignment = Element.ALIGN_CENTER;

                rightTable.AddCell(new Phrase("Item No.", tableFont));
                rightTable.AddCell(new Phrase("Item Description", tableFont));
                rightTable.AddCell(new Phrase("Quantity", tableFont));
                rightTable.AddCell(new Phrase("Unit Price", tableFont));
                rightTable.AddCell(new Phrase("Discount", tableFont));
                rightTable.AddCell(new Phrase("Total Amount", tableFont));

                rightTable.HorizontalAlignment = Element.ALIGN_LEFT;

                int itemCount = 1;
                foreach (var item in items) {
                    rightTable.AddCell(new Phrase(item.ItemNumber.ToString(), tableFont));
                    rightTable.AddCell(new Phrase(item.Description, tableFont));
                    rightTable.AddCell(new Phrase(item.Quantity.ToString(), tableFont));
                    rightTable.AddCell(new Phrase("", tableFont));
                    rightTable.AddCell(new Phrase("", tableFont));
                    rightTable.AddCell(new Phrase("", tableFont));
                    itemCount++;
                }
                //Nothing Follows
                rightTable.AddCell(new Phrase("", tableFont)); rightTable.AddCell(new Phrase("", tableFont)); rightTable.AddCell(new Phrase("")); rightTable.AddCell(new Phrase("******** NOTHING FOLLOWS ********", tableFont)); rightTable.AddCell(new Phrase("")); rightTable.AddCell(new Phrase("")); rightTable.AddCell(new Phrase(""));

                Grid2.Add(rightTable);
                document.Add(Grid2);
                // End of table -----------------------------------

                // Footer
                SetFontSizeTo(10);
                PrintTextBottom("If accepted within _____ days, the undersigned offers and agrees to honor this quotation.", 20, 85);
                PrintTextBottom("Print Name of Person:", 20, 65);
                PrintTextBottom("Company Name:", 20, 50);
                PrintTextBottom("Address:", 20, 35);
                PrintTextBottom("Email Address:", 20, 20);

                PrintTextBottom("No. of Days to Deliver:", 200, 65);
                PrintTextBottom("Telephone No.:", 200, 50);
                PrintTextBottom("Fax No.:", 200, 35);

                page.EndText();

                writer.Flush();
            }
            finally {
                document.Close();
            }
        }
Ejemplo n.º 26
0
  public static void Main( string[] args )
  {
    // Setup Chain of Responsibility
    Director Larry = new Director( "Larry" );
    VicePresident Sam = new VicePresident( "Sam" );
    President Tammy = new President( "Tammy" );
    Larry.SetSuccessor( Sam );
    Sam.SetSuccessor( Tammy );

    // Generate and process different requests
    PurchaseRequest rs = new PurchaseRequest( 
                          2034, 350.00, "Supplies" );
    Larry.ProcessRequest( rs );

    PurchaseRequest rx = new PurchaseRequest( 
                          2035, 32590.10, "Project X" );
    Larry.ProcessRequest( rx );

    PurchaseRequest ry = new PurchaseRequest( 
                          2036, 122100.00, "Project Y" );
    Larry.ProcessRequest( ry );

  }
Ejemplo n.º 27
0
 public bool IsAssigned(PurchaseRequest pr, int userAdminID, int loginRole)
 {
     if ((pr.AssignID.HasValue && pr.AssignID.Value == userAdminID &&
                 pr.AssignRole.HasValue && pr.AssignRole.Value == loginRole) )
         return true;
     return false;
 }
Ejemplo n.º 28
0
        /// <summary>
        /// Write Insert Log For Employee
        /// </summary>
        /// <param name="objInfo"></param>
        /// <param name="logId"></param>
        private bool WriteUpdateLogForPurchaseRequest(PurchaseRequest newInfo, string logId)
        {
            bool isUpdated = false;
            try
            {
                // Get old info
                PurchaseRequest oldInfo = new PurchaseRequestDao().GetByID(newInfo.ID);

                if ((oldInfo != null) && (newInfo != null) && (logId != null))
                {
                    if (newInfo.WFStatusID != oldInfo.WFStatusID)
                    {
                        commonDao.InsertLogDetail(logId, "WFStatusID", "Status", oldInfo.WFStatus.Name, new StatusDao().GetByID(newInfo.WFStatusID).Name);
                        isUpdated = true;
                    }
                    if (newInfo.WFResolutionID != oldInfo.WFResolutionID)
                    {
                        commonDao.InsertLogDetail(logId, "WFResolutionID", "Resolution", oldInfo.WFResolution.Name, new ResolutionDao().GetByID(newInfo.WFResolutionID).Name);
                        isUpdated = true;
                    }
                    if (newInfo.RequestDate != oldInfo.RequestDate)
                    {
                        commonDao.InsertLogDetail(logId, "RequestDate", "Request Date", oldInfo.RequestDate.ToString(Constants.DATETIME_FORMAT_VIEW), newInfo.RequestDate.ToString(Constants.DATETIME_FORMAT_VIEW));
                        isUpdated = true;
                    }
                    if (newInfo.ExpectedDate != oldInfo.ExpectedDate)
                    {
                        commonDao.InsertLogDetail(logId, "ExpectedDate", "Expected Date", oldInfo.ExpectedDate.HasValue ? oldInfo.ExpectedDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW) : string.Empty, newInfo.ExpectedDate.HasValue ? newInfo.ExpectedDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW) : string.Empty);
                        isUpdated = true;
                    }
                    if (newInfo.SubDepartment != oldInfo.SubDepartment)
                    {
                        commonDao.InsertLogDetail(logId, "SubDepartment", "Sub Department", oldInfo.Department.DepartmentName, new DepartmentDao().GetById(newInfo.SubDepartment).DepartmentName);
                        isUpdated = true;
                    }
                    if (newInfo.BillableToClient != oldInfo.BillableToClient)
                    {
                        commonDao.InsertLogDetail(logId, "BillableToClient", "Billable To Client", oldInfo.BillableToClient ? "Yes" : "No", newInfo.BillableToClient ? "Yes" : "No");
                        isUpdated = true;
                    }
                    if (newInfo.Priority != oldInfo.Priority)
                    {
                        commonDao.InsertLogDetail(logId, "Priority", "Priority", oldInfo.Priority.HasValue ? (oldInfo.Priority.Value == 1 ? "Urgent" : string.Empty) : string.Empty, newInfo.Priority.HasValue ? (newInfo.Priority.Value == 1 ? "Urgent" : string.Empty) : string.Empty);
                        isUpdated = true;
                    }
                    if (newInfo.VendorName != oldInfo.VendorName)
                    {
                        commonDao.InsertLogDetail(logId, "VendorName", "VendorName", oldInfo.VendorName, newInfo.VendorName);
                        isUpdated = true;
                    }
                    if (newInfo.VendorPhone != oldInfo.VendorPhone)
                    {
                        commonDao.InsertLogDetail(logId, "VendorPhone", "VendorPhone", oldInfo.VendorPhone, newInfo.VendorPhone);
                        isUpdated = true;
                    }
                    if (newInfo.VendorEmail != oldInfo.VendorEmail)
                    {
                        commonDao.InsertLogDetail(logId, "VendorEmail", "VendorEmail", oldInfo.VendorEmail, newInfo.VendorEmail);
                        isUpdated = true;
                    }
                    if (newInfo.VendorAddress != oldInfo.VendorAddress)
                    {
                        commonDao.InsertLogDetail(logId, "VendorAddress", "VendorAddress", oldInfo.VendorAddress, newInfo.VendorAddress);
                        isUpdated = true;
                    }
                    if (newInfo.MoneyType != oldInfo.MoneyType)
                    {
                        commonDao.InsertLogDetail(logId, "MoneyType", "Money Type", oldInfo.MoneyType == Constants.TYPE_MONEY_USD ? "USD" : "VND", newInfo.MoneyType == Constants.TYPE_MONEY_USD ? "USD" : "VND");
                        isUpdated = true;
                    }
                    if (newInfo.OtherCost != oldInfo.OtherCost)
                    {
                        commonDao.InsertLogDetail(logId, "OtherCost", "Other Cost", oldInfo.OtherCost.HasValue ? oldInfo.OtherCost.Value.ToString() : string.Empty, newInfo.OtherCost.HasValue ? newInfo.OtherCost.Value.ToString() : string.Empty);
                        isUpdated = true;
                    }
                    if (newInfo.SaleTaxName != oldInfo.SaleTaxName)
                    {
                        commonDao.InsertLogDetail(logId, "SaleTaxName", "SaleTaxName", oldInfo.SaleTaxName, newInfo.SaleTaxName);
                        isUpdated = true;
                    }
                    if (newInfo.SaleTaxValue != oldInfo.SaleTaxValue)
                    {
                        commonDao.InsertLogDetail(logId, "SaleTaxValue", "Sale Tax Value", oldInfo.SaleTaxValue.HasValue ? oldInfo.SaleTaxValue.Value.ToString() : string.Empty, newInfo.SaleTaxValue.HasValue ? newInfo.SaleTaxValue.Value.ToString() : string.Empty);
                        isUpdated = true;
                    }
                    if (newInfo.Shipping != oldInfo.Shipping)
                    {
                        commonDao.InsertLogDetail(logId, "Shipping", "Shipping", oldInfo.Shipping.HasValue ? oldInfo.Shipping.Value.ToString() : string.Empty, newInfo.Shipping.HasValue ? newInfo.Shipping.Value.ToString() : string.Empty);
                        isUpdated = true;
                    }
                    if (newInfo.ServiceCharge != oldInfo.ServiceCharge)
                    {
                        commonDao.InsertLogDetail(logId, "ServiceCharge", "ServiceCharge", oldInfo.ServiceCharge.HasValue ? oldInfo.ServiceCharge.Value.ToString() : string.Empty, newInfo.ServiceCharge.HasValue ? newInfo.ServiceCharge.Value.ToString() : string.Empty);
                        isUpdated = true;
                    }
                    if (newInfo.Discount != oldInfo.Discount)
                    {
                        commonDao.InsertLogDetail(logId, "Discount", "Discount", oldInfo.Discount.HasValue ? oldInfo.Discount.Value.ToString() : string.Empty, newInfo.Discount.HasValue ? newInfo.Discount.Value.ToString() : string.Empty);
                        isUpdated = true;
                    }
                    if (newInfo.CCList != oldInfo.CCList)
                    {
                        commonDao.InsertLogDetail(logId, "CCList", "CCList", oldInfo.CCList, newInfo.CCList);
                        isUpdated = true;
                    }
                    if (newInfo.AssignRole != oldInfo.AssignRole || newInfo.AssignID != oldInfo.AssignID)
                    {
                        commonDao.InsertLogDetail(logId, "Assign", "Assign", oldInfo.UserAdmin.UserName + " (" + oldInfo.WFRole.Name + ")", ((newInfo.AssignID.HasValue ? new UserAdminDao().GetById(newInfo.AssignID.Value).UserName : string.Empty)
                            + " (" + (newInfo.AssignRole.HasValue ? new RoleDao().GetByID(newInfo.AssignRole.Value).Name : string.Empty) + ")"));
                        isUpdated = true;
                    }
                    if (newInfo.USAccounting != oldInfo.USAccounting)
                    {
                        commonDao.InsertLogDetail(logId, "USAccounting", "USAccounting", oldInfo.USAccounting.HasValue ? new UserAdminDao().GetById(oldInfo.USAccounting.Value).UserName : string.Empty, newInfo.USAccounting.HasValue ? new UserAdminDao().GetById(newInfo.USAccounting.Value).UserName : string.Empty);
                        isUpdated = true;
                    }
                    if (isUpdated)
                    {
                        // Insert Key Name
                        string key = Constants.PER_REVIEW_EFORM_MASTER_PREFIX + oldInfo.ID.ToString();
                        commonDao.InsertLogDetail(logId, "ID", "Key for Update", key, null);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return isUpdated;
        }
Ejemplo n.º 29
0
 public string GetLastInvolveIdByRole(PurchaseRequest pr, string roleId)
 {
     string result = "";
     string[] arrInvoleId = string.IsNullOrEmpty(pr.InvolveID) ? new string[0] :
         pr.InvolveID.Split(new char[]{Constants.SEPARATE_INVOLVE_CHAR},
             StringSplitOptions.RemoveEmptyEntries);
     string[] arrInvoleRole = string.IsNullOrEmpty(pr.InvolveRole) ? new string[0] :
         pr.InvolveRole.Split(new char[]{Constants.SEPARATE_INVOLVE_CHAR},
             StringSplitOptions.RemoveEmptyEntries);
     for (int i = arrInvoleRole.Length - 1; i >= 0; i--)
         if (arrInvoleRole[i].Equals(roleId))
             result = arrInvoleId[i];
     return result;
 }
Ejemplo n.º 30
0
        /// <summary>
        /// Check update date whether is valid
        /// </summary>
        /// <param name="objUI">PurchaseRequest</param>
        /// <param name="objDb">PurchaseRequest</param>
        /// <param name="msg">Message</param>
        /// <returns>bool</returns>
        private bool IsValidUpdateDate(PurchaseRequest objUI, PurchaseRequest objDb, out Message msg)
        {
            bool isValid = false;
            msg = null;

            try
            {
                if ((objUI != null) && (objUI.UpdateDate != null))
                {
                    if (objDb != null)
                    {
                        if (objDb.UpdateDate.ToString().Equals(objUI.UpdateDate.ToString()))
                        {
                            isValid = true;
                        }
                        else
                        {
                            msg = new Message(MessageConstants.E0025, MessageType.Error, "Purchase Request Id " + objDb.ID);
                        }
                    }
                }
            }
            catch
            {
                throw;
            }

            return isValid;
        }
Ejemplo n.º 31
0
        ///// <summary>
        ///// Write Update Log For When Role Manager
        ///// </summary>
        ///// <param name="newInfo"></param>
        ///// <param name="logId"></param>
        ///// <returns></returns>
        //public void WriteUpdateLogForRoleManager(PurchaseRequest newInfo, ELogAction action)
        //{
        //    bool isUpdated = false;
        //    try
        //    {
        //        // Get old info
        //        string logId = commonDao.UniqueId;
        //        commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.PurchaseRequest.ToString(), action.ToString());
        //        PurchaseRequest oldInfo = new PurchaseRequestDao().GetByID(newInfo.ID);
        //        if ((oldInfo != null) && (newInfo != null) && (logId != null))
        //        {
        //            if (newInfo.WFStatusID != oldInfo.WFStatusID)
        //            {
        //                commonDao.InsertLogDetail(logId, "WFStatusID", "Status", new WFStatusDao().GetByID(oldInfo.WFStatusID).Name, new WFStatusDao().GetByID(newInfo.WFStatusID).Name);
        //                isUpdated = true;
        //            }
        //            if (newInfo.WFResolutionID != oldInfo.WFResolutionID)
        //            {
        //                WFResolution objRes = new ResolutionDao().GetByID(newInfo.WFResolutionID);
        //                if (objRes != null)
        //                {
        //                    commonDao.InsertLogDetail(logId, "WFResolutionID", "Resolution", oldInfo.WFResolutionID.ToString(), objRes.Name);
        //                    isUpdated = true;
        //                }
        //            }
        //            if (newInfo.AssignRole != oldInfo.AssignRole)
        //            {
        //                if (newInfo.AssignRole.HasValue)
        //                {
        //                    WFRole obj = new RoleDao().GetByID(newInfo.AssignRole.Value);
        //                    if (obj != null)
        //                    {
        //                        UserAdmin objUserAdmin = new UserAdminDao().GetById(newInfo.AssignID.Value);
        //                        if (objUserAdmin != null)
        //                        {
        //                            commonDao.InsertLogDetail(logId, "AssignID", " Forward to", oldInfo.UserAdmin.UserName + " (" + oldInfo.WFRole.Name + ")", objUserAdmin.UserName + " (" + obj.Name + ")");
        //                            isUpdated = true;
        //                        }
        //                    }
        //                }
        //            }
        //            if (isUpdated)
        //            {
        //                // Insert Key Name
        //                string key = Constants.PR_REQUEST_PREFIX + oldInfo.ID.ToString();
        //                commonDao.InsertLogDetail(logId, "EmployeeId", "Key for Update", key, null);
        //            }
        //            else
        //            {
        //                commonDao.DeleteMasterLog(logId);
        //            }
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}
        /// <summary>
        /// Write Log For PurchaseRequest
        /// </summary>
        /// <param name="oldInfo"></param>
        /// <param name="newInfo"></param>
        /// <param name="action"></param>
        public void WriteLogForPurchaseRequest(PurchaseRequest oldInfo, PurchaseRequest newInfo, ELogAction action)
        {
            try
            {
                if (newInfo == null)
                {
                    return;
                }

                MasterLog objMasterLog = new MasterLog();

                string logId = commonDao.UniqueId;

                switch (action)
                {
                    case ELogAction.Insert:
                        // Insert to Master Log
                        commonDao.InsertMasterLog(logId, newInfo.CreatedBy, ELogTable.PurchaseRequest.ToString(), action.ToString());
                        // Write Insert Log
                        WriteInsertLogForPurchaseRequest(newInfo, logId);
                        break;
                    case ELogAction.Update:
                        // Insert to Master Log
                        commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.PurchaseRequest.ToString(), action.ToString());
                        // Write Update Log
                        bool isUpdated = false;
                        isUpdated = WriteUpdateLogForPurchaseRequest(newInfo, logId);
                        if (!isUpdated)
                        {
                            commonDao.DeleteMasterLog(logId);
                        }
                        break;
                    case ELogAction.Delete:
                        // Insert to Master Log
                        commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.PurchaseRequest.ToString(), action.ToString());
                        // Write Delete Log
                        string key = newInfo.ID.ToString();
                        commonDao.InsertLogDetail(logId, "PurchaseRequest_ID", "Key for Delete", key, null);
                        break;
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 32
0
        public void RenderCanvasSheet(Stream stream, IEnumerable<CanvasItemModel> items, UserModel currentUser,UserModel requestedBy, PurchaseRequest Pr, string[] Vendors)
        {
            Document document = new Document(PageSize.LETTER);

            try {
                PdfWriter writer = PdfWriter.GetInstance(document, stream);
                document.Open();

                // Create a page in the document and add it to the bottom layer
                document.NewPage();
                //Pass Document to this
                CurrentDoc = document;

                page = writer.DirectContentUnder;
                page.BeginText();
                int top = (int)document.GetTop(0);
                SetFontSizeTo(16);
                PrintText("CANVASS SHEET", 20, 10);
                SetFontSizeTo(10);

                //Header
                PrintText("Company Name: " + requestedBy.CompanyName, 20, 30); // Company Name
                PrintText("Department: " + requestedBy.DepartmentName, 20, 45); // Company Address
                PrintText("Purpose: " + Pr.Purpose, 20, 60); // Purpose
                PrintTextRight("Date: {0}".WithTokens(DateTime.Now.ToShortDateString()), 70, 30); // Date Created
                PrintTextRight("PR No: {0}".WithTokens(Pr.PRNo), 70, 45); // PR Number

                SetFontSizeTo(8);

                // START HERE ----------------------------
                Paragraph Grid = new Paragraph("\n");
                Grid.Alignment = 1;
                Grid.SpacingAfter = 10f;
                document.Add(Grid);

                Paragraph Grid2 = new Paragraph();
                Grid2.Alignment = 1;
                Grid2.SpacingBefore = 35f;
                //Start Table -----------------------------------
                PdfPTable rightTable = new PdfPTable(7);
                int[] widths = { 1, 7, 2, 2, 2, 2, 2 };
                rightTable.SetWidths(widths);
                rightTable.TotalWidth = 570f;
                rightTable.LockedWidth = true;
                Font tableFont = new Font(Font.FontFamily.HELVETICA, 8);

                PdfPCell rightAlignedCell = new PdfPCell();
                rightAlignedCell.HorizontalAlignment = Element.ALIGN_CENTER;

                //Headers
                rightAlignedCell.Phrase = new Phrase("Item No.", tableFont); rightTable.AddCell(rightAlignedCell);
                rightAlignedCell.Phrase = new Phrase("Item Description", tableFont); rightTable.AddCell(rightAlignedCell);
                rightAlignedCell.Phrase = new Phrase("Quantity", tableFont); rightTable.AddCell(rightAlignedCell);
                rightAlignedCell.Phrase = new Phrase("UOM", tableFont); rightTable.AddCell(rightAlignedCell);
                rightAlignedCell.Phrase = new Phrase(Vendors[0], tableFont); rightTable.AddCell(rightAlignedCell);
                rightAlignedCell.Phrase = new Phrase(Vendors[1], tableFont); rightTable.AddCell(rightAlignedCell);
                rightAlignedCell.Phrase = new Phrase(Vendors[2], tableFont); rightTable.AddCell(rightAlignedCell);

                rightAlignedCell.HorizontalAlignment = Element.ALIGN_RIGHT;

                foreach (var item in items) {
                    string priceVendor1 = item.PriceVendor1 == 0 ? "NONE" : item.PriceVendor1.ToString();
                    string priceVendor2 = item.PriceVendor2 == 0 ? "NONE" : item.PriceVendor2.ToString();
                    string priceVendor3 = item.PriceVendor3 == 0 ? "NONE" : item.PriceVendor3.ToString();
                    rightTable.AddCell(new Phrase(item.ItemNumber.ToString(), tableFont));
                    rightTable.AddCell(new Phrase(item.ItemDescription, tableFont));
                    rightAlignedCell.Phrase = new Phrase(item.Quantity.ToString(), tableFont); rightTable.AddCell(rightAlignedCell);
                    rightTable.AddCell(new Phrase(item.UOM, tableFont));
                    rightAlignedCell.Phrase = new Phrase(priceVendor1, tableFont); rightTable.AddCell(rightAlignedCell);
                    rightAlignedCell.Phrase = new Phrase(priceVendor2, tableFont); rightTable.AddCell(rightAlignedCell);
                    rightAlignedCell.Phrase = new Phrase(priceVendor3, tableFont); rightTable.AddCell(rightAlignedCell);
                }
                Grid2.Add(rightTable);
                document.Add(Grid2);

                // Footer
                SetFontSizeTo(10);
                PrintTextBottom("Requested By:", 20, 105);
                PrintTextBottom("{0} {1}".WithTokens(requestedBy.FirstName, requestedBy.LastName), 20, 35);

                PrintTextBottom("Prepared By:", 265, 105);
                PrintTextBottom("{0} {1}".WithTokens(currentUser.FirstName, currentUser.LastName), 265, 35);

                PrintTextBottom("Approved By:", 450, 105);
                PrintTextBottom("{0}".WithTokens("______________________"), 450, 35);

                page.EndText();

                writer.Flush();
            }
            finally {
                document.Close();
            }
        }
Ejemplo n.º 33
0
 public bool IsInInvolveList(PurchaseRequest pr, int userAdminID, int loginRole)
 {
     int? result = dbContext.check_in_list_int(pr.InvolveID, userAdminID,
         pr.InvolveRole, loginRole, Constants.SEPARATE_INVOLVE_SIGN);
     return result.HasValue ? result.Value == 1 ? true : false : false;
 }
Ejemplo n.º 34
0
 abstract public void ProcessRequest( 
                  PurchaseRequest request );
Ejemplo n.º 35
0
 public bool IsRequestor(PurchaseRequest pr, int userAdminID, int loginRole)
 {
     if (loginRole == Constants.PR_REQUESTOR_ID && pr.Requestor == userAdminID)
         return true;
     return false;
 }
Ejemplo n.º 36
0
        /// <summary>
        /// Insert purchase request
        /// </summary>
        /// <param name="objUI">PurchaseRequest</param>
        /// <returns>Message</returns>
        public Message Insert(PurchaseRequest objUI)
        {
            Message msg = null;
            DbTransaction trans = null;
            try
            {
                dbContext.Connection.Open();
                trans = dbContext.Connection.BeginTransaction();
                dbContext.Transaction = trans;
                if (objUI != null)
                {
                    objUI.DeleteFlag = false;
                    dbContext.PurchaseRequests.InsertOnSubmit(objUI);
                    dbContext.SubmitChanges();
                    //Write Log
                    new PurchaseRequestLogDao().WriteLogForPurchaseRequest(null, objUI, ELogAction.Insert);
                    msg = new Message(MessageConstants.I0001, MessageType.Info, "Purchase Request '" + Constants.PR_REQUEST_PREFIX + objUI.ID + "'", "added");
                    trans.Commit();
                }
            }
            catch
            {
                if (trans != null) trans.Rollback();
                // Show system error
                msg = new Message(MessageConstants.E0007, MessageType.Error);
            }
            finally
            {
                if ((trans.Connection != null) && (trans.Connection.State == System.Data.ConnectionState.Open))
                {
                    trans.Connection.Close();
                }
            }

            return msg;
        }
Ejemplo n.º 37
0
        /// <summary>
        /// Update purchase request
        /// </summary>
        /// <param name="objUI">PurchaseRequest</param>
        /// <param name="oldItemList">List of old purchase items</param>
        /// <param name="newItemList">List of new purchase items</param>
        /// <returns>Message</returns>
        public Message Update(PurchaseRequest objUI,List<PurchaseItem> oldItemList,List<PurchaseItem> newItemList)
        {
            Message msg = null;
            DbTransaction trans = null;
            try
            {
                dbContext.Connection.Open();
                trans = dbContext.Connection.BeginTransaction();
                dbContext.Transaction = trans;
                if (objUI != null)
                {
                    // Get current group in dbContext
                    PurchaseRequest objDb = GetByID(objUI.ID);

                    if (objDb != null)
                    {
                        if (objDb.UpdateDate.ToString() == objUI.UpdateDate.ToString())
                        {
                            new PurchaseRequestLogDao().WriteLogForPurchaseRequest(null, objUI, ELogAction.Update);
                            #region Purchase Request
                            // Update info by objUI
                            objDb.ExpectedDate = objUI.ExpectedDate;
                            objDb.CCList = objUI.CCList;
                            objDb.WFStatusID = objUI.WFStatusID;
                            objDb.PaymentID = objUI.PaymentID;
                            objDb.WFResolutionID = objUI.WFResolutionID;
                            objDb.SubDepartment = objUI.SubDepartment;
                            objDb.Justification = objUI.Justification;
                            objDb.BillableToClient = objUI.BillableToClient;
                            objDb.VendorName = objUI.VendorName;
                            objDb.VendorPhone = objUI.VendorPhone;
                            objDb.VendorEmail = objUI.VendorEmail;
                            objDb.VendorAddress = objUI.VendorAddress;
                            objDb.MoneyType = objUI.MoneyType;
                            objDb.SaleTaxName = objUI.SaleTaxName;
                            objDb.SaleTaxValue = objUI.SaleTaxValue;
                            objDb.OtherCost = objUI.OtherCost;
                            objDb.Shipping = objUI.Shipping;
                            objDb.Discount = objUI.Discount;
                            objDb.ServiceCharge = objUI.ServiceCharge;
                            objDb.AssignID = objUI.AssignID;
                            objDb.AssignRole = objUI.AssignRole;
                            objDb.InvolveID = objUI.InvolveID;
                            objDb.InvolveRole = objUI.InvolveRole;
                            objDb.InvolveDate = objUI.InvolveDate;
                            objDb.InvolveResolution = objUI.InvolveResolution;
                            objDb.UpdateDate = DateTime.Now;
                            objDb.UpdatedBy = objUI.UpdatedBy;
                            objDb.Priority = objUI.Priority;
                            #endregion

                            #region Purchase Item
                            if (oldItemList.Count > 0)
                            {
                                string oldItemID = string.Empty;
                                foreach (PurchaseItem oldItem in oldItemList) //case Update Old item
                                {
                                    UpdatePurchaseItem(oldItem);
                                    oldItemID += oldItem.ID + ",";
                                }
                                foreach (PurchaseItem deleteItem in GetListOldPurchaseItem(objDb.ID))
                                {
                                    if (!oldItemID.TrimEnd(',').Split(',').Contains(deleteItem.ID.ToString()))
                                    {
                                        DeletePurchaseItem(deleteItem);
                                    }
                                }

                            }
                            if (newItemList.Count > 0)
                            {
                                InsertMultiItem(newItemList);
                            }
                            #endregion
                            // Submit changes to dbContext
                            dbContext.SubmitChanges();

                            // Show success message
                            msg = new Message(MessageConstants.I0001, MessageType.Info, "Purchase Request '" + Constants.PR_REQUEST_PREFIX + objUI.ID + "'", "updated");
                            trans.Commit();
                        }
                        else
                        {
                            msg = new Message(MessageConstants.E0025, MessageType.Error, "Purchase Request '" + Constants.PR_REQUEST_PREFIX + objUI.ID + "'");
                            trans.Rollback();
                        }
                    }
                }
            }
            catch
            {
                if (trans != null) trans.Rollback();
                // Show system error
                msg = new Message(MessageConstants.E0007, MessageType.Error);
            }

            return msg;
        }