/// <summary> /// 增加一条数据 /// </summary> public bool Add(MyTest.Model.Sys_ModuleFormModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Sys_ModuleForm("); strSql.Append("F_Id,F_ModuleId,F_EnCode,F_FullName,F_FormJson,F_SortCode,F_DeleteMark,F_EnabledMark,F_Description,F_CreatorTime,F_CreatorUserId,F_LastModifyTime,F_LastModifyUserId,F_DeleteTime,F_DeleteUserId)"); strSql.Append(" values ("); strSql.Append("@F_Id,@F_ModuleId,@F_EnCode,@F_FullName,@F_FormJson,@F_SortCode,@F_DeleteMark,@F_EnabledMark,@F_Description,@F_CreatorTime,@F_CreatorUserId,@F_LastModifyTime,@F_LastModifyUserId,@F_DeleteTime,@F_DeleteUserId)"); SqlParameter[] parameters = { new SqlParameter("@F_Id", SqlDbType.VarChar, 50), new SqlParameter("@F_ModuleId", SqlDbType.VarChar, 50), new SqlParameter("@F_EnCode", SqlDbType.VarChar, 50), new SqlParameter("@F_FullName", SqlDbType.VarChar, 50), new SqlParameter("@F_FormJson", SqlDbType.VarChar, -1), new SqlParameter("@F_SortCode", SqlDbType.Int, 4), new SqlParameter("@F_DeleteMark", SqlDbType.Bit, 1), new SqlParameter("@F_EnabledMark", SqlDbType.Bit, 1), new SqlParameter("@F_Description", SqlDbType.VarChar, 500), new SqlParameter("@F_CreatorTime", SqlDbType.DateTime), new SqlParameter("@F_CreatorUserId", SqlDbType.VarChar, 50), new SqlParameter("@F_LastModifyTime", SqlDbType.DateTime), new SqlParameter("@F_LastModifyUserId", SqlDbType.VarChar, 50), new SqlParameter("@F_DeleteTime", SqlDbType.DateTime), new SqlParameter("@F_DeleteUserId", SqlDbType.VarChar, 500) }; parameters[0].Value = model.F_Id; parameters[1].Value = model.F_ModuleId; parameters[2].Value = model.F_EnCode; parameters[3].Value = model.F_FullName; parameters[4].Value = model.F_FormJson; parameters[5].Value = model.F_SortCode; parameters[6].Value = model.F_DeleteMark; parameters[7].Value = model.F_EnabledMark; parameters[8].Value = model.F_Description; parameters[9].Value = model.F_CreatorTime; parameters[10].Value = model.F_CreatorUserId; parameters[11].Value = model.F_LastModifyTime; parameters[12].Value = model.F_LastModifyUserId; parameters[13].Value = model.F_DeleteTime; parameters[14].Value = model.F_DeleteUserId; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public MyTest.Model.Sys_ModuleFormModel GetModel(string F_Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 F_Id,F_ModuleId,F_EnCode,F_FullName,F_FormJson,F_SortCode,F_DeleteMark,F_EnabledMark,F_Description,F_CreatorTime,F_CreatorUserId,F_LastModifyTime,F_LastModifyUserId,F_DeleteTime,F_DeleteUserId from Sys_ModuleForm "); strSql.Append(" where F_Id=@F_Id "); SqlParameter[] parameters = { new SqlParameter("@F_Id", SqlDbType.VarChar, 50) }; parameters[0].Value = F_Id; MyTest.Model.Sys_ModuleFormModel model = new MyTest.Model.Sys_ModuleFormModel(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public MyTest.Model.Sys_ModuleFormModel DataRowToModel(DataRow row) { MyTest.Model.Sys_ModuleFormModel model = new MyTest.Model.Sys_ModuleFormModel(); if (row != null) { if (row["F_Id"] != null) { model.F_Id = row["F_Id"].ToString(); } if (row["F_ModuleId"] != null) { model.F_ModuleId = row["F_ModuleId"].ToString(); } if (row["F_EnCode"] != null) { model.F_EnCode = row["F_EnCode"].ToString(); } if (row["F_FullName"] != null) { model.F_FullName = row["F_FullName"].ToString(); } if (row["F_FormJson"] != null) { model.F_FormJson = row["F_FormJson"].ToString(); } if (row["F_SortCode"] != null && row["F_SortCode"].ToString() != "") { model.F_SortCode = int.Parse(row["F_SortCode"].ToString()); } if (row["F_DeleteMark"] != null && row["F_DeleteMark"].ToString() != "") { if ((row["F_DeleteMark"].ToString() == "1") || (row["F_DeleteMark"].ToString().ToLower() == "true")) { model.F_DeleteMark = true; } else { model.F_DeleteMark = false; } } if (row["F_EnabledMark"] != null && row["F_EnabledMark"].ToString() != "") { if ((row["F_EnabledMark"].ToString() == "1") || (row["F_EnabledMark"].ToString().ToLower() == "true")) { model.F_EnabledMark = true; } else { model.F_EnabledMark = false; } } if (row["F_Description"] != null) { model.F_Description = row["F_Description"].ToString(); } if (row["F_CreatorTime"] != null && row["F_CreatorTime"].ToString() != "") { model.F_CreatorTime = DateTime.Parse(row["F_CreatorTime"].ToString()); } if (row["F_CreatorUserId"] != null) { model.F_CreatorUserId = row["F_CreatorUserId"].ToString(); } if (row["F_LastModifyTime"] != null && row["F_LastModifyTime"].ToString() != "") { model.F_LastModifyTime = DateTime.Parse(row["F_LastModifyTime"].ToString()); } if (row["F_LastModifyUserId"] != null) { model.F_LastModifyUserId = row["F_LastModifyUserId"].ToString(); } if (row["F_DeleteTime"] != null && row["F_DeleteTime"].ToString() != "") { model.F_DeleteTime = DateTime.Parse(row["F_DeleteTime"].ToString()); } if (row["F_DeleteUserId"] != null) { model.F_DeleteUserId = row["F_DeleteUserId"].ToString(); } } return(model); }