Exemplo n.º 1
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="ApplicationId"></param>
        /// <returns></returns>
        public AjaxResult Update(C_S_Application entity, string ApplicationId)
        {
            AjaxResult msg = new AjaxResult();

            string sqlStr = @"UPDATE dbo.C_S_Application
                                SET ApplicationName = @ApplicationName,
                                    ApplicationCode = @ApplicationCode,
                                    SortCode = @SortCode,
                                    Company = @Company,
                                    Remark = @Remark,
                                    UpdateBy = @UpdateBy,
                                    UpdateTime = @UpdateTime,
                                    StartFileName = @StartFileName
                                WHERE ApplicationId = @ApplicationId";

            SqlParameter[] parameter =
            {
                new SqlParameter("ApplicationId",   entity.ApplicationId),
                new SqlParameter("ApplicationName", entity.ApplicationName),
                new SqlParameter("ApplicationCode", entity.ApplicationCode),
                new SqlParameter("SortCode",        entity.SortCode),
                new SqlParameter("Company",         entity.Company),
                new SqlParameter("Remark",          entity.Remark),
                new SqlParameter("UpdateBy",        entity.UpdateBy),
                new SqlParameter("UpdateTime",      entity.UpdateTime),
                new SqlParameter("StartFileName",   entity.StartFileName),
            };
            int result = SqlHelper.ExecuteNonQuery(sqlStr, parameter);

            if (result == 1)
            {
                msg.data    = "";
                msg.state   = "success";
                msg.message = "修改成功!";
            }
            else
            {
                msg.data    = "";
                msg.state   = "error";
                msg.message = "修改失败!";
            }
            return(msg);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public AjaxResult Add(C_S_Application entity)
        {
            AjaxResult          msg       = new AjaxResult();
            List <SqlParameter> parameter = new List <SqlParameter>();

            parameter.Add(new SqlParameter("ApplicationName", entity.ApplicationName));
            parameter.Add(new SqlParameter("ApplicationCode", entity.ApplicationCode));
            parameter.Add(new SqlParameter("Company", entity.Company));

            string sqlStr = "select * from C_S_Application where (ApplicationName = @ApplicationName or ApplicationCode=@ApplicationCode) and Company = @Company";

            DataTable dt = SqlHelper.ExecuteDataTable(sqlStr, parameter.ToArray());

            if (dt.Rows.Count > 0)
            {
                msg.data    = "";
                msg.state   = "error";
                msg.message = "新增失败,该应用已经存在!";
            }
            else
            {
                sqlStr = @"INSERT INTO dbo.C_S_Application (ApplicationId,ApplicationName,ApplicationCode,
                                 Company,SortCode,Remark,CreateBy,CreateTime,StartFileName)
                                VALUES  ( @ApplicationId ,@ApplicationName ,
                                          @ApplicationCode ,  @Company, @SortCode ,                                      
                                          @Remark ,  @CreateBy , @CreateTime,@StartFileName) ";
                parameter.Clear();
                parameter.Add(new SqlParameter("ApplicationId", entity.ApplicationId));
                parameter.Add(new SqlParameter("ApplicationName", entity.ApplicationName));
                parameter.Add(new SqlParameter("ApplicationCode", entity.ApplicationCode));
                parameter.Add(new SqlParameter("SortCode", entity.SortCode));
                parameter.Add(new SqlParameter("Company", entity.Company));
                parameter.Add(new SqlParameter("Remark", entity.ApplicationName));
                parameter.Add(new SqlParameter("CreateBy", entity.CreateBy));
                parameter.Add(new SqlParameter("CreateTime", entity.CreateTime));
                parameter.Add(new SqlParameter("StartFileName", entity.StartFileName));

                int result = SqlHelper.ExecuteNonQuery(sqlStr, parameter.ToArray());

                if (result == 1)
                {
                    msg.data    = "";
                    msg.state   = "success";
                    msg.message = "新增成功!";


                    #region =====================写操作日志======================
                    C_S_Log log = new C_S_Log()
                    {
                        OperateType     = 4,        //新增
                        OperateUserId   = entity.CreateBy,
                        ApplicationId   = entity.ApplicationId,
                        ApplicationCode = entity.ApplicationCode,
                        Content         = "新增应用",
                        IPAddress       = Net.Ip,
                        MachineName     = Net.Host
                    };

                    CSLog_BLL.Add(log);
                    #endregion =================================================
                }
                else
                {
                    msg.data    = "";
                    msg.state   = "error";
                    msg.message = "新增失败!";
                }
            }
            return(msg);
        }