Esempio n. 1
0
        public static bool CreateAdjustmentVoucher(int sessionID, string itemNo, int qty, string reason)
        {
            bool result = false;

            try
            {
                LussisEntities context = new LussisEntities();

                Employee            employee     = AndroidAuthenticationController.GetDetailsOfEmployee(sessionID);
                StationeryCatalogue itemToChange = context.StationeryCatalogues.Where(item => item.ItemNo.Equals(itemNo)).FirstOrDefault();

                // Create new Adjustment Voucher
                AdjustmentVoucher newVoucher = new AdjustmentVoucher()
                {
                    DateIssued = DateTime.Today,
                    IssueEmpNo = employee.EmpNo,
                    Status     = "Pending"
                };
                context.AdjustmentVouchers.Add(newVoucher);
                context.SaveChanges();

                result = true;

                if (result == true)
                {
                    try
                    {
                        // Add Voucher Detail
                        AdjustmentVoucherDetail newAdjustment = new AdjustmentVoucherDetail()
                        {
                            AvNo   = newVoucher.AvNo,
                            ItemNo = itemNo,
                            Qty    = qty - itemToChange.CurrentQty,
                            Reason = reason
                        };
                        context.AdjustmentVoucherDetails.Add(newAdjustment);
                        context.SaveChanges();

                        result = true;
                    }
                    catch (Exception)
                    {
                        result = false;
                    }
                }
            }
            catch (Exception)
            {
                result = false;
            }

            return(result);
        }
Esempio n. 2
0
        public static string GetDisbursementNoForCurrentDepartmentOf(int sessionID)
        {
            Employee employee = AndroidAuthenticationController.GetDetailsOfEmployee(sessionID);

            return(employee
                   .Department
                   .Disbursements
                   .Where(dis => dis.Status.Equals("Pending"))
                   .OrderByDescending(dis => dis.DisbursementDate)
                   .FirstOrDefault()
                   .DisbursementNo
                   .ToString());
        }