Ejemplo n.º 1
0
        public frmSmallSearch(HTextBox textboxSearch)
        {
            InitializeComponent();
            ht = textboxSearch;
            if (ht._SearchTable != null)
            {
                sql = "Select ";

                string[] column = ht._SearchFields.Split('&');
                foreach (string a in column)
                {
                    field.Add(a.Split(':')[0], a.Split(':')[1]);
                    sql += " " + a.Split(':')[0] + ",";
                }
                sql = sql.Remove(sql.Length - 1);
                sql += " from " + ht._SearchTable + " where 1=1 ";
                //-----------------
                #region SearchFilter ABUBAKR 10 Sept 2013
                if (txtSearchfor.Text.Trim() != "" && ht._SearchFilter != null && ht._SearchFilter != "")
                    sql += " and " + ht._SearchFilter;
                #endregion

              string   NotActivesql = @"   SELECT     COLUMN_NAME
                             FROM         INFORMATION_SCHEMA.COLUMNS
                             WHERE      (TABLE_NAME = '" + ht._SearchTable + @"') and COLUMN_NAME = 'NotActive' ";
                DataTable dt = DataLayer.executeDataTable(NotActivesql);
                if (dt.Rows.Count != 0)
                    sql += "  and isnull( NotActive ,0) =0";

                dt = DataLayer.executeDataTable(sql);
                grid.DataSource = dt;
                foreach (DataGridViewColumn col in grid.Columns)
                {

                    col.HeaderText = field[col.Name];
                }
            }
        }
Ejemplo n.º 2
0
        public string Previous(string tableName, HTextBox co, string value, string criteria = "")
        {
            string code = "";
            try
            {
                if (value != "")
                {
                    string sql = @"Select top(1) isnull(" + co._FieldName + ",0) As PrevCode from " + tableName + " Where " + co._FieldName + " < " + value;
                    if (criteria != "") sql += " AND " + criteria;
                    sql += " Order BY " + co._FieldName + " desc";
                    code = DataLayer.Executescalar(sql);
                    if (code == null || code == "")
                    {
                        string sql2 = @"Select isnull(MIN(" + co._FieldName + "),0) As PrevCode  from " + tableName + " ";
                        if (criteria != "") sql2 += " Where " + criteria;
                        code = DataLayer.Executescalar(sql2);
                    }
                }
                else
                {
                    string sql = @"Select isnull(MIN(" + co._FieldName + "),0) As PrevCode  from " + tableName + " ";
                    if (criteria != "") sql += " Where " + criteria;
                    code = DataLayer.Executescalar(sql);
                }
            }
            catch (Exception)
            {

                MessageBox.Show("Exception : Previous()");
            }

            return code;
        }