Esempio n. 1
0
        public static bool DeleteSupplierType(String supplierTypeCode)
        {
            try
            {
                using (NewcourtEntities ctx = new NewcourtEntities())
                {
                    if (CanDeleteSupplierType(supplierTypeCode))
                    {
                        SupplierTypes supplierType = ctx.SupplierTypes.FirstOrDefault(a => a.SupplierTypeCode == supplierTypeCode);

                        if (supplierType != null)
                        {
                            ctx.SupplierTypes.Remove(supplierType);
                            ctx.SaveChanges();
                            return(true);
                        }
                    }

                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        public static void SaveSupplierType(Data_SupplierType supplierType)
        {
            try
            {
                using (NewcourtEntities ctx = new NewcourtEntities())
                {
                    SupplierTypes record = ctx.SupplierTypes.FirstOrDefault(a => a.SupplierTypeCode == supplierType.SupplierTypeCode);

                    if (record != null)
                    {
                        record.Name = supplierType.Name;
                    }
                    else
                    {
                        ctx.SupplierTypes.Add(new SupplierTypes()
                        {
                            SupplierTypeCode = supplierType.SupplierTypeCode,
                            Name             = supplierType.Name
                        });
                    }

                    ctx.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }