private void AddProject(object sender) { sel_pr = new ProjectModel(); sel_cus = new CustomerModel(); ProjectWindowAdd newwin = new ProjectWindowAdd(sel_pr, sel_cus); CustomerModel newcs = new CustomerModel(); if (newwin.ShowDialog() == true) { if (sel_pr.CustomerID == 0)//новый заказчик { db.AddCustomer(sel_cus); db.Save(); } sel_pr.CustomerID = db.GetCustomerByName(sel_cus).ID; sel_pr.StatusID = 5;//статус "Поступил" db.AddProject(sel_pr); db.Save(); d1.Mainprojects = db.GetAllProjects(); d1.Customers = db.GetAllCustomers(); } }