Пример #1
0
 private void UsingSql(object sender, RoutedEventArgs e)
 {
     if (SQLQuery.Text.StartsWith("SELECT"))
     {
         MySqlLib.MySqlData.MySqlExecuteData.MyResultData result = new MySqlLib.MySqlData.MySqlExecuteData.MyResultData();
         result        = MySqlLib.MySqlData.MySqlExecuteData.SqlReturnDataset(SQLQuery.Text, connectStrWithDb);
         querySelected = true;
         if (result.HasError == false)
         {
             sqlSelectGrid.ItemsSource = result.ResultData.DefaultView;
             tabControl.SelectedIndex  = 5;
         }
         else
         {
             MessageBox.Show(result.ErrorText);
         }
     }
     else
     {
         MySqlLib.MySqlDataC.MySqlExecute.MyResult result = new MySqlLib.MySqlDataC.MySqlExecute.MyResult();
         result = MySqlLib.MySqlDataC.MySqlExecute.SqlNoneQuery(SQLQuery.Text, connectStrWithDb);
         if (result.HasError == false)
         {
             MessageBox.Show(result.ResultText);
         }
         else
         {
             MessageBox.Show(result.ErrorText);
         }
     }
 }
Пример #2
0
        private void AddEmployee()
        {
            string SQLQuery = "INSERT INTO employees VALUES(";

            TextBox[] textBoxes         = { ID, FullName, Passport, Organization };
            string[]  attributesHeaders = { "ID", "Full_Name", "Serial_And_Passport_Number", "Organization" };
            for (int i = 0; i < textBoxes.Length; i++)
            {
                if (textBoxes[i].Text != null && textBoxes[i].Text != "")
                {
                    SQLQuery += "'" + textBoxes[i].Text + "', ";
                }
            }
            if (ConfirmedByTheOrganization.SelectedIndex != -1)
            {
                SQLQuery += "'" + ConfirmedByTheOrganization.SelectedIndex + "')";
            }
            MySqlLib.MySqlDataC.MySqlExecute.MyResult result = new MySqlLib.MySqlDataC.MySqlExecute.MyResult();
            result = MySqlLib.MySqlDataC.MySqlExecute.SqlNoneQuery(SQLQuery, connectStr);
            if (result.HasError == false)
            {
                Close();
            }
            else
            {
                MessageBox.Show(result.ErrorText);
                MessageBox.Show(SQLQuery);
            }
        }
Пример #3
0
        private void Report_Input_SQL(string whichTable, int Session_ID)
        {
            string Session_ID_str = Session_ID == -1 ? "NULL" : "'" + Session_ID.ToString() + "'";

            MySqlLib.MySqlDataC.MySqlExecute.MyResult result = new MySqlLib.MySqlDataC.MySqlExecute.MyResult();
            string time = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");

            result = MySqlLib.MySqlDataC.MySqlExecute.SqlNoneQuery("INSERT INTO report_" + whichTable + " VALUES('" +
                                                                   currentEmployeeID + "', '" + time + "', " + Session_ID_str + ")", connectStr);
            if (result.HasError == false)
            {
                UpdateGrid("report");
                UpdateGrid(currentEmployeeID);
            }
            else
            {
                MessageBox.Show(result.ErrorText);
            }
        }
Пример #4
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (checkBoxes(comboBox1.SelectedIndex))
            {
                sourceXFromX.Content = "Формарование ссылки " + ++currentIndex + " из " + totalIndexes;
                if (currentIndex > totalIndexes)
                {
                    sourceXFromX.Content = "Формарование ссылки " + totalIndexes + " из " + totalIndexes;
                }
                FileStream file = new FileStream(@"XML\item.xml", FileMode.Open);
                XML = new byte[file.Length];
                file.Read(XML, 0, XML.Length);
                string tempXML = System.Text.Encoding.UTF8.GetString(XML);
                file.Close();
                string temp     = "";
                string SQLQuery = "";
                switch (comboBox1.SelectedIndex)
                {
                case 0:
                    temp += Name.Text + " [Электронный ресурс]/ Режим доступа: "
                            + LinkOrAuthors.Text + ".";

                    SQLQuery = "INSERT INTO electronic_resource VALUES('" +
                               Name.Text + "', '" + LinkOrAuthors.Text + "')";
                    break;

                case 1:
                    temp += LinkOrAuthors.Text;
                    if (!LinkOrAuthors.Text.EndsWith("."))
                    {
                        temp += ". ";
                    }
                    temp += " " + Name.Text + " [Текст] / – " +
                            City.Text + ": " + Publisher.Text + ", " + YearBox.Text + ". – " +
                            Pages.Text + " с.";
                    if (Volume.Text != null && Volume.Text != "")
                    {
                        temp += " – " + Volume.Text + " т.";
                    }

                    SQLQuery  = "INSERT INTO literature VALUES(";
                    SQLQuery += LinkOrAuthors.Text == "" ? "NULL" : "'" + LinkOrAuthors.Text + "'";
                    SQLQuery += ", '" + Name.Text + "', '" +
                                City.Text + "', '" + YearBox.Text + "', '" + Publisher.Text + "', ";
                    SQLQuery += Volume.Text == "" ? "NULL" : "'" + Volume.Text + "'";
                    SQLQuery += ", '" + Pages.Text + "')";
                    break;

                default: break;
                }

                MySqlLib.MySqlDataC.MySqlExecute.MyResult SQLResult = new MySqlLib.MySqlDataC.MySqlExecute.MyResult();
                SQLResult = MySqlLib.MySqlDataC.MySqlExecute.SqlNoneQuery(SQLQuery, connStr);

                tempXML            = tempXML.Replace("123456654321", temp);
                Name.Text          = "";
                YearBox.Text       = "";
                LinkOrAuthors.Text = "";
                Pages.Text         = "";
                Volume.Text        = "";
                City.Text          = "";
                Publisher.Text     = "";

                res += tempXML;

                if (currentIndex > totalIndexes)
                {
                    AddLinks();
                    MessageBoxResult result = MessageBox.Show("Готово", "", MessageBoxButton.OK, MessageBoxImage.Information);
                    Close();
                }
            }
        }