Ejemplo n.º 1
0
        // Executes query using passed params, places results in
        // passed IDMListView control
        // Calls must be preceded by a BindToLib
        public void ExecQuery(ref DataGridView IDMLView, string sWhereClause, string sFolderName, int iMaxRows, DocEntry.FormMain FormPrinc)
        {
            if (oQueryLib != null)
            {
                // Build the string necessary to bind to the database connection
                //sConnect = "provider=FnDBProvider;data source=" + oQueryLib.Name + ";Prompt=4;SystemType=" + ((int)(oQueryLib.SystemType)) + ";";
                // Build the query string

                //sQuery = "SELECT * FROM FnDocument ";
                sQuery = "SELECT * FROM Document ";
                SearchSQL   sqlObject   = new SearchSQL();
                SearchScope searchScope = new SearchScope(oQueryLib);
                if (sWhereClause.Length > 0)
                {
                    sQuery = sQuery + "WHERE " + sWhereClause;
                }

                // Set up the properties on the record set
                if (oRS != null)
                {
                    oRS = null;
                }
                //Set oMiBD = New ADODB.Connection
                //oMiBD.ConnectionString = sConnect
                //oMiBD.Open
                //oRS = new ADODB.Recordset();
                //FSQ20070521: UPGRADE_WARNING:Couldn't resolve default property of object oRS.ActiveConnection. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                //oRS.let_ActiveConnection(sConnect);
                //oRS.Properties["SupportsObjSet"].Value = true;
                if (iMaxRows > 0)
                {
                    //oRS.MaxRecords = iMaxRows;
                    sQuery = sQuery + " OPTIONS ( BATCHSIZE " + iMaxRows + " )";
                }
                //oRS.Properties["SearchFolderName"].Value = sFolderName;
                // All set up - pull the trigger
                //oRS.LockType = ADODB.LockTypeEnum.adLockOptimistic;
                //oRS.Open sQuery, oMiBD, adOpenKeyset, , adCmdText
                //oRS.Open sQuery, oMiBD, adOpenKeyset

                //oRS.Open(sQuery, Type.Missing, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockUnspecified, -1);
                sqlObject.SetQueryString(sQuery);
                //sqlObject.SetQueryString(mySQLString);
                oRS = searchScope.FetchRows(sqlObject, null, null, true);
                ShowResults(IDMLView, FormPrinc);
            }
            else
            {
                MessageBox.Show("Must set library!", Application.ProductName);
            }
        }
Ejemplo n.º 2
0
        public List<string> FNSearch(string sql)
        {
            List<string> result = new List<string>();

            SearchSQL searchSql = new SearchSQL(sql);
            SearchScope searchScope = new SearchScope(this._ceConn.objectStore);
            IRepositoryRowSet rowSet = searchScope.FetchRows(searchSql, null, null, null);

            if (rowSet.IsEmpty())
                return null;

            System.Collections.IEnumerator enumerator = rowSet.GetEnumerator();
            while (enumerator.MoveNext())
            {
                IRepositoryRow row = (IRepositoryRow)enumerator.Current;
                Id id = row.Properties.GetProperty("Id").GetIdValue();
                result.Add(id.ToString());
            }

            return result;
        }
        private void search_button_Click(object sender, RoutedEventArgs e)
        {
            this.Topmost = false;
            errorOccurred = false;
            TextRange _RText = new TextRange(richTextBox1.Document.ContentStart, richTextBox1.Document.ContentEnd);
            try
            {
                String tr = _RText.Text.TrimEnd();
                tr = tr.TrimStart();
                if (tr == "\r\n") tr = "";

                String date = (MaskedDate.Text[0] == '_') ? "" : MaskedDate.Text;

                String[] s = { "'" + ID_Txt.Text + "'","N'" + date + "'","N'" + textBox1.Text + "'","N'" + textBox2.Text + "'","N'" + textBox3.Text + "'","N'" + textBox4.Text
                    + "'","N'" + textBox5.Text + "'","N'" + textBox6.Text + "'","N'" + textBox7.Text + "'","N'" + textBox8.Text
                    + "'","N'" + textBox9.Text + "'","N'" + textBox10.Text + "'","N'" + textBox11.Text + "'","N'" + textBox12.Text
                    + "'","N'" + textBox13.Text + "'","N'" + textBox14.Text + "'","N'" + textBox15.Text + "'","N'" + textBox16.Text
                    + "'","N'" + textBox17.Text + "'","N'" + textBox18.Text + "'","N'" + MyPriceTextBox.getStringFromMasked(textBox19.Text)
                    + "'","N'" + MyPriceTextBox.getStringFromMasked(textBox20.Text)
                    + "'","N'" + textBox21.Text + "'", checkBox1.IsChecked.ToString() , checkBox2.IsChecked.ToString() , checkBox3.IsChecked.ToString()
                    , checkBox4.IsChecked.ToString() , checkBox5.IsChecked.ToString() , checkBox6.IsChecked.ToString()
                    , checkBox7.IsChecked.ToString() , checkBox8.IsChecked.ToString() , checkBox9.IsChecked.ToString()
                    , checkBox10.IsChecked.ToString() , checkBox11.IsChecked.ToString() , checkBox12.IsChecked.ToString()
                    , checkBox13.IsChecked.ToString() , checkBox14.IsChecked.ToString() , checkBox15.IsChecked.ToString()
                    , checkBox16.IsChecked.ToString() , checkBox17.IsChecked.ToString() , checkBox18.IsChecked.ToString()
                    , checkBox19.IsChecked.ToString() , checkBox20.IsChecked.ToString() , checkBox21.IsChecked.ToString()
                    , checkBox22.IsChecked.ToString() , checkBox23.IsChecked.ToString() , checkBox24.IsChecked.ToString()
                    , checkBox25.IsChecked.ToString() , checkBox26.IsChecked.ToString() , checkBox27.IsChecked.ToString()
                    ,"N'" + _RText.Text + "'","N'" + textBox22.Text + "'"};

                SearchSQL sq = new SearchSQL(s, "SearchApartmanMaskooniS");
                DataTable dt = sq.getResult();

                if (Show3D_checkBox.IsChecked == true)
                {
                    Result3D res3d = new Result3D();
                    res3d.dt = dt;
                    res3d.Show();
                }
                else
                {
                    ResultWindow res = new ResultWindow();
                    res.which = Codes.ApartmanMaskooniEstijari;

                    if (dt != null)
                    {
                        res.dt = dt.Copy();
                        if (cols == null)
                        {
                            cols = new string[dt.Columns.Count];
                            for (int i = 0; i < cols.Length; i++)
                            {
                                cols[i] = dt.Columns[i].ColumnName;
                            }
                        }
                        if (MaskedDate.Text == "____/__/__") dt.Columns.Remove(cols[1]);
                        if (textBox2.Text.Trim().Length == 0) dt.Columns.Remove(cols[3]);
                        if (textBox3.Text.Trim().Length == 0) dt.Columns.Remove(cols[4]);
                        if (textBox4.Text.Trim().Length == 0) dt.Columns.Remove(cols[5]);
                        if (textBox5.Text.Trim().Length == 0) dt.Columns.Remove(cols[6]);
                        if (textBox6.Text.Trim().Length == 0) dt.Columns.Remove(cols[7]);
                        if (textBox7.Text.Trim().Length == 0) dt.Columns.Remove(cols[8]);
                        if (textBox8.Text.Trim().Length == 0) dt.Columns.Remove(cols[9]);
                        if (textBox9.Text.Trim().Length == 0) dt.Columns.Remove(cols[10]);
                        if (textBox10.Text.Trim().Length == 0) dt.Columns.Remove(cols[11]);
                        if (textBox11.Text.Trim().Length == 0) dt.Columns.Remove(cols[12]);
                        if (textBox12.Text.Trim().Length == 0) dt.Columns.Remove(cols[13]);
                        if (textBox13.Text.Trim().Length == 0) dt.Columns.Remove(cols[14]);
                        if (textBox14.Text.Trim().Length == 0) dt.Columns.Remove(cols[15]);
                        if (textBox15.Text.Trim().Length == 0) dt.Columns.Remove(cols[16]);
                        if (textBox16.Text.Trim().Length == 0) dt.Columns.Remove(cols[17]);
                        if (textBox17.Text.Trim().Length == 0) dt.Columns.Remove(cols[18]);
                        if (textBox18.Text.Trim().Length == 0) dt.Columns.Remove(cols[19]);
                        if (textBox21.Text.Trim().Length == 0) dt.Columns.Remove(cols[22]);
                        if (checkBox1.IsChecked == false) dt.Columns.Remove(cols[23]);
                        if (checkBox2.IsChecked == false) dt.Columns.Remove(cols[24]);
                        if (checkBox3.IsChecked == false) dt.Columns.Remove(cols[25]);
                        if (checkBox4.IsChecked == false) dt.Columns.Remove(cols[26]);
                        if (checkBox5.IsChecked == false) dt.Columns.Remove(cols[27]);
                        if (checkBox6.IsChecked == false) dt.Columns.Remove(cols[28]);
                        if (checkBox7.IsChecked == false) dt.Columns.Remove(cols[29]);
                        if (checkBox8.IsChecked == false) dt.Columns.Remove(cols[30]);
                        if (checkBox9.IsChecked == false) dt.Columns.Remove(cols[31]);
                        if (checkBox10.IsChecked == false) dt.Columns.Remove(cols[32]);
                        if (checkBox11.IsChecked == false) dt.Columns.Remove(cols[33]);
                        if (checkBox12.IsChecked == false) dt.Columns.Remove(cols[34]);
                        if (checkBox13.IsChecked == false) dt.Columns.Remove(cols[35]);
                        if (checkBox14.IsChecked == false) dt.Columns.Remove(cols[36]);
                        if (checkBox15.IsChecked == false) dt.Columns.Remove(cols[37]);
                        if (checkBox16.IsChecked == false) dt.Columns.Remove(cols[38]);
                        if (checkBox17.IsChecked == false) dt.Columns.Remove(cols[39]);
                        if (checkBox18.IsChecked == false) dt.Columns.Remove(cols[40]);
                        if (checkBox19.IsChecked == false) dt.Columns.Remove(cols[41]);
                        if (checkBox20.IsChecked == false) dt.Columns.Remove(cols[42]);
                        if (checkBox21.IsChecked == false) dt.Columns.Remove(cols[43]);
                        if (checkBox22.IsChecked == false) dt.Columns.Remove(cols[44]);
                        if (checkBox23.IsChecked == false) dt.Columns.Remove(cols[45]);
                        if (checkBox24.IsChecked == false) dt.Columns.Remove(cols[46]);
                        if (checkBox25.IsChecked == false) dt.Columns.Remove(cols[47]);
                        if (checkBox26.IsChecked == false) dt.Columns.Remove(cols[48]);
                        if (checkBox27.IsChecked == false) dt.Columns.Remove(cols[49]);
                        if (_RText.Text == "\r\n") dt.Columns.Remove(cols[50]);
                        if (textBox22.Text.Length == 0) dt.Columns.Remove(cols[51]);
                    }
                    res.gridView.DataSource = dt;
                    res.Show();
                }
            }
            catch (Exception)
            {
                errorOccurred = true;
                MessageBox.Show("خطا در اتصال و یا اجرای درخواست از پایگاه داده ها", "خطا", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 4
0
        private void search_button_Click(object sender, RoutedEventArgs e)
        {
            this.Topmost  = false;
            errorOccurred = false;
            TextRange _RText = new TextRange(richTextBox1.Document.ContentStart, richTextBox1.Document.ContentEnd);

            try
            {
                String tr = _RText.Text.TrimEnd();
                tr = tr.TrimStart();
                if (tr == "\r\n")
                {
                    tr = "";
                }

                String date = (MaskedDate.Text[0] == '_') ? "" : MaskedDate.Text;

                String[] s = { "'" + ID_Txt.Text + "'", "N'" + date + "'",               "N'" + textBox1.Text + "'",      "N'" + textBox2.Text + "'",     "N'" + textBox3.Text + "'", "N'" + textBox4.Text
                               + "'",                   "N'" + textBox5.Text + "'",      "N'" + textBox6.Text + "'",      "N'" + textBox7.Text + "'",     "N'" + textBox8.Text
                               + "'",                   "N'" + textBox9.Text + "'",      "N'" + textBox10.Text + "'",     "N'" + textBox11.Text + "'",    "N'" + textBox12.Text
                               + "'",                   "N'" + textBox13.Text + "'",     "N'" + textBox14.Text + "'",     "N'" + textBox15.Text + "'",    "N'" + textBox16.Text
                               + "'",                   "N'" + textBox17.Text + "'",     "N'" + textBox18.Text + "'",     "N'" + MyPriceTextBox.getStringFromMasked(textBox19.Text)
                               + "'",                   "N'" + MyPriceTextBox.getStringFromMasked(textBox20.Text)
                               + "'",                   "N'" + textBox21.Text + "'",     checkBox1.IsChecked.ToString(),  checkBox2.IsChecked.ToString(), checkBox3.IsChecked.ToString()
                               ,                        checkBox4.IsChecked.ToString(),  checkBox5.IsChecked.ToString(),  checkBox6.IsChecked.ToString()
                               ,                        checkBox7.IsChecked.ToString(),  checkBox8.IsChecked.ToString(),  checkBox9.IsChecked.ToString()
                               ,                        checkBox10.IsChecked.ToString(), checkBox11.IsChecked.ToString(), checkBox12.IsChecked.ToString()
                               ,                        checkBox13.IsChecked.ToString(), checkBox14.IsChecked.ToString(), checkBox15.IsChecked.ToString()
                               ,                        checkBox16.IsChecked.ToString(), checkBox17.IsChecked.ToString(), checkBox18.IsChecked.ToString()
                               ,                        checkBox19.IsChecked.ToString(), checkBox20.IsChecked.ToString(), checkBox21.IsChecked.ToString()
                               ,                        checkBox22.IsChecked.ToString(), checkBox23.IsChecked.ToString(), checkBox24.IsChecked.ToString()
                               ,                        checkBox25.IsChecked.ToString(), checkBox26.IsChecked.ToString(), checkBox27.IsChecked.ToString()
                               ,                        "N'" + _RText.Text + "'",        "N'" + textBox22.Text + "'" };

                SearchSQL sq = new SearchSQL(s, "SearchApartmanMaskooniS");
                DataTable dt = sq.getResult(DBComboBox.SelectedIndex);

                if (Show3D_checkBox.IsChecked == true)
                {
                    Result3D res3d = new Result3D();
                    res3d.dt = dt;
                    res3d.Show();
                }
                else
                {
                    ResultWindow res = new ResultWindow();
                    res.session = session;
                    res.which   = Codes.ApartmanMaskooniEstijari;

                    if (dt != null)
                    {
                        res.dt = dt.Copy();
                        if (cols == null)
                        {
                            cols = new string[dt.Columns.Count];
                            for (int i = 0; i < cols.Length; i++)
                            {
                                cols[i] = dt.Columns[i].ColumnName;
                            }
                        }
                        if (MaskedDate.Text == "____/__/__")
                        {
                            dt.Columns.Remove(cols[1]);
                        }
                        if (textBox2.Text.Trim().Length == 0)
                        {
                            dt.Columns.Remove(cols[3]);
                        }
                        if (textBox3.Text.Trim().Length == 0)
                        {
                            dt.Columns.Remove(cols[4]);
                        }
                        if (textBox4.Text.Trim().Length == 0)
                        {
                            dt.Columns.Remove(cols[5]);
                        }
                        if (textBox5.Text.Trim().Length == 0)
                        {
                            dt.Columns.Remove(cols[6]);
                        }
                        if (textBox6.Text.Trim().Length == 0)
                        {
                            dt.Columns.Remove(cols[7]);
                        }
                        if (textBox7.Text.Trim().Length == 0)
                        {
                            dt.Columns.Remove(cols[8]);
                        }
                        if (textBox8.Text.Trim().Length == 0)
                        {
                            dt.Columns.Remove(cols[9]);
                        }
                        if (textBox9.Text.Trim().Length == 0)
                        {
                            dt.Columns.Remove(cols[10]);
                        }
                        if (textBox10.Text.Trim().Length == 0)
                        {
                            dt.Columns.Remove(cols[11]);
                        }
                        if (textBox11.Text.Trim().Length == 0)
                        {
                            dt.Columns.Remove(cols[12]);
                        }
                        if (textBox12.Text.Trim().Length == 0)
                        {
                            dt.Columns.Remove(cols[13]);
                        }
                        if (textBox13.Text.Trim().Length == 0)
                        {
                            dt.Columns.Remove(cols[14]);
                        }
                        if (textBox14.Text.Trim().Length == 0)
                        {
                            dt.Columns.Remove(cols[15]);
                        }
                        if (textBox15.Text.Trim().Length == 0)
                        {
                            dt.Columns.Remove(cols[16]);
                        }
                        if (textBox16.Text.Trim().Length == 0)
                        {
                            dt.Columns.Remove(cols[17]);
                        }
                        if (textBox17.Text.Trim().Length == 0)
                        {
                            dt.Columns.Remove(cols[18]);
                        }
                        if (textBox18.Text.Trim().Length == 0)
                        {
                            dt.Columns.Remove(cols[19]);
                        }
                        if (textBox21.Text.Trim().Length == 0)
                        {
                            dt.Columns.Remove(cols[22]);
                        }
                        if (checkBox1.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[23]);
                        }
                        if (checkBox2.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[24]);
                        }
                        if (checkBox3.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[25]);
                        }
                        if (checkBox4.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[26]);
                        }
                        if (checkBox5.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[27]);
                        }
                        if (checkBox6.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[28]);
                        }
                        if (checkBox7.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[29]);
                        }
                        if (checkBox8.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[30]);
                        }
                        if (checkBox9.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[31]);
                        }
                        if (checkBox10.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[32]);
                        }
                        if (checkBox11.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[33]);
                        }
                        if (checkBox12.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[34]);
                        }
                        if (checkBox13.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[35]);
                        }
                        if (checkBox14.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[36]);
                        }
                        if (checkBox15.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[37]);
                        }
                        if (checkBox16.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[38]);
                        }
                        if (checkBox17.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[39]);
                        }
                        if (checkBox18.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[40]);
                        }
                        if (checkBox19.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[41]);
                        }
                        if (checkBox20.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[42]);
                        }
                        if (checkBox21.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[43]);
                        }
                        if (checkBox22.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[44]);
                        }
                        if (checkBox23.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[45]);
                        }
                        if (checkBox24.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[46]);
                        }
                        if (checkBox25.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[47]);
                        }
                        if (checkBox26.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[48]);
                        }
                        if (checkBox27.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[49]);
                        }
                        if (_RText.Text == "\r\n")
                        {
                            dt.Columns.Remove(cols[50]);
                        }
                        if (textBox22.Text.Length == 0)
                        {
                            dt.Columns.Remove(cols[51]);
                        }
                    }
                    res.gridView.DataSource = dt;
                    res.dbIndex             = DBComboBox.SelectedIndex;
                    res.Show();
                }
            }
            catch (Exception)
            {
                errorOccurred = true;
                MessageBox.Show("خطا در اتصال و یا اجرای درخواست از پایگاه داده ها", "خطا", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 5
0
 public IDocumentSet queryDocs(string sSql, int maxRecords, int pageSize)
 {
     logMsg("mkQuery(" + sSql + "), maxRecords=" + maxRecords + ", batchSize=" + pageSize + "...");
     SearchScope search = new SearchScope(objStore);
     SearchSQL searchSql = new SearchSQL();
     if (maxRecords > 0)
         searchSql.SetMaxRecords(maxRecords);
     // This must be done separately in order to call SetMaxRecords() etc
     searchSql.SetQueryString(sSql); 
     IDocumentSet documents =
         (IDocumentSet)search.FetchObjects(searchSql, pageSize, null, true);
     return documents;
 }
Ejemplo n.º 6
0
        // Executes query using passed params, places results in
        // passed IDMListView control
        // Calls must be preceded by a BindToLib
        public void ExecQuery(ref DataGridView IDMLView, string sWhereClause, string sFolderName, int iMaxRows) //AxIDMListView.AxIDMListView
        {
            if (objObjectStore != null)
            {
                // Build the string necessary to bind to the database connection
                //sConnect = "provider=FnDBProvider;data source=" + oQueryLib.Name + ";Prompt=4;SystemType=" + ((int)oQueryLib.SystemType) + ";";
                // Build the query string

                String mySQLString = "SELECT * FROM ExpedientesDC  ";
                //String mySQLString = "SELECT * FROM Document  ";
                SearchSQL sqlObject = new SearchSQL();


                // The SearchSQL instance (sqlObject) can then be specified in the
                // SearchScope parameter list to execute the search. Uses fetchRows to test the SQL
                // statement.
                SearchScope searchScope = new SearchScope(objObjectStore);

                if (sWhereClause.Length > 0)
                {
                    sQuery = "";
                    sQuery = sQuery + "WHERE VersionStatus=1 " + sWhereClause;
                    //sQuery = sQuery + "WHERE VersionStatus=1 ";
                }

                // Set up the properties on the record set
                //if (oRS != null)
                //{
                oRS = null;
                //}
                //Set oMiBD = New ADODB.Connection
                //oMiBD.ConnectionString = sConnect
                //oMiBD.Open
                //oRS = new ADODB.Recordset();

                //oRS.let_ActiveConnection(sConnect);
                //oRS.Properties["SupportsObjSet"].Value = true;
                if (iMaxRows > 0)
                {
                    //searchScope.
                    //oRS.MaxRecords = iMaxRows;
                    sQuery = sQuery + " OPTIONS ( BATCHSIZE " + iMaxRows + " )";
                }
                //oRS.Properties["SearchFolderName"].Value = sFolderName;
                // All set up - pull the trigger
                //oRS.LockType = ADODB.LockTypeEnum.adLockOptimistic;
                //oRS.Open sQuery, oMiBD, adOpenKeyset, , adCmdText
                //oRS.Open sQuery, oMiBD, adOpenKeyset
                //oRS.Open(sQuery, Type.Missing, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockUnspecified, -1);

                try
                {
                    //MessageBox.Show("Query: " + mySQLString + sQuery);
                    sqlObject.SetQueryString(mySQLString + sQuery);
                    //sqlObject.SetQueryString(mySQLString);
                    oRS = searchScope.FetchRows(sqlObject, null, null, true);


                    ShowResults(ref IDMLView);
                }
                catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                MessageBox.Show("Must set library!", Application.ProductName);
            }
        }