public int Delete(tblCity tblCity) { int __rowsAffected = 0; // Create command using (SqlCommand sqlCommand = new SqlCommand("tblCityDelete")) { // Set command type sqlCommand.CommandType = CommandType.StoredProcedure; try { // Attach command AttachCommand(sqlCommand); // Add command parameters SqlParameter vid = new SqlParameter("@id", SqlDbType.BigInt); vid.Direction = ParameterDirection.Input; sqlCommand.Parameters.Add(vid); // Set input parameter values SqlServerHelper.SetParameterValue(vid, tblCity.id); // Execute command __rowsAffected = sqlCommand.ExecuteNonQuery(); } finally { // Detach command DetachCommand(sqlCommand); } } return(__rowsAffected); }
public int Retrieve(tblCity tblCity) { int __rowsAffected = 1; // Create command using (SqlCommand sqlCommand = new SqlCommand("tblCityGet")) { // Set command type sqlCommand.CommandType = CommandType.StoredProcedure; try { // Attach command AttachCommand(sqlCommand); // Add command parameters SqlParameter vid = new SqlParameter("@id", SqlDbType.BigInt); vid.Direction = ParameterDirection.InputOutput; sqlCommand.Parameters.Add(vid); SqlParameter vname = new SqlParameter("@name", SqlDbType.NVarChar, 100); vname.Direction = ParameterDirection.Output; sqlCommand.Parameters.Add(vname); // Set input parameter values SqlServerHelper.SetParameterValue(vid, tblCity.id); // Execute command sqlCommand.ExecuteNonQuery(); try { // Get output parameter values tblCity.id = SqlServerHelper.ToInt64(vid); tblCity.name = SqlServerHelper.ToString(vname); } catch (Exception ex) { if (ex is System.NullReferenceException) { __rowsAffected = 0; } else { throw ex; } } } finally { // Detach command DetachCommand(sqlCommand); } } return(__rowsAffected); }
public virtual void Clone(tblCity sourceObject) { if (sourceObject == null) { throw new ArgumentNullException("sourceObject"); } // Clone attributes from source object this._id = sourceObject.id; this._name = sourceObject.name; }
public int Insert(tblCity tblCity) { int __rowsAffected = 0; // Create command using (SqlCommand sqlCommand = new SqlCommand("tblCityInsert")) { // Set command type sqlCommand.CommandType = CommandType.StoredProcedure; // Add command parameters SqlParameter vid = new SqlParameter("@id", SqlDbType.BigInt); vid.Direction = ParameterDirection.InputOutput; sqlCommand.Parameters.Add(vid); SqlParameter vname = new SqlParameter("@name", SqlDbType.NVarChar, 100); vname.Direction = ParameterDirection.Input; sqlCommand.Parameters.Add(vname); // Set input parameter values SqlServerHelper.SetParameterValue( vid, tblCity.id, 0); SqlServerHelper.SetParameterValue(vname, tblCity.name); try { // Attach command AttachCommand(sqlCommand); // Execute command __rowsAffected = sqlCommand.ExecuteNonQuery(); if (__rowsAffected == 0) { return(__rowsAffected); } // Get output parameter values tblCity.id = SqlServerHelper.ToInt64(vid); } finally { // Detach command DetachCommand(sqlCommand); } } return(__rowsAffected); }