private void Filter_Click(object sender, EventArgs e) { if (_view.rcvMethod == "ALL") { _view.rcvs = _repository.GetRcvHeaderByDate(_view.startDate, _view.endDate); } else { _view.rcvs = _repository.GetRcvHeaderByDate(_view.startDate, _view.endDate).Where(x => x.ReceiptMethod == _view.rcvMethod).ToList(); } var result = _view.rcvs.OrderByDescending(o => o.ReceiptDate).ToList(); if (result != null) { if (!string.IsNullOrEmpty(_view.rcvNum)) { result = result.Where(x => x.ReceiptNum.Contains(_view.rcvNum)).ToList(); } if (!string.IsNullOrEmpty(_view.vendorNum)) { result = result.Where(x => x.VendorName == (_view.vendorNum)).ToList(); } } result = result.ToList(); _view.BindingData(result); }
private void Get_GRN(object sender, EventArgs e) { if (!string.IsNullOrEmpty(_view.headSeleted.VendorCode)) { POReceiptHeaderModel h = _view.headSeleted; POReceiptHeaderModel rcvHead = null; if (!string.IsNullOrEmpty(_view.grnFileter)) { var head = _repository.GetReceiptHeaderByNumber(_view.grnFileter); if (_view.headSeleted.VendorCode == head.VendorCode) { rcvHead = head; } else { MessageBox.Show("Vendor not match with header.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (rcvHead != null) { _view.rcvLines = _repository.GetRcvLineByHeaderID(rcvHead.ReceiptHeaderId); } else { List <POReceiptHeaderModel> list = _repository.GetRcvHeaderByDate(DateTime.Now.AddDays(-30), DateTime.Now) .Where(x => x.ReceivedFlag && x.VendorCode == _view.headSeleted.VendorCode && x.ReceiptMethod == "RECEIVE").ToList(); using (POReceiptListForm frm = new POReceiptListForm(list)) { frm.startDate = DateTime.Now; frm.endDate = DateTime.Now; frm.rcvMethod = "RECEIVE"; frm.ShowDialog(); if (frm.rcvsSelected != null) { var head = frm.rcvsSelected.FirstOrDefault(); if (_view.headSeleted.VendorCode == head.VendorCode) { rcvHead = head; _view.rcvLines = _repository.GetRcvLineByHeaderID(rcvHead.ReceiptHeaderId); } else { MessageBox.Show("Vendor not match with header.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } } if (_view.rcvLines != null) { _view.rcvLines.ToList().ForEach(c => c.QuantityShipped = 0); h.InvoiceNum = rcvHead.InvoiceNum; h.Attribute1 = rcvHead.ReceiptHeaderId.ToString(); h.Attribute2 = rcvHead.ReceiptNum; h.SourceType = rcvHead.SourceType; _view.BindingRcvLines(_view.rcvLines); _view.headSeleted = h; } } else { MessageBox.Show("Please select Vendor!.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }