コード例 #1
0
        private string generateSQLStringFromSearchBox()
        {
            if (ModWindowCompanySearchTextBox.Text == "")
            {
                return("SELECT * FROM " + MainWindow.connectionObj.table1 + ";");
            }
            string cName = ModWindowCompanySearchTextBox.Text;

            DataModder.legalizeSQLString(ref cName);
            return("SELECT * FROM " + MainWindow.connectionObj.table1 + " WHERE " + MainWindow.connectionObj.table1CompanyName + " LIKE '" + ModWindowCompanySearchTextBox.Text + "%';");
        }
コード例 #2
0
        private void searchMethod()
        {
            if (StreamBox.SelectedIndex == -1)
            {
                StreamBox.SelectedIndex = 3;
            }
            if (ResponseBox.SelectedIndex == -1)
            {
                ResponseBox.SelectedIndex = 3;
            }
            string originalString = CompanyNameField.Text;
            string cNameTemp      = CompanyNameField.Text;

            DataModder.legalizeSQLString(ref cNameTemp);
            CompanyNameField.Text = cNameTemp;
            if ((SrNoField.Text == "") && (CompanyNameField.Text == "") && (DateOfApproachField.SelectedDate == null) && (ResponseBox.SelectedIndex == 3) && (StreamBox.SelectedIndex == 3))
            {
                fillTableHere("SELECT * FROM " + connectionObj.table1 + ";", ref company);
                modifyDGrid(company, DGrid);
            }
            else
            {
                string[] responseTable = new string[]
                {
                    "Yes",
                    "No",
                    "Floating",
                    ""
                };
                string[] streamTable = new string[]
                {
                    "CSE",
                    "ECE",
                    "CSE/ECE",
                    ""
                };
                string date;
                try
                {
                    date = DateTime.Parse(DateOfApproachField.SelectedDate.ToString()).ToString("yyyy-MM-dd");
                }
                catch (FormatException ex)
                {
                    date = "";
                }
                string cNum = "", cName = "", dOA = "", rspns = "", strm = "";
                if (SrNoField.Text != "")
                {
                    cNum = connectionObj.table1CompanyNum + " = '" + SrNoField.Text + "'|";
                }
                if (CompanyNameField.Text != "")
                {
                    if (InstaSearchCheckBox.IsChecked == false)
                    {
                        cName = connectionObj.table1CompanyName + " = '" + CompanyNameField.Text + "'|";
                    }
                    else
                    {
                        cName = connectionObj.table1CompanyName + " LIKE '" + CompanyNameField.Text + "%'|";
                    }
                }
                if (date != "")
                {
                    dOA = connectionObj.table1DateOfApproach + " = '" + date + "'|";
                }
                if (ResponseBox.SelectedIndex != 3)
                {
                    rspns = connectionObj.table1Response + " = '" + responseTable[ResponseBox.SelectedIndex] + "'|";
                }
                if (StreamBox.SelectedIndex != 3)
                {
                    strm = connectionObj.table1Stream + " = '" + streamTable[StreamBox.SelectedIndex] + "'|";
                }
                string   query      = "SELECT * FROM " + connectionObj.table1 + " WHERE " + cNum + cName + dOA + rspns + strm + ";";
                string[] querySplit = query.Split('|');
                query = "";
                for (int i = 0; i < querySplit.Length - 1; i++)
                {
                    if (i == querySplit.Length - 2)
                    {
                        query += querySplit[i] + ";";
                    }
                    else
                    {
                        query += querySplit[i] + " AND ";
                    }
                }
                fillTableHere(query, ref company);
                modifyDGrid(company, DGrid);
            }
        }