Exemple #1
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void Add(Area model)
 {
     using (DBHelper db = DBHelper.Create())
     {
         db.Insert<Area>(model);
     }
 }
Exemple #2
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 public List<Ajax.Model.Area> DataTableToList(DataTable dt)
 {
     List<Ajax.Model.Area> modelList = new List<Ajax.Model.Area>();
     int rowsCount = dt.Rows.Count;
     if (rowsCount > 0)
     {
         Ajax.Model.Area model;
         for (int n = 0; n < rowsCount; n++)
         {
             model = new Ajax.Model.Area();
             if (dt.Rows[n]["ID"] != null && dt.Rows[n]["ID"].ToString() != "")
             {
                 model.ID = dt.Rows[n]["ID"].ToString();
             }
             if (dt.Rows[n]["PID"] != null && dt.Rows[n]["PID"].ToString() != "")
             {
                 model.PID = dt.Rows[n]["PID"].ToString();
             }
             if (dt.Rows[n]["Code"] != null && dt.Rows[n]["Code"].ToString() != "")
             {
                 model.Code = dt.Rows[n]["Code"].ToString();
             }
             if (dt.Rows[n]["Name"] != null && dt.Rows[n]["Name"].ToString() != "")
             {
                 model.Name = dt.Rows[n]["Name"].ToString();
             }
             modelList.Add(model);
         }
     }
     return modelList;
 }
Exemple #3
0
 /// <summary>
 /// 新增区域,返回新增区域的对象
 /// </summary>
 /// <param name="area"></param>
 /// <returns></returns>
 public object AddArea(Area area)
 {
     using (DBHelper db = DBHelper.Create())
     {
         area.ID = Guid.NewGuid().ToString().Replace("-", "");
         string selectCode = "select max(code) from T_Area where PID = @PID";
         Dictionary<string, object> paramList = new Dictionary<string, object>();
         paramList.Add("PID", area.PID);
         object maxCode = db.ExcuteScular(selectCode, paramList);
         string code = maxCode == null ? "" : maxCode.ToString();
         string selectPCode = "select code from T_Area where ID = @ID";
         paramList.Clear();
         paramList.Add("ID", area.PID);
         object PCode = db.ExcuteScular(selectPCode, paramList);
         if (string.IsNullOrEmpty(code))
             code = PCode + "0001";
         else
             code = code.Substring(0, code.Length - 4) + (Convert.ToInt32(code.Substring(code.Length - 4)) + 1).ToString().PadLeft(4, '0');
         area.Code = code;
         area.Code = PCode + area.Code;
         try
         {
             return db.Insert<Area>(area);
         }
         catch (System.Exception ex)
         {
             area.State = "1";
             area.Errormsg = ex.Message;
             return area;
         }
     }
 }
Exemple #4
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Ajax.Model.Area> DataTableToList(DataTable dt)
        {
            List <Ajax.Model.Area> modelList = new List <Ajax.Model.Area>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                Ajax.Model.Area model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Ajax.Model.Area();
                    if (dt.Rows[n]["ID"] != null && dt.Rows[n]["ID"].ToString() != "")
                    {
                        model.ID = dt.Rows[n]["ID"].ToString();
                    }
                    if (dt.Rows[n]["PID"] != null && dt.Rows[n]["PID"].ToString() != "")
                    {
                        model.PID = dt.Rows[n]["PID"].ToString();
                    }
                    if (dt.Rows[n]["Code"] != null && dt.Rows[n]["Code"].ToString() != "")
                    {
                        model.Code = dt.Rows[n]["Code"].ToString();
                    }
                    if (dt.Rows[n]["Name"] != null && dt.Rows[n]["Name"].ToString() != "")
                    {
                        model.Name = dt.Rows[n]["Name"].ToString();
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
 public JsonResult AddArea(Area area)
 {
     AjaxResult result = new AjaxResult();
     dynamic a = new AreaRule().AddArea(area);
     result.Success = a.Errormsg != null ? false : true;
     result.Message = result.Success ? "地区信息添加成功" : "error:" + a.Errormsg;
     return Json(result, JsonRequestBehavior.AllowGet);
 }
Exemple #6
0
 /// <summary>
 /// 新增区域
 /// </summary>
 /// <param name="area"></param>
 /// <returns></returns>
 public object AddArea(Area area)
 {
     return dal.AddArea(area);
 }
Exemple #7
0
 /// <summary>
 /// 修改区域
 /// </summary>
 /// <param name="area"></param>
 /// <returns></returns>
 public bool ModifyArea(Area area)
 {
     return dal.ModifyArea(area);
 }
Exemple #8
0
 /// <summary>
 /// 获取所有区域
 /// </summary>
 /// <param name="area"></param>
 /// <returns></returns>
 public List<object> GetAreaList(Area area)
 {
     return dal.GetAreaList(area);
 }
Exemple #9
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Area model)
 {
     using (DBHelper db = DBHelper.Create())
     {
         db.Update<Area>(model);
         return true;
     }
 }
Exemple #10
0
 /// <summary>
 /// 修改区域
 /// </summary>
 /// <param name="area"></param>
 /// <returns></returns>
 public bool ModifyArea(Area area)
 {
     string sql = "update T_AREA set NAME=@NAME,Manager=@Manager where ID=@ID";
     using (DBHelper db = DBHelper.Create())
     {
         Dictionary<string, object> paramDic = new Dictionary<string, object>();
         paramDic.Add("NAME", area.Name);
         paramDic.Add("Manager", area.Manager);
         paramDic.Add("ID", area.ID);
         int effectLine = db.ExecuteNonQuery(sql, paramDic);
         return effectLine > 0 ? true : false;
     }
 }
Exemple #11
0
 /// <summary>
 /// 获取所有区域
 /// </summary>
 /// <param name="area"></param>
 /// <returns></returns>
 public List<object> GetAreaList(Area area)
 {
     StringBuilder sb = new StringBuilder();
     sb.Append(" where 1 =1");
     if (!string.IsNullOrEmpty(area.ID))
     {
         sb.Append(" and ID=@ID");
     }
     if (string.IsNullOrEmpty(area.PID))
     {
         sb.Append(" and PID is null");
     }
     else
     {
         sb.Append(" and pid = '" + area.PID + "'");
     }
     if (!string.IsNullOrEmpty(area.Name))
     {
         sb.Append(" and Name like '%" + area.Name + "%'");
     }
     string sql = "select id,pid,code,name from T_Area {0}";
     sql = string.Format(sql, sb.ToString());
     using (DBHelper db = DBHelper.Create())
     {
         return db.GetDynaminObjectList(sql, null);
     }
 }
Exemple #12
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Ajax.Model.Area model)
 {
     return(dal.Update(model));
 }
Exemple #13
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void Add(Ajax.Model.Area model)
 {
     dal.Add(model);
 }
Exemple #14
0
 public JsonResult ModifyArea(Area area)
 {
     AjaxResult result = new AjaxResult();
     try
     {
         result.Success = new AreaRule().ModifyArea(area);
         result.Message = result.Success ? "地区信息修改成功。" : "地区信息修改失败。";
     }
     catch (Exception ex)
     {
         result.Success = false;
         result.Message = "error:" + ex.Message;
     }
     return Json(result, JsonRequestBehavior.AllowGet);
 }
Exemple #15
0
 public JsonResult GetAreaList(Area area)
 {
     return Json(new AreaRule().GetAreaList(area), JsonRequestBehavior.AllowGet);
 }