private void BindData() { string id = Request.QueryString["id"]; VDPositionBLL bll = null; VDPosition info = new VDPosition(); try { bll = BLLFactory.CreateBLL <VDPositionBLL>(); if (string.IsNullOrEmpty(id) == false) { info.ID = id; info = bll.Get(info); UIBindHelper.BindForm(this.Page, info); this.hiID.Value = info.ID; this.HiCREATEUSER.Value = info.CREATEUSER; this.HiCREATETIME.Value = info.CREATETIME.ToString(); this.HiParentID.Value = info.ParentID; } else { this.HiParentID.Value = Request.QueryString["parentID"]; info = new VDPosition(); } } catch (Exception ex) { throw ex; } }
protected void btSave_Click(object sender, EventArgs e) { VDPosition info = new VDPosition(); VDPositionBLL bll = null; try { UIBindHelper.BindModelByControls(this.Page, info); bll = BLLFactory.CreateBLL <VDPositionBLL>(); info.ParentID = this.HiParentID.Value; if (this.hiID.Value == "") { bll.Insert(info); ClientScript.RegisterStartupScript(this.GetType(), "myjs", "parent.addNode('" + info.ID + "','" + info.PositionName + "');parent.closeAppWindow1();", true); } else { info.CREATEUSER = this.HiCREATEUSER.Value; info.CREATETIME = DateTime.Parse(this.HiCREATETIME.Value); info.ID = this.hiID.Value; bll.Update(info); ClientScript.RegisterStartupScript(this.GetType(), "myjs", "parent.editNode('" + info.ID + "','" + info.PositionName + "');parent.closeAppWindow1();", true); } } catch (Exception ex) { throw ex; } }
/// <summary> /// 插入信息(单表) /// </summary> /// <param name="">信息</param> /// <returns>插入行数</returns> public DataResult <int> Insert(VDPosition model) { DataResult <int> result = new DataResult <int>(); try { //基本信息 model.ID = Guid.NewGuid().ToString(); model.CREATEUSER = this.LoginUser.UserID; model.CREATETIME = DateTime.Now; model.UPDATEUSER = model.CREATEUSER; model.UPDATETIME = model.CREATETIME; if (Exists(model)) { result.Msg = "编号已存在"; result.Result = -1; return(result); } result.Result = new VDPositionDAL().Insert(model); result.IsSuccess = true; return(result); } catch (Exception ex) { throw ex; } }
/// <summary> /// 判断名称是否存在 /// </summary> /// <param name="">信息</param> /// <returns>true:已存在;fasel:不存在。</returns> public bool Exists(VDPosition model) { try { return(new VDPositionDAL().Exists(model)); } catch (Exception ex) { throw ex; } }
/// <summary> /// 删除信息 /// </summary> /// <param name="">信息</param> /// <returns>删除个数</returns> public int Delete(VDPosition model) { try { return(new VDPositionDAL().Delete(model)); } catch (Exception ex) { throw ex; } }
/// <summary> /// 获取信息 /// </summary> /// <param name="">条件</param> /// <returns>信息</returns> public VDPosition Get(VDPosition model) { try { return(new VDPositionDAL().Get(model)); } catch (Exception ex) { throw ex; } }
/// <summary> /// 获取列表 /// </summary> /// <param name="condition">条件</param> /// <returns>位置列表</returns> public List <VDPosition> GetList(VDPosition condition) { List <VDPosition> list = null; string sql = null; using (IDataSession session = AppDataFactory.CreateMainSession()) { sql = "SELECT * FROM T_VD_Position order by PositionCode"; list = session.GetList <VDPosition>(sql, new List <DataParameter>().ToArray()).ToList <VDPosition>(); } return(list); }
/// <summary> /// 获取信息 /// </summary> /// <param name="">条件</param> /// <returns>*信息</returns> public VDPosition Get(VDPosition model) { try { using (IDataSession session = AppDataFactory.CreateMainSession()) { //获取信息 model = session.Get <VDPosition>(model); } return(model); } catch (Exception ex) { throw ex; } }
private void BindData() { VDPositionBLL bll = null; VDCameraBLL cbll = null; VDPosition condition = new VDPosition(); List <VDPosition> list = null; List <VDCamera> cameraList = null; try { //获取位置列表 bll = BLLFactory.CreateBLL <VDPositionBLL>(); list = bll.GetList(); //获取摄像头列表 cbll = BLLFactory.CreateBLL <VDCameraBLL>(); cameraList = cbll.GetList(); //绑定摄像头 foreach (VDPosition postion in list) { postion.CameraList = cameraList.Where(p => p.PostionID == postion.ID).ToList <VDCamera>(); } //输出位置信息 foreach (VDPosition position in list) { this.PositionList.Text += "<div class=\"easyui-panel\" title=\"" + position.PositionName + "\" style=\"width:500px;padding:10px;\">"; foreach (VDCamera camera in position.CameraList) { this.PositionList.Text += string.Format("<a href=\"#\" onclick=\"openRTMonitor('{0}','{1}')\">{1}<a> " , camera.ID, camera.CameraName); } this.PositionList.Text += "</div>"; } } catch (Exception ex) { throw ex; } }
/// <summary> /// 删除信息 /// </summary> /// <param name=""></param> /// <returns>删除个数</returns> public int Delete(VDPosition model) { int count = 0; try { using (IDataSession session = AppDataFactory.CreateMainSession()) { //删除基本信息 count = session.Delete <VDPosition>(model); } return(count); } catch (Exception ex) { throw ex; } }
private void BindData() { VDPositionBLL bll = null; VDPosition condition = new VDPosition(); List <VDPosition> list = null; try { bll = BLLFactory.CreateBLL <VDPositionBLL>(); list = bll.GetList(); this.hiPostionList.Value = this.GetTreeNodes(list); } catch (Exception ex) { throw ex; } }
/// <summary> /// 更新信息 /// </summary> /// <param name="">信息</param> /// <returns>更新行数</returns> public DataResult <int> Update(VDPosition model) { DataResult <int> result = new DataResult <int>(); try { if (Exists(model)) { result.Msg = "编号已存在"; result.Result = -1; return(result); } model.UPDATEUSER = this.LoginUser.UserID; result.Result = new VDPositionDAL().Update(model); result.IsSuccess = true; return(result); } catch (Exception ex) { throw ex; } }
/// <summary> /// 判断编号是否存在 /// </summary> /// <param name="info"></param> /// <returns>true:已存在;fasel:不存在。</returns> public bool Exists(VDPosition model) { StringBuilder sqlBuilder = new StringBuilder(); StringBuilder whereBuilder = new StringBuilder(); List <DataParameter> parameters = new List <DataParameter>(); int count = 0; try { sqlBuilder.Append("SELECT COUNT(0) FROM T_VD_Position"); whereBuilder.Append(" AND ID <> @ID "); parameters.Add(new DataParameter { ParameterName = "ID", DataType = DbType.String, Value = model.ID }); if (!string.IsNullOrEmpty(model.PositionCode)) { whereBuilder.Append(" AND PositionCode = @PositionCode "); parameters.Add(new DataParameter { ParameterName = "PositionCode", DataType = DbType.String, Value = model.PositionCode }); } if (whereBuilder.Length > 0) { sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4)); } using (IDataSession session = AppDataFactory.CreateMainSession()) { count = Convert.ToInt32(session.ExecuteSqlScalar(sqlBuilder.ToString(), parameters.ToArray())); } return(count > 0); } catch (Exception ex) { throw ex; } }