/// <summary> /// ����һ������ /// </summary> /// <param name="model">model</param> public int AddRecord(SFileUsingListData model) { StringBuilder strSql = new StringBuilder(); strSql.Append("set nocount on; "); strSql.Append("insert into SFileUsingList("); strSql.Append("orginId,fileId,fileUsingType,fileOrginType,recordTitle,isSys,mark,isrtEmpId,isrtDt,updtEmpId,updtDt)"); strSql.Append(" values ("); strSql.Append("@orginId,@fileId,@fileUsingType,@fileOrginType,@recordTitle,@isSys,@mark,@isrtEmpId,@isrtDt,@updtEmpId,@updtDt)"); strSql.Append("; select @@identity; set nocount off; "); SqlParameter[] parameters = { new SqlParameter("@orginId", SqlDbType.Int), new SqlParameter("@fileId", SqlDbType.Int), new SqlParameter("@fileUsingType", SqlDbType.Int), new SqlParameter("@fileOrginType", SqlDbType.NVarChar,20), new SqlParameter("@recordTitle", SqlDbType.NVarChar,50), new SqlParameter("@isSys", SqlDbType.Bit), new SqlParameter("@mark", SqlDbType.NVarChar,500), new SqlParameter("@isrtEmpId", SqlDbType.Int), new SqlParameter("@isrtDt", SqlDbType.DateTime), new SqlParameter("@updtEmpId", SqlDbType.Int), new SqlParameter("@updtDt", SqlDbType.DateTime) }; parameters[0].Value = model.orginId; parameters[1].Value = model.fileId; parameters[2].Value = model.fileUsingType; parameters[3].Value = model.fileOrginType; parameters[4].Value = model.recordTitle; parameters[5].Value = model.isSys; parameters[6].Value = model.mark; parameters[7].Value = model.isrtEmpId; parameters[8].Value = model.isrtDt == string.Empty ? null : model.isrtDt; parameters[9].Value = model.updtEmpId; parameters[10].Value = model.updtDt == string.Empty ? null : model.updtDt; int id = 0; try { object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); if (ret != null && ret != DBNull.Value) { id = Convert.ToInt32(ret); } } catch (Exception ex) { throw ex; } return id; }
/// <summary> /// ����һ������ /// </summary> /// <param name="model">model</param> public bool ModifyRecord(SFileUsingListData model) { return this.fileUsingListDB.ModifyRecord(model); }
/// <summary> /// ����һ������ /// </summary> /// <param name="model">model</param> public int AddRecord(SFileUsingListData model) { return this.fileUsingListDB.AddRecord(model); }
/// <summary> /// ����һ������ /// </summary> /// <param name="model">model</param> public bool ModifyRecord(SFileUsingListData model) { bool ret = false; StringBuilder strSql = new StringBuilder(); strSql.Append("update SFileUsingList set "); strSql.Append("orginId=@orginId,"); strSql.Append("fileId=@fileId,"); strSql.Append("fileUsingType=@fileUsingType,"); strSql.Append("fileOrginType=@fileOrginType,"); strSql.Append("recordTitle=@recordTitle,"); strSql.Append("isSys=@isSys,"); strSql.Append("mark=@mark,"); strSql.Append("isrtEmpId=@isrtEmpId,"); strSql.Append("isrtDt=@isrtDt,"); strSql.Append("updtEmpId=@updtEmpId,"); strSql.Append("updtDt=@updtDt"); strSql.Append(" where id = @id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int), new SqlParameter("@orginId", SqlDbType.Int), new SqlParameter("@fileId", SqlDbType.Int), new SqlParameter("@fileUsingType", SqlDbType.Int), new SqlParameter("@fileOrginType", SqlDbType.NVarChar,20), new SqlParameter("@recordTitle", SqlDbType.NVarChar,50), new SqlParameter("@isSys", SqlDbType.Bit), new SqlParameter("@mark", SqlDbType.NVarChar,500), new SqlParameter("@isrtEmpId", SqlDbType.Int), new SqlParameter("@isrtDt", SqlDbType.DateTime), new SqlParameter("@updtEmpId", SqlDbType.Int), new SqlParameter("@updtDt", SqlDbType.DateTime) }; parameters[0].Value = model.id; parameters[1].Value = model.orginId; parameters[2].Value = model.fileId; parameters[3].Value = model.fileUsingType; parameters[4].Value = model.fileOrginType; parameters[5].Value = model.recordTitle; parameters[6].Value = model.isSys; parameters[7].Value = model.mark; parameters[8].Value = model.isrtEmpId; parameters[9].Value = model.isrtDt == string.Empty ? null : model.isrtDt; parameters[10].Value = model.updtEmpId; parameters[11].Value = model.updtDt == string.Empty ? null : model.updtDt; try { SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); ret = true; } catch (Exception ex) { throw ex; } return ret; }
/// <summary> /// �õ�һ��model /// </summary> /// <param name="id">����ֵ</param> /// <returns>model</returns> public SFileUsingListData GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from SFileUsingList"); strSql.Append(" where id = @id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int) }; parameters[0].Value = id; SFileUsingListData model = new SFileUsingListData(); DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { DataRow row = ds.Tables[0].Rows[0]; if (row["id"] != DBNull.Value) { model.id = Convert.ToInt32(row["id"]); } if (row["orginId"] != DBNull.Value) { model.orginId = Convert.ToInt32(row["orginId"]); } if (row["fileId"] != DBNull.Value) { model.fileId = Convert.ToInt32(row["fileId"]); } if (row["fileUsingType"] != DBNull.Value) { model.fileUsingType = Convert.ToInt32(row["fileUsingType"]); } if (row["fileOrginType"] != DBNull.Value) { model.fileOrginType = Convert.ToString(row["fileOrginType"]); } if (row["recordTitle"] != DBNull.Value) { model.recordTitle = Convert.ToString(row["recordTitle"]); } if (row["isSys"] != DBNull.Value) { model.isSys = Convert.ToBoolean(row["isSys"]); } if (row["mark"] != DBNull.Value) { model.mark = Convert.ToString(row["mark"]); } if (row["isrtEmpId"] != DBNull.Value) { model.isrtEmpId = Convert.ToInt32(row["isrtEmpId"]); } if (row["isrtDt"] != DBNull.Value) { model.isrtDt = Convert.ToString(row["isrtDt"]); } if (row["updtEmpId"] != DBNull.Value) { model.updtEmpId = Convert.ToInt32(row["updtEmpId"]); } if (row["updtDt"] != DBNull.Value) { model.updtDt = Convert.ToString(row["updtDt"]); } return model; } else { return null; } }