Пример #1
0
        public int AddSupplier(FormCollection f)
        {
            String supplierName = f["txtSupplierName"];
            String supplierAddress = f["txtSupplierAddress"];
            String supplierPhoneNumber = f["txtSupplierPhoneNumber"];
            String supplierEmail = f["txtSupplierEmail"];
            String supplierTaxCode = f["txtSupplierTaxCode"];
            Supplier supplier = new Supplier();
            try
            {
                supplier.SupplierName = supplierName;
                supplier.SupplierAddress = supplierAddress;
                supplier.SupplierPhoneNumber = supplierPhoneNumber;
                supplier.SupplierEmail = supplierEmail;
                supplier.SupplierTaxCode = supplierTaxCode;
                supplier.IsActive = true;
            }
            catch (Exception)
            {
                return 0;

            }

            bool result = SupplierBusiness.AddSupplier(supplier);
            if (result)
            {
                return 1;
            }
            else
            {
                return 0;
            }
        }
Пример #2
0
 public static bool AddSupplier(Supplier supplier)
 {
     if (supplier == null)
     {
         return false;
     }
     try
     {
         db.Suppliers.Add(supplier);
         db.SaveChanges();
     }
     catch (Exception e)
     {
         string s = e.ToString();
         return false;
     }
     return true;
 }