private void setParameter(iSqlParameter[] parms, ItemcategoryattrInfo info) { try { int i = -1; parms[++i].Value = info.Iid; parms[++i].Value = info.Categoryid; parms[++i].Value = info.Belongto; return; } catch (Exception ex) { throw ex; } }
private ItemcategoryattrInfo getDataReader(iSqlDataReader dar) { try { int i = -1; ItemcategoryattrInfo info = new ItemcategoryattrInfo(); info.Iid = dar.IsDBNull(++i) ? 0 : dar.GetInt32(i); info.Categoryid = dar.IsDBNull(++i) ? 0 : dar.GetInt32(i); info.Belongto = dar.IsDBNull(++i) ? 0 : dar.GetInt32(i); return info; } catch (Exception ex) { throw ex; } }
private bool Saveitem(iSqlTransaction trans, ItemcategoryattrInfo info) { try { if (trans == null || info == null) return false; string SQL = SQL_INSERT; iSqlParameter[] parms = this.getParameter(SQL); this.setParameter(parms, info); HELPER.executeNonQuery(trans, iCommandType.Text, SQL, parms); return true; } catch (Exception ex) { throw ex; } }
public bool Save(int iid, int belongto, string categoryid) { try { using (iSqlConnection iConn = HELPER.getConnect(HELPER.SQL_SYSTEM)) { using (iSqlTransaction trans = iConn.BeginTransaction()) { try { if (this.Deleteitem(trans, iid, belongto)) { if (!CFunctions.IsNullOrEmpty(categoryid)) { string[] strid = categoryid.Split(','); if (strid.Length > 0) { for (int i = 0; i < strid.Length; i++) { ItemcategoryattrInfo info = new ItemcategoryattrInfo(); info.Iid = iid; info.Belongto = belongto; info.Categoryid = Convert.ToInt32(strid[i]); this.Saveitem(trans, info); } } } } trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw ex; } } iConn.Close(); } return true; } catch (Exception ex) { throw ex; } }