Exemplo n.º 1
0
        public ActionResult Search(InvoiceSearchForm form)
        {
            List <Invoice>        invoices = invoiceProvider.SearchInvoice(form);
            List <InvoiceApiPoco> retour   = new List <InvoiceApiPoco>();

            invoices.ForEach(x => retour.Add(new InvoiceApiPoco(x)));
            return(Json(retour, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public ActionResult Index(InvoiceSearchForm form)
        {
            List <Invoice> result = new List <Invoice>();

            // if (form.ActiveSearch)
            result = invoiceProvider.SearchInvoice(form);
            ViewBag.contactform       = form;
            ViewBag.InvoiceSearchForm = form;
            return(View(result));
        }
Exemplo n.º 3
0
        public INVOICE.InvoiceResults SearchInvoice(InvoiceSearchForm form)
        {
            // string sql = "SELECT * FROM invoices where 1=1";
            Dictionary <string, object> ins = new Dictionary <string, object>();

            if (form == null)
            {
                form = new InvoiceSearchForm();
            }

            List <string> wheres = new List <string>();

            try
            {
                if (!string.IsNullOrWhiteSpace(form.CustomerRef))
                {
                    ins.Add("CustomerRef", form.CustomerRef); wheres.Add(" CustomerRef=@CustomerRef");
                }
                if (!string.IsNullOrWhiteSpace(form.InvoiceTitle))
                {
                    ins.Add("InvoiceTitle", form.InvoiceTitle); wheres.Add(" InvoiceTitle=@InvoiceTitle");
                }
                if (!string.IsNullOrWhiteSpace(form.InvoiceType))
                {
                    ins.Add("InvoiceType", form.InvoiceType); wheres.Add(" InvoiceType=@InvoiceType");
                }
                if (!string.IsNullOrWhiteSpace(form.ProviderRef))
                {
                    ins.Add("ProviderRef", form.ProviderRef); wheres.Add(" ProviderRef=@ProviderRef");
                }
                if (!string.IsNullOrWhiteSpace(form.RefInvoice))
                {
                    ins.Add("RefInvoice", form.RefInvoice); wheres.Add(" RefInvoice=@RefInvoice");
                }
                //if (form.DateAcq.HasValue)  {ins.Add("DateAcq", form.DateAcq.Value); wheres.Add(" and InvoiceTitle=@InvoiceTitle"); }
                //if (form.DateCreate.HasValue)  {ins.Add("DateCreate", form.DateCreate.Value); wheres.Add(" and InvoiceTitle=@InvoiceTitle"); }
                if (form.DateInvoice.HasValue)
                {
                    ins.Add("DateInvoice", form.DateInvoice.Value); wheres.Add(" DateInvoice=@DateInvoice");
                }
                //if (form.DatePaid.HasValue)  {ins.Add("DatePaid", form.DatePaid.Value); wheres.Add(" and InvoiceTitle=@InvoiceTitle"); }
                //if (form.DateSend.HasValue) { ins.Add("DateSend", form.DateSend.Value); wheres.Add(" and InvoiceTitle=@InvoiceTitle"); }
                //if (form.DateValidate.HasValue)  { ins.Add("DateValidate", form.DateValidate.Value); wheres.Add( " and InvoiceTitle=@InvoiceTitle"); }

                string sql = " FROM invoices ";
                if (wheres.Count > 0)
                {
                    sql += string.Join(" AND ", wheres.ToArray());
                }

                InvoiceResults retour = new InvoiceResults();
                int            nb     = Convert.ToInt32(this.Connector.QueryScalar("SELECT COUNT(*) as nb " + sql, ins));
                retour.TotalCountResults = nb;

                System.Data.DataTable ret = this.Connector.Query("SELECT * " + sql, ins);

                retour.LoadFromDataTable(ret);
                return(retour);
            }
            catch (Exception ex)
            {
                throw new Exception("SearchInvoice " + ex.Message, ex);
            }
        }