//Test Search by Criteria protected void ButtonFind_Click(object sender, EventArgs e) { AdjustmentVoucherTransactionSearchDTO criteria = new AdjustmentVoucherTransactionSearchDTO(); if (rbnStockLogID.Checked) { criteria.StockLogTransactionID = Convert.ToInt32(TextBox1.Text.ToString()); } if (rbnAdjVoucherTran.Checked) { criteria.AdjustmentVoucherTransactionID = Convert.ToInt32(TextBox1.Text.ToString()); } if (rbnStationeryID.Checked) { criteria.StationeryID = Convert.ToInt32(TextBox1.Text.ToString()); } if (rbnType.Checked) { criteria.Type = Convert.ToInt32(TextBox1.Text.ToString()); } if (rbnReason.Checked) { criteria.Reason = TextBox1.Text.ToString(); } if (rbnQty.Checked) { criteria.Quantity = Convert.ToInt32(TextBox1.Text.ToString()); } if (rbnBal.Checked) { criteria.Balance = Convert.ToInt32(TextBox1.Text.ToString()); } using (AdjustmentVoucherManager adjm = new AdjustmentVoucherManager()) { List<StockLogTransaction> slt = adjm.GetAllStockLogTransactionByCriteria(criteria); this.GridView1.DataSource = slt; this.GridView1.DataBind(); } }
public List<StockLogTransaction> GetAllStockLogTransactionByCriteria(AdjustmentVoucherTransactionSearchDTO adjustmentVoucherTransactionSearchDTO) { try { var Query = from u in context.StockLogTransactions where u.StockLogTransactionID == (adjustmentVoucherTransactionSearchDTO.StockLogTransactionID == 0 ? u.StockLogTransactionID : adjustmentVoucherTransactionSearchDTO.StockLogTransactionID) && u.AdjustmentVoucherTransactionID == (adjustmentVoucherTransactionSearchDTO.AdjustmentVoucherTransactionID == 0 ? u.AdjustmentVoucherTransactionID : adjustmentVoucherTransactionSearchDTO.AdjustmentVoucherTransactionID) && u.StationeryID == (adjustmentVoucherTransactionSearchDTO.StationeryID == 0 ? u.Type : adjustmentVoucherTransactionSearchDTO.StationeryID) && u.Type == (adjustmentVoucherTransactionSearchDTO.Type == 0 ? u.Type : adjustmentVoucherTransactionSearchDTO.Type) && u.Reason == (adjustmentVoucherTransactionSearchDTO.Reason == null ? u.Reason : adjustmentVoucherTransactionSearchDTO.Reason) && u.Quantity == (adjustmentVoucherTransactionSearchDTO.Quantity == 0 ? u.Quantity : adjustmentVoucherTransactionSearchDTO.Quantity) && u.Balance == (adjustmentVoucherTransactionSearchDTO.Balance == 0 ? u.Balance : adjustmentVoucherTransactionSearchDTO.Balance) select u; List<StockLogTransaction> stockLogTransaction = Query.ToList<StockLogTransaction>(); return stockLogTransaction; } catch (Exception ex) { throw new Exception("Stock Log Transaction Get All Records By Criteria Return Error" + ex.Message); } }
//Need to FindByCriteria Temp Table AdjustmentVoucherTransaction public List<AdjustmentVoucherTransaction> FindAdjustmentVoucherTransactionsByCriteria(AdjustmentVoucherTransactionSearchDTO adjustmentVoucherTransactionSearchDTO) { var tempQuery = (from r in context.AdjustmentVoucherTransactions where 1 == 1 select r); if (adjustmentVoucherTransactionSearchDTO != null) { if (adjustmentVoucherTransactionSearchDTO.AdjustmentVoucherTransactionID != -1) { tempQuery = tempQuery.Where(r => r.AdjustmentVoucherTransactionID == adjustmentVoucherTransactionSearchDTO.AdjustmentVoucherTransactionID); } if (adjustmentVoucherTransactionSearchDTO.StartDate != null && adjustmentVoucherTransactionSearchDTO.EndDate != null) { tempQuery = tempQuery.Where(r => r.DateIssued >= adjustmentVoucherTransactionSearchDTO.StartDate && r.DateIssued <= adjustmentVoucherTransactionSearchDTO.EndDate); } if (adjustmentVoucherTransactionSearchDTO.StartDate != null) { tempQuery = tempQuery.Where(r => r.DateIssued == adjustmentVoucherTransactionSearchDTO.StartDate); } if (adjustmentVoucherTransactionSearchDTO.EndDate != null) { tempQuery = tempQuery.Where(r => r.DateIssued == adjustmentVoucherTransactionSearchDTO.EndDate); } } return (from q in tempQuery select q).ToList<AdjustmentVoucherTransaction>(); }
public List<StockLogTransaction> GetAllStockLogTransactionByCriteria(AdjustmentVoucherTransactionSearchDTO criteria) { try { return adjustmentVoucherDAO.GetAllStockLogTransactionByCriteria(criteria); } catch (Exception ex) { throw new Exception("Stock Log Transaction Get All Records By Criteria Return Error" + ex.Message); } }