Example #1
0
        //******************************************************Method 01 I am a code master***********************************************************//

        //get item total quantity from requisitions(without outstading)
        private void getRetrievalFormItemList(List <RetrievalFormItem> refl, List <Requisition> reql)
        {
            bool IsNewItem       = true;
            bool IsNewDepartment = true;

            if (reql.Count > 0)
            {
                foreach (Requisition req in reql)
                {
                    foreach (RequisitionItem reqitem in req.RequisitionItems)
                    {
                        IsNewItem = true;//reset bool for every new item
                        foreach (RetrievalFormItem refitem in refl)
                        {
                            if (refitem.ItemID == reqitem.itemID) //not a new item for RequisitionFormList
                            {
                                IsNewItem       = false;          //set bool
                                refitem.Needed  = refitem.Needed + reqitem.requisitionQty;
                                refitem.Actual  = refitem.Needed;
                                IsNewDepartment = true;//reset bool for every new item
                                foreach (BreakdownByDepartment dept in refitem.BreakdownByDepartmentList)
                                {
                                    if (dept.DeptID == req.deptID)// not a new department for BreakdownByDepartment
                                    {
                                        IsNewDepartment = false;
                                        dept.Needed     = dept.Needed + reqitem.requisitionQty;
                                        dept.Actual     = dept.Needed;
                                        break;
                                    }
                                }
                                if (IsNewDepartment)//add new dept in refitem.BreakList
                                {
                                    BreakdownByDepartment b = new BreakdownByDepartment();
                                    b.DeptID = req.deptID;
                                    b.Needed = reqitem.requisitionQty;
                                    b.Actual = b.Needed;
                                    refitem.BreakdownByDepartmentList.Add(b);
                                }
                                break;
                            }
                        }
                        if (IsNewItem)//add new item in RequisitionFormList
                        {
                            RetrievalFormItem r = new RetrievalFormItem();
                            r.ItemID          = reqitem.itemID;
                            r.ItemDescription = reqitem.Item.description;
                            r.Location        = reqitem.Item.location;
                            r.Needed          = reqitem.requisitionQty;
                            r.Actual          = r.Needed;

                            BreakdownByDepartment b = new BreakdownByDepartment();
                            b.DeptID = req.deptID;
                            b.Needed = reqitem.requisitionQty;
                            b.Actual = b.Needed;
                            r.BreakdownByDepartmentList.Add(b);

                            refl.Add(r);
                        }
                    }
                }
            }
        }
Example #2
0
        //get item total quantity from requisitions with outstanding
        private void getRetrievalFormItemList(List <RetrievalFormItem> refl, List <Requisition> reql, List <Outstanding> outl)
        {
            //Add requisitions in RetrievalForm
            getRetrievalFormItemList(refl, reql);
            //Add outstandings in RetrievalForm
            bool IsNewItem       = true;
            bool IsNewDepartment = true;

            if (outl.Count > 0)
            {
                foreach (Outstanding outreq in outl)
                {
                    foreach (OutstandingItem outitem in outreq.OutstandingItems)
                    {
                        IsNewItem = true;//reset bool for every new item
                        foreach (RetrievalFormItem refitem in refl)
                        {
                            if (refitem.ItemID == outitem.itemID) //not a new item for RequisitionFormList
                            {
                                IsNewItem       = false;          //set bool
                                refitem.Needed  = refitem.Needed + outitem.expectedQty;
                                refitem.Actual  = refitem.Needed;
                                IsNewDepartment = true;//reset bool for every new item
                                foreach (BreakdownByDepartment dept in refitem.BreakdownByDepartmentList)
                                {
                                    if (dept.DeptID == outreq.deptID)// not a new department for BreakdownByDepartment
                                    {
                                        IsNewDepartment = false;
                                        dept.Needed     = dept.Needed + outitem.expectedQty;
                                        dept.Actual     = dept.Needed;
                                        break;
                                    }
                                }
                                if (IsNewDepartment)//add new dept in refitem.BreakList
                                {
                                    BreakdownByDepartment b = new BreakdownByDepartment();
                                    b.DeptID = outreq.deptID;
                                    b.Needed = outitem.expectedQty;
                                    b.Actual = b.Needed;
                                    refitem.BreakdownByDepartmentList.Add(b);
                                }
                                break;
                            }
                        }
                        if (IsNewItem)//add new item in RequisitionFormList
                        {
                            RetrievalFormItem r = new RetrievalFormItem();
                            r.ItemID          = outitem.itemID;
                            r.ItemDescription = outitem.Item.description;
                            r.Location        = outitem.Item.location;
                            r.Needed          = outitem.expectedQty;
                            r.Actual          = r.Needed;

                            BreakdownByDepartment b = new BreakdownByDepartment();
                            b.DeptID = outreq.deptID;
                            b.Needed = outitem.expectedQty;
                            b.Actual = b.Needed;
                            r.BreakdownByDepartmentList.Add(b);

                            refl.Add(r);
                        }
                    }
                }
            }
        }