Exemplo n.º 1
0
 public ActionResult AddSensorTypes(SensorAddModel model)
 {
     if (ModelState.IsValid)
     {
         var result = SensorBLL.AddSensorType(model, base.UserIDForLog);
         base.DoLog(OperationTypeEnum.Add, result, "SensorCode:" + model.SensorCode);
         return(Json(result));
     }
     else
     {
         return(PartialView("_AddSensorType", model));
     }
 }
Exemplo n.º 2
0
        public static OperationResult AddSensorType(SensorAddModel model, int CreateUserID)
        {
            List <SqlParameter> paras = new List <SqlParameter>()
            {
                new SqlParameter("@SensorName", SqlDbType.NVarChar, 30),
                new SqlParameter("@TValue", SqlDbType.Bit),
                new SqlParameter("@FValue", SqlDbType.Bit),
                new SqlParameter("@Remark", SqlDbType.NVarChar, 200),
                new SqlParameter("@CreateUserID", SqlDbType.Int),
                new SqlParameter("@SensorCode", SqlDbType.Int),
                new SqlParameter("@TypeCode", SqlDbType.NVarChar)
            };

            paras[0].Value = model.SensorName.Trim();
            paras[1].Value = model.Value1;
            paras[2].Value = model.Value2;

            if (string.IsNullOrWhiteSpace(model.Remark))
            {
                paras[3].Value = DBNull.Value;
            }
            else
            {
                paras[3].Value = model.Remark;
            }
            paras[4].Value = CreateUserID;
            paras[5].Value = model.SensorCode;
            paras[6].Value = model.TypeCode.Trim();
            #region  SQL
            string sql;
            #endregion

            sql = @"INSERT INTO dbo.SensorList(SensorName,Value1,Value2,Remark,Status,CreateUserID,SensorCode,TypeCode) VALUES (@SensorName,@TValue,@FValue,@Remark,'0',@CreateUserID,@SensorCode,@TypeCode)";


            bool result = MSSQLHelper.ExecuteNonQuery(CommandType.Text, sql, paras.ToArray()) > 0;
            return(new OperationResult()
            {
                Success = result,
                Message = result ? PromptInformation.OperationSuccess : PromptInformation.DBError
            });
        }