예제 #1
0
        public static SelectResult <TerminalTypeEditModel> GetTerminalTypeByID(int id)
        {
            List <SqlParameter> paras = new List <SqlParameter>()
            {
                new SqlParameter("@ID", SqlDbType.Int),
            };

            paras[0].Value = id;
            string sql = @"SELECT * FROM dbo.TerminalTypes WHERE ID=@ID";
            List <TerminalTypeEditModel> list = ConvertToList <TerminalTypeEditModel> .Convert(MSSQLHelper.ExecuteDataTable(CommandType.Text, sql, paras.ToArray()));

            TerminalTypeEditModel data = null;
            string msg = string.Empty;

            if (list == null)
            {
                msg = PromptInformation.DBError;
            }
            else if (list.Count == 0)
            {
                msg = PromptInformation.NotExists;
            }
            else
            {
                data = list[0];
            }
            return(new SelectResult <TerminalTypeEditModel>()
            {
                DataResult = data,
                Message = msg
            });
        }
예제 #2
0
 public ActionResult EditTerminalType(TerminalTypeEditModel model)
 {
     if (ModelState.IsValid)
     {
         var result = TerminalTypeBLL.EditTerminalType(model, base.UserIDForLog);
         base.DoLog(OperationTypeEnum.Edit, result, "TerminalName:" + model.TerminalName);
         return(Json(result));
     }
     else
     {
         model.TerminalManufacturerSelectList = new SelectList(TerminalManufacturerBLL.GetTerminalManufacturers(), "ID", "ManufacturerName");
         return(PartialView("_EditTerminalType", model));
     }
 }
예제 #3
0
        public static OperationResult EditTerminalType(TerminalTypeEditModel model, int EditUserID)
        {
            List <SqlParameter> paras = new List <SqlParameter>()
            {
                new SqlParameter("@TerminalName", SqlDbType.NVarChar, 200),
                new SqlParameter("@TerminalManufacturerID", SqlDbType.Int),
                new SqlParameter("@ACCON_Frequency", SqlDbType.Int),
                new SqlParameter("@ACCOFF_Frequency", SqlDbType.Int),
                new SqlParameter("@Filter", SqlDbType.Bit),
                new SqlParameter("@CommunicationMode", SqlDbType.NVarChar, 50),
                new SqlParameter("@Remark", SqlDbType.NVarChar, 500),
                new SqlParameter("@ID", SqlDbType.Int),
                new SqlParameter("@EditUserID", SqlDbType.Int),
                new SqlParameter("@EditTime", SqlDbType.DateTime)
            };

            paras[0].Value = model.TerminalName.Trim();
            paras[1].Value = model.TerminalManufacturerID;
            paras[2].Value = model.ACCON_Frequency;
            paras[3].Value = model.ACCOFF_Frequency;
            paras[4].Value = model.Filter;

            if (string.IsNullOrWhiteSpace(model.CommunicationMode))
            {
                paras[5].Value = DBNull.Value;
            }
            else
            {
                paras[5].Value = model.CommunicationMode.Trim();
            }

            if (string.IsNullOrWhiteSpace(model.Remark))
            {
                paras[6].Value = DBNull.Value;
            }
            else
            {
                paras[6].Value = model.Remark;
            }

            paras[7].Value = model.ID;
            paras[8].Value = EditUserID;
            paras[9].Value = DateTime.Now;
            #region  SQL
            string sql = @"UPDATE  dbo.TerminalTypes
SET     TerminalName = @TerminalName ,
        TerminalManufacturerID = @TerminalManufacturerID ,
        ACCON_Frequency = @ACCON_Frequency ,
        ACCOFF_Frequency = @ACCOFF_Frequency ,
        Filter = @Filter ,
        CommunicationMode = @CommunicationMode ,
        Remark = @Remark,
        EditTime=@EditTime,
EditUserID=@EditUserID
WHERE   ID = @ID";
            #endregion


            int    result = MSSQLHelper.ExecuteNonQuery(CommandType.Text, sql, paras.ToArray());
            string msg    = string.Empty;
            switch (result)
            {
            case 1:
                msg = PromptInformation.OperationSuccess;
                break;

            case 0:
                msg = PromptInformation.NotExists;
                break;

            case -1:
                msg = PromptInformation.DBError;
                break;
            }
            return(new OperationResult()
            {
                Success = result > 0,
                Message = msg
            });
        }