public List <PEIS.Model.SYSUserRight> DataTableToList(DataTable dt) { List <PEIS.Model.SYSUserRight> list = new List <PEIS.Model.SYSUserRight>(); int count = dt.Rows.Count; if (count > 0) { for (int i = 0; i < count; i++) { PEIS.Model.SYSUserRight sysUserRight = new PEIS.Model.SYSUserRight(); if (dt.Rows[i]["ID_UserRight"].ToString() != "") { sysUserRight.UserRightID = int.Parse(dt.Rows[i]["UserRightID"].ToString()); } if (dt.Rows[i]["RightID"].ToString() != "") { sysUserRight.RightID = new int?(int.Parse(dt.Rows[i]["RightID"].ToString())); } if (dt.Rows[i]["CreateDate"].ToString() != "") { sysUserRight.CreateDate = new DateTime?(DateTime.Parse(dt.Rows[i]["CreateDate"].ToString())); } if (dt.Rows[i]["OperatorID"].ToString() != "") { sysUserRight.OperatorID = new int?(int.Parse(dt.Rows[i]["OperatorID"].ToString())); } if (dt.Rows[i]["UserID"].ToString() != "") { sysUserRight.UserID = new int?(int.Parse(dt.Rows[i]["UserID"].ToString())); } list.Add(sysUserRight); } } return(list); }
public bool Update(PEIS.Model.SYSUserRight model) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("update SYSUserRight set "); stringBuilder.Append("RightID=@RightID,"); stringBuilder.Append("CreateDate=@CreateDate,"); stringBuilder.Append("OperatorID=@OperatorID,"); stringBuilder.Append("UserID=@UserID"); stringBuilder.Append(" where RightID=@RightID"); SqlParameter[] array = new SqlParameter[] { new SqlParameter("@RightID", SqlDbType.Int, 4), new SqlParameter("@CreateDate", SqlDbType.DateTime), new SqlParameter("@OperatorID", SqlDbType.Int, 4), new SqlParameter("@UserID", SqlDbType.Int, 4), new SqlParameter("@UserRightID", SqlDbType.Int, 4) }; array[0].Value = model.RightID; array[1].Value = model.CreateDate; array[2].Value = model.OperatorID; array[3].Value = model.UserID; array[4].Value = model.UserRightID; int num = DbHelperSQL.ExecuteSql(stringBuilder.ToString(), array); return(num > 0); }
public int Add(PEIS.Model.SYSUserRight model) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("insert into SYSUserRight("); stringBuilder.Append("RightID,CreateDate,OperatorID,UserID)"); stringBuilder.Append(" values ("); stringBuilder.Append("@RightID,@CreateDate,@OperatorID,@UserID)"); stringBuilder.Append(";select @@IDENTITY"); SqlParameter[] array = new SqlParameter[] { new SqlParameter("@RightID", SqlDbType.Int, 4), new SqlParameter("@CreateDate", SqlDbType.DateTime), new SqlParameter("@OperatorID", SqlDbType.Int, 4), new SqlParameter("@UserID", SqlDbType.Int, 4) }; array[0].Value = model.RightID; array[1].Value = model.CreateDate; array[2].Value = model.OperatorID; array[3].Value = model.UserID; object single = DbHelperSQL.GetSingle(stringBuilder.ToString(), array); int result; if (single == null) { result = 0; } else { result = Convert.ToInt32(single); } return(result); }
public PEIS.Model.SYSUserRight GetModel(int UserRightID) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("select top 1 UserRightID,RightID,CreateDate,OperatorID,UserID from SYSUserRight "); stringBuilder.Append(" where UserRightID=@UserRightID"); SqlParameter[] array = new SqlParameter[] { new SqlParameter("@UserRightID", SqlDbType.Int, 4) }; array[0].Value = UserRightID; PEIS.Model.SYSUserRight UserRight = new PEIS.Model.SYSUserRight(); DataSet dataSet = DbHelperSQL.Query(stringBuilder.ToString(), array); PEIS.Model.SYSUserRight result; if (dataSet.Tables[0].Rows.Count > 0) { if (dataSet.Tables[0].Rows[0]["UserRightID"].ToString() != "") { UserRight.UserRightID = int.Parse(dataSet.Tables[0].Rows[0]["UserRightID"].ToString()); } if (dataSet.Tables[0].Rows[0]["ID_Right"].ToString() != "") { UserRight.RightID = new int?(int.Parse(dataSet.Tables[0].Rows[0]["RightID"].ToString())); } if (dataSet.Tables[0].Rows[0]["CreateDate"].ToString() != "") { UserRight.CreateDate = new DateTime?(DateTime.Parse(dataSet.Tables[0].Rows[0]["CreateDate"].ToString())); } if (dataSet.Tables[0].Rows[0]["OperatorID"].ToString() != "") { UserRight.OperatorID = new int?(int.Parse(dataSet.Tables[0].Rows[0]["OperatorID"].ToString())); } if (dataSet.Tables[0].Rows[0]["UserID"].ToString() != "") { UserRight.UserID = new int?(int.Parse(dataSet.Tables[0].Rows[0]["UserID"].ToString())); } result = UserRight; } else { result = null; } return(result); }
public bool Update(PEIS.Model.SYSUserRight model) { return(this.dal.Update(model)); }
public int Add(PEIS.Model.SYSUserRight model) { return(this.dal.Add(model)); }