private void Search() { try { SearchVouchersDTO lObjSearchVouchers = new SearchVouchersDTO(); lObjSearchVouchers.Area = txtArea.Value; if (string.IsNullOrEmpty(txtEmploye.Value)) { mStrEmployeId = ""; } if (string.IsNullOrEmpty(cboStatus.Value)) { lObjSearchVouchers.Status = 0; } else { lObjSearchVouchers.Status = Convert.ToInt32(cboStatus.Value); } lObjSearchVouchers.Employee = mStrEmployeId; lObjSearchVouchers.StartDate = txtStartD.Value; lObjSearchVouchers.EndDate = txtEndDate.Value; List <Vouchers> lLstVouchers = new List <Vouchers>(); lLstVouchers = mObjPurchasesServiceFactory.GetPurchaseVouchersService().GetVouchersList(lObjSearchVouchers).ToList(); if (DtMatrix == null) { CreateDataTableMatrix(); } else { DtMatrix.Rows.Clear(); } FillMatrix(lLstVouchers); } catch (Exception ex) { UIApplication.ShowMessageBox(ex.Message); LogService.WriteError("frmSearchRefunds (btnSearch_ClickBefore) " + ex.Message); LogService.WriteError(ex); } }
public IList <Vouchers> GetVouchersList(SearchVouchersDTO pObjSearchVouchersDTO) { return(lObjPurchaseVoucher.GetVouchersList(pObjSearchVouchersDTO)); }
/// <summary> /// Agregar filtros a la consulta. /// </summary> private List <string> GetFilterssVouchers(SearchVouchersDTO pObjSearchVouchersDTO, Dictionary <string, string> lLstStrParameters) { List <string> lLstFilters = new List <string>(); try { string lStrWereAnd = "and"; //simepre sera And por la condicion de if (!string.IsNullOrEmpty(pObjSearchVouchersDTO.Area)) { lLstFilters.Add(lStrWereAnd + " U_Area = '{Area}'"); lLstStrParameters.Add("Area", pObjSearchVouchersDTO.Area); lStrWereAnd = "and"; } if (!string.IsNullOrEmpty(pObjSearchVouchersDTO.Employee)) { lLstFilters.Add(lStrWereAnd + " U_Employee = '{Employee}' "); lLstStrParameters.Add("Employee", pObjSearchVouchersDTO.Employee); lStrWereAnd = "and"; } else { lLstFilters.Add(""); } if (!string.IsNullOrEmpty(pObjSearchVouchersDTO.StartDate.ToString()) && !string.IsNullOrEmpty(pObjSearchVouchersDTO.EndDate.ToString())) { lLstFilters.Add(lStrWereAnd + " U_Date between '{StartDate}' and '{EndDate}' "); lLstStrParameters.Add("StartDate", pObjSearchVouchersDTO.StartDate); lLstStrParameters.Add("EndDate", pObjSearchVouchersDTO.EndDate); lStrWereAnd = "and"; } else { if (!string.IsNullOrEmpty(pObjSearchVouchersDTO.StartDate.ToString())) { lLstFilters.Add(lStrWereAnd + " U_Date = '{StartDate}' "); lLstStrParameters.Add("StartDate", pObjSearchVouchersDTO.StartDate); lStrWereAnd = "and"; } else { lLstFilters.Add(""); } } if (pObjSearchVouchersDTO.Status > 0) { lLstFilters.Add(lStrWereAnd + " U_Status = '{Status}' "); lLstStrParameters.Add("Status", pObjSearchVouchersDTO.Status.ToString()); lStrWereAnd = "and"; } else { lLstFilters.Add(""); } } catch (Exception ex) { LogService.WriteError("PurchasesDAO (GetFilterssVouchers): " + ex.Message); LogService.WriteError(ex); } return(lLstFilters); }
/// <summary> /// Obtener lista de vouchers por filtro. /// </summary> public IList <Vouchers> GetVouchersList(SearchVouchersDTO pObjSearchVouchersDTO) { List <Vouchers> lLstObjVouchers = new List <Vouchers>(); SAPbobsCOM.Recordset lObjRecordset = null; try { string lStrQuery = this.GetSQL("GetVoucher"); Dictionary <string, string> lLstStrParameters = new Dictionary <string, string>(); foreach (string lStrFilter in GetFilterssVouchers(pObjSearchVouchersDTO, lLstStrParameters)) { lStrQuery += " " + lStrFilter; } lStrQuery += " order by Code desc"; //this.UIAPIRawForm.DataSources.DataTables.Item("RESULT").ExecuteQuery(lStrQuery); lObjRecordset = (SAPbobsCOM.Recordset)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); lStrQuery = lStrQuery.Inject(lLstStrParameters); lObjRecordset.DoQuery(lStrQuery); if (lObjRecordset.RecordCount > 0) { for (int i = 0; i < lObjRecordset.RecordCount; i++) { Vouchers lObjVoucher = new Vouchers(); lObjVoucher.RowCode = lObjRecordset.Fields.Item("Code").Value.ToString(); lObjVoucher.Folio = lObjRecordset.Fields.Item("U_Folio").Value.ToString(); lObjVoucher.Status = Convert.ToInt32(lObjRecordset.Fields.Item("U_Status").Value.ToString()); lObjVoucher.Area = lObjRecordset.Fields.Item("U_Area").Value.ToString(); lObjVoucher.Employee = lObjRecordset.Fields.Item("U_Employee").Value.ToString(); lObjVoucher.Date = Convert.ToDateTime(lObjRecordset.Fields.Item("U_Date").Value.ToString()); lObjVoucher.Total = Convert.ToDouble(lObjRecordset.Fields.Item("U_Total").Value.ToString()); double lDblTotal = Convert.ToDouble((lObjRecordset.Fields.Item("DocTotal").Value.ToString())); if (lObjVoucher.Total == lDblTotal && lObjVoucher.Status == (int)StatusEnum.Authorized_Ope_Admon) { //lObjVoucher.Status = 5; if (mObjPurchaseServiceFactory.GetVouchersService().Update(lObjVoucher.RowCode, StatusEnum.Closed) != 0) { string lStrerror = DIApplication.Company.GetLastErrorDescription(); UIApplication.ShowMessageBox(lStrerror); } else { lObjVoucher.Status = (int)StatusEnum.Closed; // lObStatusEnum.GetDescription(); } } lLstObjVouchers.Add(lObjVoucher); lObjRecordset.MoveNext(); } } } catch (Exception ex) { UIApplication.ShowMessageBox(string.Format("InitDataSourcesException: {0}", ex.Message)); LogService.WriteError("PurchasesDAO (GetVouchersList): " + ex.Message); LogService.WriteError(ex); } finally { MemoryUtility.ReleaseComObject(lObjRecordset); } return(lLstObjVouchers); }