public bool IsExisted(PayrollTypeInfo info) { db.Open(); String query = "select count(*) from PayrollType " + " where PayrollType = @PayrollType "; var obj = (List <int>)db.Query <int>(query, info); db.Close(); return(obj[0] > 0); }
public void Save(PayrollTypeInfo info) { if (this.IsExisted(info)) { this.Update(info); } else { this.Insert(info); } }
public void Update(PayrollTypeInfo info) { db.Open(); string query = " UPDATE [dbo].[PayrollType] SET " + " [PayrollTypeDesc] = @PayrollTypeDesc " + ", [CreateUser] = @CreateUser " + ", [CreateDate] = @CreateDate " + ", [LastModifyUser] = @LastModifyUser " + ", [LastModifyDate] = @LastModifyDate " + " where PayrollType = @PayrollType "; db.Execute(query, info); db.Close(); }
public void Insert(PayrollTypeInfo info) { db.Open(); string query = "INSERT INTO [dbo].[PayrollType] ( [PayrollType] " + ",[PayrollTypeDesc] " + ",[CreateUser] " + ",[CreateDate] " + ",[LastModifyUser] " + ",[LastModifyDate] " + ") " + "VALUES ( @PayrollType " + ",@PayrollTypeDesc " + ",@CreateUser " + ",@CreateDate " + ",@LastModifyUser " + ",@LastModifyDate " + ") "; db.Execute(query, info); db.Close(); }