Ejemplo n.º 1
0
        private string rental_form_sql_builder(string[] sql_field, Control[] fields, validation.types[] types)
        {
            validation val           = new validation();
            string     where_sql_Cmd = "";

            for (int i = 0; i < fields.Length; i++)
            {
                if (fields[i].Text == "" || !val.validate(fields[i].Text, types[i]) || fields[i].Text == "0")
                {
                    continue;
                }
                if ((fields[i] == rentals_search_rented_Date && rentals_search_use_date_Rented.Checked == true) ||
                    (fields[i] == rentals_search_return_Date && rentals_search_use_date_Return.Checked == true))
                {
                    where_sql_Cmd += "AND " + sql_field[i] + " = " + ((fields[i] as DateTimePicker).Value.Date).ToString() + "";
                }
                else if (fields[i] is NumericUpDown)
                {
                    where_sql_Cmd += "AND " + sql_field[i] + " = " + fields[i].Text + "";
                }
                else
                {
                    where_sql_Cmd += "AND " + sql_field[i] + " LIKE '%" + fields[i].Text + "%' ";
                }
            } // end of for
            return(where_sql_Cmd);
        }
Ejemplo n.º 2
0
        private string form_sql_builder(string[] sql_field, Control[] fields, validation.types[] types)
        {
            validation val           = new validation();
            string     where_sql_Cmd = "";

            for (int i = 0; i < fields.Length; i++)
            {
                if (fields[i].Text == "" || !val.validate(fields[i].Text, types[i]) || fields[i].Text == "0")
                {
                    continue;
                }

                if (where_sql_Cmd == "")
                {
                    if (fields[i] == branches_search_Address1 || fields[i] == branches_search_Phonenumber)
                    {
                        where_sql_Cmd += "WHERE (" + sql_field[i] + " LIKE '%" + fields[i].Text + "%' OR " +
                                         sql_field[i] + " LIKE '%" + fields[i].Text + "%') ";
                    }
                    else
                    {
                        where_sql_Cmd += "WHERE " + sql_field[i] + " LIKE '%" + fields[i].Text + "%' ";
                    }
                }
                else
                {
                    if (fields[i] == branches_search_Address1 || fields[i] == branches_search_Phonenumber)
                    {
                        where_sql_Cmd += "AND (" + sql_field[i] + " LIKE '%" + fields[i].Text + "%' OR " +
                                         sql_field[i + 2] + " LIKE '%" + fields[i].Text + "%') ";
                    }
                    else
                    {
                        where_sql_Cmd += "AND " + sql_field[i] + " LIKE '%" + fields[i].Text + "%' ";
                    }
                }
            } // end of for
            return(where_sql_Cmd);
        }