Exemple #1
0
        public void InsertUpdate(MLTipoMaterial ML)
        {
            try
            {
                dbSmartSysDataContext dbContext = new dbSmartSysDataContext();

                var Mat = (from t in dbContext.TipoMaterials where t.CodTipoMaterial == ML.CodTipoMaterial select t).SingleOrDefault();

                if (Mat == null)
                {
                    TipoMaterial dbMat = new TipoMaterial();

                    dbMat.CodTipoMaterial = ML.CodTipoMaterial;
                    dbMat.TipoMaterial1 = ML.TipoMaterial;

                    dbContext.TipoMaterials.InsertOnSubmit(dbMat);
                    dbContext.TipoMaterials.Context.SubmitChanges();
                }
                else
                {
                    Mat.TipoMaterial1 = ML.TipoMaterial;

                    dbContext.TipoMaterials.Context.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 partial void DeleteTipoMaterial(TipoMaterial instance);
 partial void UpdateTipoMaterial(TipoMaterial instance);
 partial void InsertTipoMaterial(TipoMaterial instance);