Esempio n. 1
0
        public ActionResult ComplainTypeAdd()
        {
            int id = string.IsNullOrEmpty(Request["id"]) ? 0 : int.Parse(Request["id"]);

            if (id > 0)
            {
                mo = bll.GetModel(id);
            }

            ViewBag.mo = mo;
            return(View());
        }
Esempio n. 2
0
        /// <summary>
        /// 添加修改投诉类型
        /// </summary>
        /// <returns></returns>
        public JsonResult InsertOrUpdateAddType(JMP.MDL.CsComplainType mode)
        {
            object retJson = new { success = 0, msg = "操作失败" };

            if (mode.Id > 0)
            {
                #region 修改
                //得到一个实体对象
                mo = bll.GetModel(mode.Id);
                //拷贝
                var mocolne = mo.Clone();
                mo.Name        = mode.Name;
                mo.Description = mode.Description;

                if (bll.Update(mo))
                {
                    Logger.ModifyLog("修改投诉类型", mocolne, mo);

                    retJson = new { success = 1, msg = "修改成功" };
                }
                else
                {
                    retJson = new { success = 0, msg = "修改失败" };
                }
                #endregion
            }
            else
            {
                #region 添加

                mode.state           = 0;
                mode.CreatedOn       = DateTime.Now;
                mode.CreatedByUserId = UserInfo.UserId;
                int num = bll.Add(mode);
                if (num > 0)
                {
                    Logger.CreateLog("添加投诉类型", mode);

                    retJson = new { success = 1, msg = "添加成功" };
                }
                else
                {
                    retJson = new { success = 0, msg = "添加失败" };
                }
                #endregion
            }
            return(Json(retJson));
        }
Esempio n. 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public JMP.MDL.CsComplainType GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Id, Name, Description, state, CreatedOn, CreatedByUserId  ");
            strSql.Append("  from CsComplainType ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;


            JMP.MDL.CsComplainType model = new JMP.MDL.CsComplainType();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                model.Name        = ds.Tables[0].Rows[0]["Name"].ToString();
                model.Description = ds.Tables[0].Rows[0]["Description"].ToString();
                if (ds.Tables[0].Rows[0]["state"].ToString() != "")
                {
                    model.state = int.Parse(ds.Tables[0].Rows[0]["state"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CreatedOn"].ToString() != "")
                {
                    model.CreatedOn = DateTime.Parse(ds.Tables[0].Rows[0]["CreatedOn"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CreatedByUserId"].ToString() != "")
                {
                    model.CreatedByUserId = int.Parse(ds.Tables[0].Rows[0]["CreatedByUserId"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(JMP.MDL.CsComplainType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update CsComplainType set ");

            strSql.Append(" Name = @Name , ");
            strSql.Append(" Description = @Description , ");
            strSql.Append(" state = @state , ");
            strSql.Append(" CreatedOn = @CreatedOn , ");
            strSql.Append(" CreatedByUserId = @CreatedByUserId  ");
            strSql.Append(" where Id=@Id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",              SqlDbType.Int,         4),
                new SqlParameter("@Name",            SqlDbType.NVarChar,  255),
                new SqlParameter("@Description",     SqlDbType.NVarChar,  500),
                new SqlParameter("@state",           SqlDbType.Int,         4),
                new SqlParameter("@CreatedOn",       SqlDbType.DateTime),
                new SqlParameter("@CreatedByUserId", SqlDbType.Int, 4)
            };

            parameters[0].Value = model.Id;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.Description;
            parameters[3].Value = model.state;
            parameters[4].Value = model.CreatedOn;
            parameters[5].Value = model.CreatedByUserId;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(JMP.MDL.CsComplainType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CsComplainType(");
            strSql.Append("Name,Description,state,CreatedOn,CreatedByUserId");
            strSql.Append(") values (");
            strSql.Append("@Name,@Description,@state,@CreatedOn,@CreatedByUserId");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",            SqlDbType.NVarChar,  255),
                new SqlParameter("@Description",     SqlDbType.NVarChar,  500),
                new SqlParameter("@state",           SqlDbType.Int,         4),
                new SqlParameter("@CreatedOn",       SqlDbType.DateTime),
                new SqlParameter("@CreatedByUserId", SqlDbType.Int, 4)
            };

            parameters[0].Value = model.Name;
            parameters[1].Value = model.Description;
            parameters[2].Value = model.state;
            parameters[3].Value = model.CreatedOn;
            parameters[4].Value = model.CreatedByUserId;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <JMP.MDL.CsComplainType> DataTableToList(DataTable dt)
        {
            List <JMP.MDL.CsComplainType> modelList = new List <JMP.MDL.CsComplainType>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                JMP.MDL.CsComplainType model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new JMP.MDL.CsComplainType();
                    if (dt.Rows[n]["Id"].ToString() != "")
                    {
                        model.Id = int.Parse(dt.Rows[n]["Id"].ToString());
                    }
                    model.Name        = dt.Rows[n]["Name"].ToString();
                    model.Description = dt.Rows[n]["Description"].ToString();
                    if (dt.Rows[n]["state"].ToString() != "")
                    {
                        model.state = int.Parse(dt.Rows[n]["state"].ToString());
                    }
                    if (dt.Rows[n]["CreatedOn"].ToString() != "")
                    {
                        model.CreatedOn = DateTime.Parse(dt.Rows[n]["CreatedOn"].ToString());
                    }
                    if (dt.Rows[n]["CreatedByUserId"].ToString() != "")
                    {
                        model.CreatedByUserId = int.Parse(dt.Rows[n]["CreatedByUserId"].ToString());
                    }


                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Esempio n. 7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(JMP.MDL.CsComplainType model)
 {
     return(dal.Update(model));
 }
Esempio n. 8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(JMP.MDL.CsComplainType model)
 {
     return(dal.Add(model));
 }