public bool InsertDanhMuc(clsDanhMuc dm) { string sql = "Insert into tblDanhMuc(TenDanhMuc,TypeID,MoTa) values(@TenDM,@Type,@Mota)"; bool st=false; clsDAConnection conn=new clsDAConnection(); conn.openCon(); using (SqlCommand com = conn.getCon().CreateCommand()) { com.CommandType = CommandType.Text; com.CommandText = sql; // Create a SqlParameter object for the title parameter. SqlParameter p1 = com.CreateParameter(); p1.ParameterName = "@TenDM"; p1.SqlDbType = SqlDbType.NVarChar; p1.Size = 50; p1.Value = dm.TenDanhMuc; com.Parameters.Add(p1); // Use a shorthand syntax to add the id parameter. com.Parameters.Add("@Type", SqlDbType.Int).Value = dm.MyType; com.Parameters.Add("@Mota", SqlDbType.NVarChar,1000).Value = dm.MoTa; // Execute the command and process the result. if (com.ExecuteNonQuery()==1) { st = true; } conn.closeCon(); return st; } }
public bool DeleteDM(clsDanhMuc dm) { string sql = "Delete from tblDanhMuc Where ID=@ID"; bool st = false; clsDAConnection conn = new clsDAConnection(); conn.openCon(); using (SqlCommand com = conn.getCon().CreateCommand()) { com.CommandType = CommandType.Text; com.CommandText = sql; com.Parameters.Add("@ID", SqlDbType.Int).Value = dm.Id; // Execute the command and process the result. if (com.ExecuteNonQuery() == 1) { st = true; } conn.closeCon(); return st; } }
public bool InsertDM(clsDanhMuc dm) { clsDADanhMuc d=new clsDADanhMuc(); return d.InsertDanhMuc(dm); }
public bool EditDM(clsDanhMuc dm) { clsDADanhMuc d = new clsDADanhMuc(); return d.EditDanhMuc(dm); }
public bool DelDM(clsDanhMuc dm) { clsDADanhMuc d = new clsDADanhMuc(); return d.DeleteDM(dm); }