예제 #1
0
        public static OperationResult AddNightBan(NightBanEditModel model)
        {
            List <SqlParameter> paras = new List <SqlParameter>()
            {
                new SqlParameter("@NightBanName", SqlDbType.NVarChar),
                new SqlParameter("@NightBanAddress", SqlDbType.NVarChar),
                new SqlParameter("@StartTime", SqlDbType.Time),
                new SqlParameter("@EndTime", SqlDbType.Time),
                new SqlParameter("@IsEnabled", SqlDbType.Bit),
                new SqlParameter("@IsDefault", SqlDbType.Bit),
                new SqlParameter("@CreateUserID", SqlDbType.Int)
            };

            paras[0].Value = model.NightBanName.Trim();
            paras[1].Value = model.NightBanAddress.Trim();
            paras[2].Value = model.StartTime;
            paras[3].Value = model.EndTime;
            paras[4].Value = model.IsEnabled;
            paras[5].Value = false;
            paras[6].Value = model.CreateUserID;

            #region  SQL
            string sql = @"INSERT INTO [dbo].[NightBan]([NightBanName] ,[NightBanAddress] ,[StartTime] ,[EndTime]
                                    ,[IsEnabled] ,[IsDefault],[CreateUserID],[CreateTime] ,[Status]) VALUES 
                                   (@NightBanName,@NightBanAddress,@StartTime,@EndTime,@IsEnabled,@IsDefault,@CreateUserID,
                                   GETDATE(),0)";
            #endregion

            bool result = MSSQLHelper.ExecuteNonQuery(CommandType.Text, sql, paras.ToArray()) > 0;
            return(new OperationResult()
            {
                Success = result,
                Message = result ? PromptInformation.OperationSuccess : PromptInformation.DBError
            });
        }
예제 #2
0
        public static SelectResult <NightBanEditModel> GetNightBanByID(int id)
        {
            List <SqlParameter> paras = new List <SqlParameter>()
            {
                new SqlParameter("@ID", SqlDbType.Int),
            };

            paras[0].Value = id;
            string sql = @" SELECT [ID],[NightBanName],[NightBanAddress],[StartTime],[EndTime]
                                     ,[IsEnabled] FROM NightBan WHERE ID=@ID";
            List <NightBanEditModel> list = ConvertToList <NightBanEditModel> .Convert(MSSQLHelper.ExecuteDataTable(CommandType.Text, sql, paras.ToArray()));

            NightBanEditModel 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 <NightBanEditModel>()
            {
                DataResult = data,
                Message = msg
            });
        }
예제 #3
0
        public ActionResult AddNightBan()
        {
            NightBanEditModel model = new NightBanEditModel();

            model.IsEnabled = true;
            model.StartTime = "02:00:00";
            model.EndTime   = "05:00:00";
            return(PartialView("_AddNightBan", model));
        }
예제 #4
0
 public ActionResult EditNightBan(NightBanEditModel model)
 {
     if (ModelState.IsValid)
     {
         model.UpdateUserID = base.UserIDForLog;
         var result = NightBanBLL.EditNightBan(model);
         base.DoLog(OperationTypeEnum.Edit, result, "ID:" + model.ID);
         return(Json(result));
     }
     else
     {
         return(PartialView("_EditNightBan", model));
     }
 }
예제 #5
0
 public ActionResult AddNightBan(NightBanEditModel model)
 {
     if (ModelState.IsValid)
     {
         model.CreateUserID = base.UserIDForLog;
         var result = NightBanBLL.AddNightBan(model);
         base.DoLog(OperationTypeEnum.Add, result, "NightBanName:" + model.NightBanName);
         return(Json(result));
     }
     else
     {
         return(PartialView("_AddNightBan", model));
     }
 }
예제 #6
0
        public static OperationResult EditNightBan(NightBanEditModel model)
        {
            List <SqlParameter> paras = new List <SqlParameter>()
            {
                new SqlParameter("@ID", SqlDbType.Int),
                new SqlParameter("@NightBanName", SqlDbType.NVarChar),
                new SqlParameter("@NightBanAddress", SqlDbType.NVarChar),
                new SqlParameter("@StartTime", SqlDbType.Time),
                new SqlParameter("@EndTime", SqlDbType.Time),
                new SqlParameter("@IsEnabled", SqlDbType.Bit),
                new SqlParameter("@UpdateUserID", SqlDbType.Int)
            };

            paras[0].Value = model.ID;
            paras[1].Value = model.NightBanName.Trim();
            paras[2].Value = model.NightBanAddress.Trim();
            paras[3].Value = model.StartTime;
            paras[4].Value = model.EndTime;
            paras[5].Value = model.IsEnabled;
            paras[6].Value = model.UpdateUserID;
            #region  SQL
            string sql;
            sql = @"UPDATE  [dbo].[NightBan] SET [NightBanName] = @NightBanName ,[NightBanAddress] = @NightBanAddress
                          ,[StartTime] = @StartTime,[EndTime] = @EndTime ,[IsEnabled] = @IsEnabled ,[UpdateUserID] = @UpdateUserID
                         ,[UpdateTime] = GETDATE()  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
            });
        }