Example #1
0
        private void Adjust(object sender, EventArgs e)
        {
            MetroGrid          grid  = sender as MetroGrid;
            List <POLineModel> temps = _repository.GetPOLineByPOID(_view.poLines.FirstOrDefault().PoHeaderId);

            if (grid.SelectedRows.Count > 0)
            {
                List <POLineModel> lines = new List <POLineModel>();

                foreach (DataGridViewRow item in grid.Rows)
                {
                    try
                    {
                        POLineModel line = (POLineModel)item.DataBoundItem;
                        POLineModel temp = temps.Where(x => x.PoLineId == line.PoLineId).FirstOrDefault();
                        if (line.Quantity != temp.Quantity)
                        {
                            lines.Add(line);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                if (lines.Count != 0)
                {
                    SaveLinesAdjust(lines);
                }
            }
        }
        private void GeneratePOLocation(IEnumerable <POReceiptLineModel> lines)
        {
            //POReceiptHeaderModel recHead = _view.headSeleted;
            IEnumerable <POReceiptLineModel> resultLines = lines;

            if (_view.headSeleted.ReceiptMethod == "RETURN")
            {
                resultLines = lines.Where(x => x.QuantityShipped < 0).ToList();
            }

            foreach (var recLine in resultLines)
            {
                POLineLocationModel loc = new POLineLocationModel();
                loc.PoHeaderId             = recLine.PoHeaderId;
                loc.PoLineId               = recLine.PoLineId;
                loc.Quantity               = recLine.QuantityShipped;
                loc.QuantityReceived       = recLine.QuantityShipped;
                loc.UnitMeasLookupCode     = recLine.UnitOfMeasure;
                loc.InspectionRequiredFlag = recLine.QcRequireInspcFlag;
                loc.ReceiptHeaderId        = recLine.ReceiptHeaderId;
                loc.ReceiptLineId          = recLine.ReceiptLineId;
                loc.ConfirmFlag            = "N";

                int id = _repoPurchase.InsertPoLineLocation(loc);
            }

            //Get PO Lines to Update PO Status ***Not support multi PO in same Receive.
            int poId = lines.FirstOrDefault().PoHeaderId;
            List <POLineModel> poLines = _repoPurchase.GetPOLineByPOID(poId);

            var result = poLines.GroupBy(x => x.ReceivedStatus)
                         .Select(group => new { ReceivedStatus = group.Key, Items = group.ToList() })
                         .ToList();

            POHeaderModel po = _repoPurchase.GetPOByID(poId);

            if (result.Count() == 1)
            {
                if (result.FirstOrDefault().ReceivedStatus == "Fill")
                {
                    po.StatusCode   = "FINALLY CLOSED";
                    po.ReceivedFlag = true;
                }
                else
                {
                    po.StatusCode   = "OPEN";
                    po.ReceivedFlag = false;
                }
            }
            else
            {
                po.StatusCode   = "OPEN";
                po.ReceivedFlag = false;
            }
            _repoPurchase.UpdatePO(po);
        }
Example #3
0
        private void GetPOLines()
        {
            List <string> state = new List <string> {
                "Pending", "Partial"
            };

            _view.line = _repository.GetPOLineByPOID(_view.po.PoHeaderId)
                         .Where(
                x => x.Status.Trim() == "APPROVED" &&
                state.Contains(x.ReceivedStatus) &&
                x.VendorId == _view.vendorId
                ).ToList();
            _view.BindingData(_view.line.OrderBy(o => o.PoLineNum).ToList());
        }