public long GetIncrease(long count, SerialNoKey key, string ex = "") { long id = 0; var db = DBHelper.GetInstance(mContext); var tran = db.BeginTransaction(); try { DataTable dt = db.ExecuteDt(tran, string.Format("select _number from _SerialNo where _key ={0} and _ex='{1}' ", (int)key, ex)); if (dt.Rows.Count == 0) { id = 1; db.ExecuteSql(tran, string.Format("insert into _SerialNo(_key,_ex ,_number) values ({0},'{1}',{2})", (int)key, ex, id + count)); } else { id = (long)dt.Rows[0][0]; db.ExecuteSql(tran, string.Format("update _SerialNo set _number = {2} where _key = {0} and _ex='{1}'", (int)key, ex, id + count)); } db.CommitTransaction(tran); } catch (Exception e) { db.RollbackTransaction(tran); throw e; } return(id); }
public long Get(SerialNoKey key, string ex = "") { var rsp = Execute(new SerialNoRequest { Ex = ex, SerialKey = (int)key }); return(rsp.id); }
public long Get(SerialNoKey key, string ex = "") { var obj = DBHelper.GetInstance(mContext).ExecuteScalar(string.Format("select _number from _SerialNo where _key ={0} and _ex='{1}' ", (int)key, ex)); if (obj == null) { return(1); } else { return((long)obj); } }
public void Update(SerialNoKey key, string ex = "") { DBHelper.GetInstance(mContext).ExecuteSql(string.Format("update _SerialNo set _number=_number + 1 where _key={0} and _ex='{1}'", (int)key, ex)); }