private void saveBtn_Click(object sender, RoutedEventArgs e)
        {
            if (_contractor != null)
            {
                using (var db = new ContractorContext())
                {
                    _contractor.ContractorName = ContractorNameBox.Text;
                    _contractor.ManagerName = ManagerNameBox.Text;
                    _contractor.ContactEmail = Email.Text;
                    _contractor.ContactPhone = PhoneNumber.Text;

                    db.Contractors.AddOrUpdate(_contractor);
                    db.SaveChanges();
                }
            }
            else
            {
                using (var db = new ContractorContext())
                {
                    Contractor nc = new Contractor()
                    {
                        ContractorName = ContractorNameBox.Text,
                        ManagerName = ManagerNameBox.Text,
                        ContactEmail = Email.Text,
                        ContactPhone = PhoneNumber.Text
                    };

                    db.Contractors.AddOrUpdate(nc);
                    db.SaveChanges();
                }
            }
            this.Close();
        }
 public NewContractor(Contractor _contractor)
 {
     InitializeComponent();
     this._contractor = _contractor;
     ContractorNameBox.Text = _contractor.ContractorName;
     ManagerNameBox.Text = _contractor.ManagerName;
     Email.Text = _contractor.ContactEmail;
     PhoneNumber.Text = _contractor.ContactPhone;
 }
Esempio n. 3
0
 public AddOrder(Contractor item)
 {
     InitializeComponent();
     _contractor = item;
     OrderPositions.Columns[0].Width = OrderPositions.Width*70/100;
     OrderPositions.Columns[1].Width = OrderPositions.Width * 30 / 100;
     HandleStuff();
     GridItems = new List<PositionsQty>();
     OrderPositions.ItemsSource = GridItems;
     this.DataContext = this;
 }