Esempio n. 1
0
 /// <summary>
 /// Помечает клиента как удалённого.
 /// </summary>
 /// <param name="CustomerToDelete"></param>
 public void DeleteCustomer(CustomerClass CustomerToDelete)
 {
     using (SQLiteConnection DBConnection = new SQLiteConnection("data source=" + DBFileName))
     {
         DBConnection.Open();
         using (SQLiteCommand Command = new SQLiteCommand(DBConnection))
         {
             Command.CommandText = @"UPDATE client SET deleted = 1 WHERE ID = " + CustomerToDelete.IDcustomer + ";";
             MyDBLogger("Delete customer by ID: " + Command.CommandText);
             Command.ExecuteNonQuery();
         }
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Редактирует в базе клиента. Автор: Марина.
 /// </summary>
 public void EditCustomerDB(CustomerClass EditCustomer)
 {
     using (SQLiteConnection DBConnection = new SQLiteConnection("data source=" + DBFileName))
     {
         DBConnection.Open();
         using (SQLiteCommand Command = new SQLiteCommand(DBConnection))
         {
             Command.CommandText = @"UPDATE client SET name = '" + EditCustomer.FIOcustomer.ToUpper() + "', " +
                                   "phoneNumber ='" + EditCustomer.PhoneCustomer + "', " +
                                   "city = '" + EditCustomer.CityCustomer + "' " +
                                   "WHERE ID = '" + EditCustomer.IDcustomer + "';";
             MyDBLogger("Edit client whis SQL-command: " + Command.CommandText);
             Command.ExecuteNonQuery();
         }
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Записывает в базу нового клиента.
 /// </summary>
 /// <param name="NewCostomer"></param>
 public void AddNewCustomerDB(CustomerClass NewCostomer)
 {
     using (SQLiteConnection DBConnection = new SQLiteConnection("data source=" + DBFileName))
     {
         DBConnection.Open();
         using (SQLiteCommand Command = new SQLiteCommand(DBConnection))
         {
             Command.CommandText = @"INSERT INTO client (name, phoneNumber, city) VALUES ('" +
                                   NewCostomer.FIOcustomer.ToUpper() + "','" +
                                   NewCostomer.PhoneCustomer + "','" +
                                   NewCostomer.CityCustomer.ToUpper() + "');";
             MyDBLogger("Create client with SQL-command: " + Command.CommandText);
             Command.ExecuteNonQuery();
         }
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Считывает из базы клиента. Автор: Марина.
        /// </summary>
        public CustomerClass ReadCustomerDB(string CustomerID)
        {
            CustomerClass ReadedCustomer = new CustomerClass();

            ReadedCustomer.IDcustomer = CustomerID;
            using (SQLiteConnection DBConnection = new SQLiteConnection("data source=" + DBFileName))
            {
                DBConnection.Open();
                using (SQLiteCommand Command = new SQLiteCommand(DBConnection))
                {
                    // Считываем информацию о водителе
                    Command.CommandText = @"SELECT name, phoneNumber, city FROM client WHERE ID = '" + ReadedCustomer.IDcustomer + "';";
                    MyDBLogger("Select Client by ID: " + Command.CommandText);
                    using (SQLiteDataReader Reader = Command.ExecuteReader())
                    {
                        Reader.Read();
                        ReadedCustomer.FIOcustomer   = Reader.GetString(0);
                        ReadedCustomer.PhoneCustomer = Reader.GetValue(1).ToString();
                        ReadedCustomer.CityCustomer  = Reader.GetString(2);
                    }
                }
            }
            return(ReadedCustomer);
        }