public FACULTY_OBJ GetByID(FACULTY_OBJ.BusinessObjectID id) { List <FACULTY_OBJ> li = getAll(new spParam("CODE", SqlDbType.VarChar, id.CODE, 0)); if (li == null || li.Count == 0) { return(null); } return(li[0]); }
//public int Insert(FACULTY_OBJ obj) //{ // int ret = 0; // DBBase db = new DBBase(ConfigurationSettings.AppSettings["connectionString"].ToString()); // string sql = "INSERT INTO FACULTY(code,codeview, name, note, edituser,edittime,lock, lockdate) VALUES(@code,@codeview, @name, @note, @edituser,@edittime,@lock, @lockdate)"; // SqlCommand com = new SqlCommand(); // com.CommandText = sql; // com.CommandType = CommandType.Text; // com.Parameters.Add("@code", SqlDbType.VarChar).Value = obj.CODE ; // com.Parameters.Add("@timestart", SqlDbType.VarChar).Value = obj.TIMESTART; // com.Parameters.Add("@timeend", SqlDbType.VarChar).Value = obj.TIMEEND; // com.Parameters.Add("@dayinweek", SqlDbType.VarChar).Value = obj.DAYINWEEK; // com.Parameters.Add("@codeview", SqlDbType.VarChar).Value = obj.CODEVIEW; // //com.Parameters.Add("@name", SqlDbType.NVarChar).Value = obj.NAME; // //com.Parameters.Add("@note", SqlDbType.NVarChar).Value = obj.NOTE; // //com.Parameters.Add("@edituser", SqlDbType.VarChar).Value = obj.EDITUSER; // //com.Parameters.Add("@edittime", SqlDbType.DateTime).Value = obj.EDITTIME; // //com.Parameters.Add("@lock", SqlDbType.Int).Value = obj.LOCK; // //com.Parameters.Add("@lockdate", SqlDbType.DateTime).Value = obj.LOCKDATE; // ret = db.doCommand(ref com); // return ret; //} //public int Update(FACULTY_OBJ obj) //{ // int ret = 0; // DBBase db = new DBBase(ConfigurationSettings.AppSettings["connectionString"].ToString()); // string sql = @"UPDATE FACULTY SET // code=@code // ,codeview=@codeview // , name=@name // , note=@note // , edituser=@edituser // ,edittime=@edittime // ,lock=@lock // , lockdate=@lockdate // WHERE code=@code_key // "; // SqlCommand com = new SqlCommand(); // com.CommandText = sql; // com.CommandType = CommandType.Text; // com.Parameters.Add("@code", SqlDbType.VarChar).Value = obj.CODE; // com.Parameters.Add("@code", SqlDbType.VarChar).Value = obj.CODE; // com.Parameters.Add("@timestart", SqlDbType.VarChar).Value = obj.TIMESTART; // com.Parameters.Add("@timeend", SqlDbType.VarChar).Value = obj.TIMEEND; // com.Parameters.Add("@dayinweek", SqlDbType.VarChar).Value = obj.DAYINWEEK; // com.Parameters.Add("@codeview", SqlDbType.VarChar).Value = obj.CODEVIEW; // com.Parameters.Add("@codeview", SqlDbType.VarChar).Value = obj.CODEVIEW; // //com.Parameters.Add("@name", SqlDbType.NVarChar).Value = obj.NAME; // //com.Parameters.Add("@note", SqlDbType.NVarChar).Value = obj.NOTE; // //com.Parameters.Add("@edituser", SqlDbType.VarChar).Value = obj.EDITUSER; // //com.Parameters.Add("@edittime", SqlDbType.DateTime).Value = obj.EDITTIME; // //com.Parameters.Add("@lock", SqlDbType.Int).Value = obj.LOCK; // //com.Parameters.Add("@lockdate", SqlDbType.DateTime).Value = obj.LOCKDATE; // com.Parameters.Add("@code_key", SqlDbType.VarChar).Value = obj._ID.CODE; // ret = db.doCommand(ref com); // return ret; //} public int Delete(FACULTY_OBJ.BusinessObjectID obj) { int ret = 0; DBBase db = new DBBase(ConfigurationSettings.AppSettings["connectionString"].ToString()); string sql = @"DELETE FROM FACULTY WHERE code=@code_key "; SqlCommand com = new SqlCommand(); com.CommandText = sql; com.CommandType = CommandType.Text; com.Parameters.Add("@code_key", SqlDbType.VarChar).Value = obj.CODE; ret = db.doCommand(ref com); return(ret); }