public bool IsExisted(WorkerStoreInfo info) { db.Open(); String query = "select count(*) from WorkerStore " + " where WorkerID = @WorkerID "; var obj = (List <int>)db.Query <int>(query, info); db.Close(); return(obj[0] > 0); }
public void Save(WorkerStoreInfo info) { if (this.IsExisted(info)) { this.Update(info); } else { this.Insert(info); } }
public void Update(WorkerStoreInfo info) { db.Open(); string query = " UPDATE [dbo].[WorkerStore] SET " + " [ClientCode] = @ClientCode " + ", [ClientWorkerID] = @ClientWorkerID " + ", [StoreCode] = @StoreCode " + ", [StartDate] = @StartDate " + ", [ToDate] = @ToDate " + " where WorkerID = @WorkerID "; db.Execute(query, info); db.Close(); }
public void Insert(WorkerStoreInfo info) { db.Open(); string query = "INSERT INTO [dbo].[WorkerStore] ( [WorkerID] " + ",[ClientCode] " + ",[ClientWorkerID] " + ",[StoreCode] " + ",[StartDate] " + ",[ToDate] " + ") " + "VALUES ( @WorkerID " + ",@ClientCode " + ",@ClientWorkerID " + ",@StoreCode " + ",@StartDate " + ",@ToDate " + ") "; db.Execute(query, info); db.Close(); }