Example #1
0
        private void addButton_Click(object sender, EventArgs e)
        {
            FormValue <string, string> formValue = changeComboBox(groupComboBox.Text);

            controller.addButtonClick(formValue);

            dataGridViewImpurityQuality.Rows.Clear();
            DAO.getInstance().selectImpurityTable(formValue.getKey(), dataGridViewImpurityQuality);
            dataGridViewImpurityQuality.ClearSelection();
        }
Example #2
0
 public bool onSaveClick(FormValue <string, string> formValue, string value)
 {
     if (!DAO.getInstance().addNote(formValue.getKey(), new FormValue <string, string> (formValue.getValue(), value)))
     {
         MessageBox.Show("Данный показатель уже существует!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return(false);
     }
     else
     {
         return(true);
     }
 }
Example #3
0
        public void deleteNote(string nameTable, FormValue<string, string> primaryKey)
        {
            string sqlCommand;
            sqlCommand = string.Format("Delete {0} where {1}='{2}'", nameTable, primaryKey.getKey(), primaryKey.getValue());

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                SqlCommand cmd = new SqlCommand(sqlCommand, connection);
                cmd.ExecuteNonQuery();
                connection.Close();
            }
        }
 public void deleteButtonClick(FormValue <string, string> formValue, string id)
 {
     DAO.getInstance().deleteNote(formValue.getKey(), new FormValue <string, string> (formValue.getValue(), id));
 }
Example #5
0
        public void updateNote(string nameTable, FormValue<string, string> primaryKey, params FormValue<string, string>[] values)
        {
            string sqlCommand;
            string settingString = string.Empty;
            if (values.Length > 0) settingString += values[0].getKey() + "='" + values[0].getValue() + "'";
            for (int i = 1; i < values.Length; i++)
            {
                settingString += ", " + values[i].getKey() + "='" + values[i].getValue() + "'";
            }
            sqlCommand = string.Format("Update {0} Set {1} where {2}='{3}'", nameTable, settingString, primaryKey.getKey(), primaryKey.getValue());

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                SqlCommand cmd = new SqlCommand(sqlCommand, connection);
                cmd.ExecuteNonQuery();
                connection.Close();
            }
        }
Example #6
0
        public DataTable findRow(string nameTable, FormValue<string, string> value)
        {
            string sqlCommand = string.Empty;
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                sqlCommand = string.Format("Select * From {0} where UPPER(REPLACE({1},' ','')) LIKE(UPPER(REPLACE('{2}',' ','')))", nameTable, value.getKey(),  " %" + value.getValue().Trim() + "%");
                connection.Open();
                SqlDataAdapter dataAdapter = new SqlDataAdapter(sqlCommand, connection);
                SqlCommandBuilder builder = new SqlCommandBuilder(dataAdapter);

                DataTable table = new DataTable();
                dataAdapter.Fill(table);
                connection.Close();
                return table;
            }
        }