public PurchaseItem(decimal quantity, decimal unitPrice, ProductDB product, ProviderDB provider)
 {
     this.Quantity = quantity;
     this.UnitPrice = unitPrice;
     this.Product = product;
     this.Provider = provider;
 }
 public void saveProvider(ProviderDB provider)
 {
     if (provider.IsNew())
     {
         int id = dbConnection.addProvider(provider.Name, provider.Address);
         provider.Id = id;
     }
     else
     {
         dbConnection.updateProvider((int)provider.Id, provider.Name, provider.Address);
     }
 }
 private void bAccept_Click(object sender, EventArgs e)
 {
     if (this.validData())
     {
         if (this.operation == DbActionsEnum.Create)
         {
             this.resultProvider = new ProviderDB(this.tbProviderName.Text, this.tbProviderAddress.Text);
         }
         else if (this.operation == DbActionsEnum.Update)
         {
             this.resultProvider = new ProviderDB((int)this.originalProvider.Id, this.tbProviderName.Text, this.tbProviderAddress.Text);
         }
         this.DialogResult = System.Windows.Forms.DialogResult.OK;
         this.Close();
     }
 }
        public DialogResult ShowDialog(ProviderDB provider, DbActionsEnum operation)
        {
            this.operation = operation;
            if (operation != DbActionsEnum.Create)
            {
                this.originalProvider = provider;
                this.phones = new BindingList<ProviderPhoneDB>(DbValidation.Instance.searchProviderPhonesByProviderId((int)provider.Id));
            }
            else
            {
                this.originalProvider = null;
                this.phones = new BindingList<ProviderPhoneDB>();
            }
            this.updatePhones();
            this.setBehaviorFromOperation(operation);

            return this.ShowDialog();
        }
 public void deleteProvider(ProviderDB provider)
 {
     dbConnection.deleteProviderPhones((int)provider.Id);
     dbConnection.deleteProvider((int)provider.Id);
 }