Пример #1
0
        public bool UpdateParameter(LakeParameter item)
        {
            bool result = false;

            try
            {
                using (RCID_DWHEntities context = new RCID_DWHEntities())
                {
                    Lake_Parameter efItem = context.Lake_Parameter.Where(b => b.ParameterID == item.ParameterID).FirstOrDefault();

                    if (efItem == null)
                    {
                        return(result);
                    }

                    efItem.ParameterActive     = item.ParameterActive;
                    efItem.ParameterFullName   = item.ParameterFullName;
                    efItem.ParameterName       = item.ParameterName;
                    efItem.ParameterTestMethod = item.ParameterTestMethod;
                    efItem.ParameterUnit       = item.ParameterUnit;

                    if (context.SaveChanges() > 0)
                    {
                        result = true;
                    }
                }
            }
            catch (Exception) { }
            return(result);
        }
Пример #2
0
        public int CreateParameter(LakeParameter item)
        {
            byte newid = 0;

            try
            {
                using (RCID_DWHEntities context = new RCID_DWHEntities())
                {
                    var lastItem = context.Lake_Parameter.OrderByDescending(u => u.ParameterID).FirstOrDefault();

                    if (lastItem != null)
                    {
                        newid = lastItem.ParameterID;
                        newid++;
                    }

                    Lake_Parameter efItem = new Lake_Parameter()
                    {
                        ParameterActive     = item.ParameterActive,
                        ParameterFullName   = item.ParameterFullName,
                        ParameterID         = newid,
                        ParameterName       = item.ParameterName,
                        ParameterTestMethod = item.ParameterTestMethod,
                        ParameterUnit       = item.ParameterUnit
                    };

                    context.Lake_Parameter.Add(efItem);

                    if (context.SaveChanges() > 0)
                    {
                        return(newid);
                    }
                }
            }
            catch (Exception e) { throw e; }
            return(newid);
        }