public ActionResult updateRetrieve()
        {
            StationeryModel entity = new StationeryModel();

            if (Request.QueryString["ErrorMessage"] != null)
            {
                TempData["ErrorMessage"] = Request.QueryString["ErrorMessage"];
                return(RedirectToAction("GenerateRetrieveForm"));
            }
            var RetrieveQty = Convert.ToInt32((Request.QueryString["key1"]));
            var itemCode    = Request.QueryString["key2"];
            var description = Request.QueryString["key4"];
            var Qty         = Convert.ToInt32(Request.QueryString["key3"]);
            var page        = Convert.ToInt32(Request.QueryString["key5"]);
            var stock       = Convert.ToInt32(Request.QueryString["key6"]);
            var status      = Request.QueryString["key7"];

            if (status != null)
            {
                List <Requisition_Detail> list = entity.Requisition_Detail.Where(x => x.itemCode == itemCode).ToList();
                foreach (var item in list)
                {
                    item.allocatedQty = 0;
                }
                entity.SaveChanges();
            }
            var rlist = (List <RetrieveForm>)HttpContext.Application["retrieveList"];

            rlist.Where(x => x.ItemCode == itemCode).First().retrieveQty = RetrieveQty;
            HttpContext.Application["retrieveList"] = rlist;
            TempData["Successful"] = "Retrieve successfully.";

            return(RedirectToAction("GenerateRetrieveForm", new { pagenumber = page }));
        }
Esempio n. 2
0
        //for android: different cos of execution of rd.allocateQty += allocateQty
        public int UpdateRequisitionDetailsAndroid(string itemcode, int requisitionNo, int?allocateQty)
        {
            try
            {
                StationeryModel    entity = new StationeryModel();
                Requisition_Detail rd     = new Requisition_Detail();
                rd = entity.Requisition_Detail.Where(x => x.itemCode == itemcode && x.requisitionNo == requisitionNo).First();
                //start of code added by alex//
                //deduct retrieve qty after doing allocation
                List <RetrieveForm> retrievalList = (List <RetrieveForm>)HttpContext.Current.Application["retrieveForm"];
                int index = retrievalList.FindIndex(x => x.ItemCode == itemcode);
                retrievalList[index].retrieveQty -= allocateQty;


                HttpContext.Current.Application["retrieveForm"] = retrievalList;

                //end of code//
                rd.allocatedQty += allocateQty;
                entity.SaveChanges();
                return(0);
            }
            catch
            {
                return(0);
            }
        }
Esempio n. 3
0
        public int UpdateAdjustmentVoucherInfo(Adjustment_Voucher_Record voucher)
        {
            using (StationeryModel context = new StationeryModel())
            {
                try
                {
                    Adjustment_Voucher_Record record = (from r in context.Adjustment_Voucher_Records
                                                        where r.voucherID == voucher.voucherID
                                                        select r).First();

                    record.approvalDate       = voucher.approvalDate;
                    record.authorisingStaffID = voucher.authorisingStaffID;
                    record.handlingStaffID    = voucher.handlingStaffID;
                    record.issueDate          = voucher.issueDate;
                    record.remarks            = voucher.remarks;
                    record.status             = voucher.status;

                    return(context.SaveChanges());
                }
                catch (Exception e)
                {
                    string errorMessage = String.Format("Error occurs when updating adjustment voucher. ({0})", e.Message);
                    throw new Exception(errorMessage);
                }
            }
        }
        public bool AddPurchaseDetail(string deliveryOrderNo, string itemCode, int qty, string remarks, decimal price)
        {
            using (StationeryModel Entity = new StationeryModel())
            {
                int maxOrderNo = 0;
                //to obtain highest order number
                List <Purchase_Order_Record> pds = Entity.Purchase_Order_Records.ToList();
                foreach (Purchase_Order_Record p in pds)
                {
                    maxOrderNo = 1;
                    if (p.orderNo > maxOrderNo)
                    {
                        maxOrderNo = p.orderNo;
                    }
                }

                Purchase_Detail pd = new Purchase_Detail();
                pd.orderNo         = maxOrderNo + 1;
                pd.deliveryOrderNo = deliveryOrderNo;
                pd.itemCode        = itemCode;
                pd.qty             = qty;
                pd.remarks         = remarks;
                pd.price           = price;

                Entity.Purchase_Detail.Add(pd);
                Entity.SaveChanges();
                return(true);
            }
        }
 public Boolean AddNewDepartment(Department dept)
 {
     try
     {
         StationeryModel entity      = new StationeryModel();
         Department      department  = new Department();
         string          capDeptCode = dept.departmentCode.ToUpper();
         department.departmentCode = capDeptCode;
         department.departmentName = dept.departmentName;
         department.contactName    = dept.contactName;
         department.phoneNo        = dept.phoneNo;
         department.faxNo          = dept.faxNo;
         //department.departmentHeadID = dept.departmentHeadID;
         if (dept.collectionPointID.ToString() == "--Select--")
         {
             return(false);
         }
         else
         {
             department.collectionPointID = dept.collectionPointID;
             //department.representativeID = dept.representativeID;
             entity.Departments.Add(department);
             entity.SaveChanges();
         }
     }
     catch
     {
         return(false);
     }
     return(true);
 }
        public bool AddNewPurchaseOrder(Purchase_Order_Record purchase_order_record)
        {
            StationeryModel Entity = new StationeryModel();

            Entity.Purchase_Order_Records.Add(purchase_order_record);
            Entity.SaveChanges();
            return(true);
        }
        //CLERK
        //transfer to transactionDAO

        public bool AddNewTransactionRecord(Transaction_Record tr)
        {
            using (StationeryModel ctx = new StationeryModel())
            {
                ctx.Transaction_Records.Add(tr);
                ctx.SaveChanges();
                return(true);
            }
        }
 //CLERK
 //transfer this code to transactionDAO
 public bool AddNewTransactionDetail(Transaction_Detail td)
 {
     using (StationeryModel ctx = new StationeryModel())
     {
         ctx.Transaction_Details.Add(td);
         ctx.SaveChanges();
         return(true);
     }
 }
Esempio n. 9
0
 public bool AddNewAdjustmentVoucher(Adjustment_Voucher_Record voucher)
 {
     using (StationeryModel context = new StationeryModel())
     {
         context.Adjustment_Voucher_Records.Add(voucher);
         context.SaveChanges();
         return(true);
     }
 }
 public bool AddPurchaseDetail(Purchase_Detail pd)
 {
     using (StationeryModel Entity = new StationeryModel())
     {
         Entity.Purchase_Detail.Add(pd);
         Entity.SaveChanges();
         return(true);
     }
 }
 public bool DeletePurchaseOrder(int orderID)
 {
     using (StationeryModel Entity = new StationeryModel())
     {
         Purchase_Order_Record por = Entity.Purchase_Order_Records.Where(x => x.orderNo == orderID).First();
         Entity.Purchase_Order_Records.Remove(por);
         Entity.SaveChanges();
         return(true);
     }
 }
Esempio n. 12
0
        public int UpdateRequisitionDetails(string itemcode, int requisitionNo, int?allocateQty, int?fulfilledQty)
        {
            StationeryModel    entity = new StationeryModel();
            Requisition_Detail rd     = new Requisition_Detail();

            rd = entity.Requisition_Detail.Where(x => x.itemCode == itemcode && x.requisitionNo == requisitionNo).First();
            rd.allocatedQty = allocateQty;
            rd.fulfilledQty = fulfilledQty;
            entity.SaveChanges();
            return(0);
        }
        public void UpdateReqDetail(string No, string itemCode, string quantity)
        {
            int requisitionNo = Convert.ToInt32(No);
            int qty           = Convert.ToInt32(quantity);

            using (StationeryModel entity = new StationeryModel())
            {
                entity.Requisition_Detail.Where(x => x.itemCode == itemCode && x.requisitionNo == requisitionNo).First().qty = (int)qty;
                entity.SaveChanges();
            }
        }
 //saving the permission into DB
 public void CreatePermissions(int permissionID, string controller, string action)
 {
     using (StationeryModel context = new StationeryModel())
     {
         permissionInfo p = new permissionInfo();
         p.permissionID = permissionID;
         p.action       = action;
         p.controller   = controller;
         p.description  = "";
         context.permissionInfoes.Add(p);
         context.SaveChanges();
     }
 }
Esempio n. 15
0
        public void DelegateEmp(string userid, DateTime?from, DateTime?to)
        {
            using (StationeryModel entity = new StationeryModel())
            {
                DateTime start = (DateTime)from;
                DateTime end   = (DateTime)to;
                User     u     = (from user in entity.Users where user.userID == userid select user).FirstOrDefault();
                u.delegationStart = start.Date;
                u.delegationEnd   = end.Date;
                u.role            = (int)UserRoles.RoleID.ActingDepartmentHead;

                entity.SaveChanges();
            }
        }
Esempio n. 16
0
        public bool DeleteSupplier(string supplierCode)
        {
            using (StationeryModel context = new StationeryModel())
            {
                Supplier supplier = (from s in context.Suppliers
                                     where s.supplierCode == supplierCode
                                     select s).FirstOrDefault();

                context.Suppliers.Remove(supplier);
                context.SaveChanges();

                return(true);
            }
        }
        public bool DeleteStationery(string itemCode)
        {
            using (StationeryModel context = new StationeryModel())
            {
                Stationery stationery = (from s in context.Stationeries
                                         where s.itemCode == itemCode
                                         select s).FirstOrDefault();

                context.Stationeries.Remove(stationery);
                context.SaveChanges();

                return(true);
            }
        }
Esempio n. 18
0
        bool ICollectionPointDAO.DeleteCollectionPoint(int collectionPointID)
        {
            using (StationeryModel context = new StationeryModel())
            {
                Collection_Point collectionPoint = (from s in context.Collection_Points
                                                    where s.collectionPointID == collectionPointID
                                                    select s).FirstOrDefault();

                context.Collection_Points.Remove(collectionPoint);
                context.SaveChanges();

                return(true);
            }
        }
Esempio n. 19
0
        public void AutoRomove(User user)
        {
            using (StationeryModel entity = new StationeryModel())
            {
                int UR = 0;
                //  int supervisor = 0;
                User actDeptHead = new User();
                actDeptHead = null;
                List <User> users = (from u in entity.Users where u.departmentCode == user.departmentCode select u).ToList <User>();

                foreach (User check in users)
                {
                    if (check.role == (int)UserRoles.RoleID.ActingDepartmentHead)
                    {
                        actDeptHead = (from user1 in entity.Users where (user1.role == 8 && user1.departmentCode == user.departmentCode) select user1).First();
                    }
                }
                if (actDeptHead != null)
                {
                    DateTime endDate = (DateTime)actDeptHead.delegationEnd;
                    DateTime tdy     = DateTime.Today;
                    if (tdy.CompareTo(endDate) > 0)
                    {
                        foreach (User u in users)
                        {
                            switch (u.role)
                            {
                            case (int)UserRoles.RoleID.UserRepresentative:
                                UR++;
                                break;
                            }
                        }

                        if (UR < 1)                                                      // no userrepresentative in list
                        {
                            actDeptHead.role = (int)UserRoles.RoleID.UserRepresentative; //assign as ur
                        }
                        else
                        {
                            actDeptHead.role = (int)UserRoles.RoleID.Employee;  //assign as employee
                        }
                        actDeptHead.delegationStart = null;
                        actDeptHead.delegationEnd   = null;
                    }

                    entity.SaveChanges();
                }
            }
        }
Esempio n. 20
0
        public bool AddNewSupplier(Supplier supplier)
        {
            using (StationeryModel context = new StationeryModel())
            {
                context.Suppliers.Add(supplier);
                int rowAffected = context.SaveChanges();

                if (rowAffected != 1)
                {
                    throw new DAOException();
                }

                return(true);
            }
        }
        public void RemovePendingRequisition(string NO)
        {
            int requisitionNo = Convert.ToInt32(NO);

            using (StationeryModel entity = new StationeryModel())
            {
                Requisition_Record record = (from r in entity.Requisition_Records
                                             where r.requisitionNo == requisitionNo
                                             select r).FirstOrDefault();

                entity.Requisition_Detail.RemoveRange(record.Requisition_Detail);
                entity.Requisition_Records.Remove(record);
                entity.SaveChanges();
            }
        }
Esempio n. 22
0
        bool ICollectionPointDAO.AddNewCollectionPoint(Collection_Point collectionPoint)
        {
            using (StationeryModel context = new StationeryModel())
            {
                context.Collection_Points.Add(collectionPoint);
                int rowAffected = context.SaveChanges();

                if (rowAffected != 1)
                {
                    throw new DAOException();
                }

                return(true);
            }
        }
Esempio n. 23
0
        public int changePassword(User user)
        {
            using (StationeryModel context = new StationeryModel())
            {
                User u = (from x in context.Users
                          where x.userID == user.userID
                          select x).FirstOrDefault();

                u.password = user.password;

                int rowAffected = context.SaveChanges();

                return(rowAffected);
            }
        }
Esempio n. 24
0
 public int UpdateRequisitionDetails(string itemcode, int requisitionNo, int?allocateQty)
 {
     try
     {
         StationeryModel    entity = new StationeryModel();
         Requisition_Detail rd     = new Requisition_Detail();
         rd = entity.Requisition_Detail.Where(x => x.itemCode == itemcode && x.requisitionNo == requisitionNo).First();
         rd.allocatedQty = allocateQty;
         entity.SaveChanges();
         return(0);
     }
     catch (Exception e) {
         e.Message.ToString();
         return(1);
     }
 }
Esempio n. 25
0
 public bool SubmitNewRequisition(Requisition_Record requisition)
 {
     using (StationeryModel context = new StationeryModel())
     {
         try
         {
             context.Requisition_Records.Add(requisition);
             context.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             throw new Exception(e.Message);
         }
     }
 }
Esempio n. 26
0
        int ICollectionPointDAO.UpdateCollectionPointInfo(Collection_Point collectionPoint)
        {
            using (StationeryModel context = new StationeryModel())
            {
                Collection_Point c = (from x in context.Collection_Points
                                      where x.collectionPointID == collectionPoint.collectionPointID
                                      select x).FirstOrDefault();

                c.collectionPointName = collectionPoint.collectionPointName;


                int rowAffected = context.SaveChanges();

                return(rowAffected);
            }
        }
 public bool AddNewTransaction(Transaction_Record transaction_record)
 {
     using (StationeryModel context = new StationeryModel())
     {
         try
         {
             context.Transaction_Records.Add(transaction_record);
             context.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
        public int UpdateDepartmentInfo(Department dept)
        {
            StationeryModel entity = new StationeryModel();
            Department      dt     = entity.Departments.Where(x => x.departmentCode == dept.departmentCode).First();

            dt.departmentName = dept.departmentName;
            dt.contactName    = dept.contactName;
            dt.phoneNo        = dept.phoneNo;
            dt.faxNo          = dept.faxNo;
            //dt.departmentHeadID = dept.departmentHeadID;
            dt.collectionPointID = dept.collectionPointID;
            //dt.representativeID = dept.representativeID;
            //dt = dept;
            int row = entity.SaveChanges();

            return(row);
        }
Esempio n. 29
0
 public static Boolean changePassWord(string userID, string CurrentPassword, string NewPassWord)
 {
     using (StationeryModel entity = new StationeryModel())
     {
         if (entity.Users.Where(x => x.userID == userID && x.password == CurrentPassword).Count() > 0)
         {
             User updateUser = entity.Users.Where(x => x.userID == userID && x.password == CurrentPassword).First();
             updateUser.password = NewPassWord;
             entity.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
        public int UpdatePurchaseDetailsInfo(Purchase_Detail pd)
        {
            using (StationeryModel Entity = new StationeryModel())
            {
                Purchase_Detail purchd = (from x in Entity.Purchase_Detail
                                          where x.orderNo == pd.orderNo && x.itemCode == pd.itemCode
                                          select x).FirstOrDefault();

                purchd.fulfilledQty     = pd.fulfilledQty;
                purchd.price            = pd.price;
                purchd.deliveryOrderNo += " /" + pd.deliveryOrderNo;
                purchd.remarks          = pd.remarks;

                int rowAffected = Entity.SaveChanges();

                return(rowAffected);
            }
        }