Ejemplo n.º 1
0
        public override void CreateRecord(FieldTable tableField)
        {
            #region Добавление новой записи
            string sql_str = string.Empty;

            #region Формирую SQL запрос
            if (!string.IsNullOrEmpty(tableField.name))
            {
                sql_str = @"Insert into contacts_book.contact_fio (name,surname, middle_name, birthday, comments) 
                                                                    values('" + tableField.name + "', " +
                          "'" + tableField.surname + "', " +
                          "'" + tableField.middle_name + "', " +
                          "STR_TO_DATE('" + tableField.birthday + "', '%d.%m.%Y'), " +
                          "'" + tableField.comments + "'); ";
            }
            else if (!string.IsNullOrEmpty(tableField.contact_definition))
            {
                sql_str = @"insert into contacts_book.contact_type(contact_definition) values('" + tableField.contact_definition + "');";
            }
            else
            {
                sql_str = @"insert into contacts_book.contact_list(fio_id, type_id, value_) 
                                values(" + tableField.fio_id + ", " + tableField.type_id + ", '" + tableField.value_ + "');";
            }
            #endregion

            ExecutionSqlQuery(sql_str);

            #endregion
        }
Ejemplo n.º 2
0
        public override void UpdateRecord(FieldTable tableField)
        {
            #region Меняю записи
            string sql_str = string.Empty;

            #region Формирую SQL запрос
            if (tableField.id_list != 0)
            {
                sql_str = @"update contacts_book.contact_list set value_ ='" + tableField.value_ + "' " +
                          "where id_list = " + tableField.id_list + " and fio_id = " + tableField.fio_id + " ";
            }
            else
            {
                sql_str = @"update contacts_book.contact_fio 
                            set  
                                name = '" + tableField.name + "', " +
                          "    surname = '" + tableField.surname + "', " +
                          "    middle_name = '" + tableField.middle_name + "', " +
                          "    birthday = STR_TO_DATE('" + tableField.birthday + "','%d.%m.%Y'), " +
                          "    comments = '" + tableField.comments + "'" +
                          " where id_fio = " + tableField.fio_id + "";
            }
            #endregion


            ExecutionSqlQuery(sql_str);


            #endregion
        }
Ejemplo n.º 3
0
        public override DataTable SelectRecord(FieldTable tableField, string getViewTable)
        {
            #region Вывожу результирующую таблицы
            string sql_str = string.Empty;

            DataTable dt = new DataTable();
            switch (getViewTable)
            {
            case "Type":
                sql_str = "select * from contacts_book.contact_type order by idcontact_type";
                break;

            case "Fio":
                sql_str = "select * from contacts_book.contact_fio where id_fio = " + tableField.fio_id + "";
                break;

            case "List":
                sql_str = "select * from contacts_book.contact_list where fio_id = " + tableField.fio_id + "";
                break;
            }

            MySqlDataAdapter dataAdapter;

            try
            {
                string connectionString = ConnStr;

                using (MySqlConnection connection = new MySqlConnection(connectionString))
                {
                    dataAdapter = new MySqlDataAdapter(sql_str, connection);
                    connection.Open();
                    dataAdapter.Fill(dt);
                }
            }
            catch (Exception ex)
            {
                CreateStringErr(ex.Message);
            }


            return(dt);

            #endregion
        }
Ejemplo n.º 4
0
        public override void DeleteRecord(FieldTable tableField)
        {
            #region Удаление записи
            string sql_str = string.Empty;

            #region Формирую SQL запрос
            if (tableField.id_list != 0)
            {
                sql_str = @"delete from contacts_book.contact_list where id_list = " + tableField.id_list + " and fio_id = " + tableField.fio_id + " ";
            }
            else
            {
                sql_str = @"delete from contacts_book.contact_fio where id_fio = " + tableField.fio_id + "";
            }
            #endregion


            ExecutionSqlQuery(sql_str);


            #endregion
        }
Ejemplo n.º 5
0
 public abstract /*List<FieldTable>*/ DataTable SelectRecord(FieldTable tableField, string getViewTable);
Ejemplo n.º 6
0
 public abstract void UpdateRecord(FieldTable tableField);
Ejemplo n.º 7
0
 public abstract void DeleteRecord(FieldTable tableField);