public void NewCovArea(string District, string Street, int Num_house) { PROVIDER_DBDataContext dc = new PROVIDER_DBDataContext(); var CovArea = new coverage_areas() { district = District, street = Street, num_house = Num_house }; dc.coverage_areas.InsertOnSubmit(CovArea); // добавление в БД dc.SubmitChanges(); // выполняет соответствующие команды // для внесения изменений базы данных }
public void DelCovArea(int idCovArea) { PROVIDER_DBDataContext dc = new PROVIDER_DBDataContext(); coverage_areas ca = (from c in dc.coverage_areas where (c.coverage_area_id == idCovArea) select c).Single <coverage_areas>(); /*dc.OrderDetails.DeleteAllOnSubmit( * cust.Orders.SelectMany(o => o.OrderDetails)); * * dc.Orders.DeleteAllOnSubmit(cust.Orders);*/ dc.coverage_areas.DeleteOnSubmit(ca); dc.SubmitChanges(); //Добавление в БД }
public void NewTransaction(int Id_agreement, string Operation_type, int Transaction_amount, DateTime Transaction_date) { PROVIDER_DBDataContext dc = new PROVIDER_DBDataContext(); var Trans = new transactions() { id_agreement = Id_agreement, operation_type = Operation_type, transaction_amount = Transaction_amount, transaction_date = Transaction_date }; dc.transactions.InsertOnSubmit(Trans); // добавление в БД dc.SubmitChanges(); // выполняет соответствующие команды // для внесения изменений базы данных }
//---------------------------------------------------------------------- buttons changed ------ << //---------------------------------------------------------------------- buttons add ---------- >> private void btn_agreement_add_Click(object sender, EventArgs e) { var Agr = new agreements() { id_user = dc.users.FirstOrDefault(u => u.user_name == id_user.SelectedItem.ToString()).user_id, balance = Int32.Parse(balance.Value.ToString()), login = login.Text, password = password.Text, id_coverage_area = Int32.Parse(id_coverage_area.SelectedItem.ToString()), num_apartment = Int32.Parse(num_house.Value.ToString()), date_connection = Convert.ToDateTime(date_connection.Text), id_co_worker = dc.co_workers.FirstOrDefault(c => c.co_worker_name == id_co_worker.SelectedItem.ToString()).co_worker_id, id_rate = dc.rates.FirstOrDefault(r => r.name_rate == id_rate.SelectedItem.ToString()).rate_id }; dc.agreements.InsertOnSubmit(Agr); dc.SubmitChanges(); fillAgreements(); }