private DateTime GetDbDate() { try { dcClientWorkStation2 dc = new dcClientWorkStation2(); DateTime _resultDate = DateTime.Now; System.Data.SqlClient.SqlCommand _cmd = new System.Data.SqlClient.SqlCommand("dbo.SelectDBDate", dc.DBConn); _cmd.CommandType = CommandType.StoredProcedure; dc.DBConn.Open(); SqlDataReader _dr = _cmd.ExecuteReader(CommandBehavior.CloseConnection); _dr.Read(); _resultDate = (DateTime)_dr[0]; dc.DBConn.Close(); return(_resultDate); } catch (Exception e) { throw e; } }
public ClientWorkStation GetClientWorkStation(int ClientId, int WorkStationId) { try { List <ClientWorkStation> result = new List <ClientWorkStation>(); dcClientWorkStation2 dc = new dcClientWorkStation2(); zsi.Framework.Data.DataProvider.SQLServer.Procedure proc = new zsi.Framework.Data.DataProvider.SQLServer.Procedure("dbo.SelectClientWorkStations"); var p = proc.Parameters; if (ClientId > 0) { p.Add("p_ClientId", ClientId); } if (WorkStationId > 0) { p.Add("p_WorkStationId", WorkStationId); } if (WorkStationId == 0) { p.Add("p_WSMacAddress", Util.GetMacAddress()); } result = dc.GetDataSource(proc); if (result.Count > 0) { return(dc.GetDataSource(proc)[0]); } else { return(new ClientWorkStation()); } } catch (SqlException ex) { if (ex.Number == 11001) { return(new ClientWorkStation()); } else { throw ex; } } }
public int UpdateWorkStation(int ClientId) { try { dcClientWorkStation2 dc = new dcClientWorkStation2(); zsi.Framework.Data.DataProvider.SQLServer.Procedure proc = new zsi.Framework.Data.DataProvider.SQLServer.Procedure("dbo.UpdateClientWorkStation"); var p = proc.Parameters; p.Add("p_WSMacAddress", Util.GetMacAddress()); p.Add("p_ClientId", ClientId); p.Add("p_CreatedUpdatedBy", ClientSettings.UserInfo.UserId); p.Add("p_WorkStationId", null, SqlDbType.Int, ParameterDirection.InputOutput); dc.Update(proc); int _WorkStationId = Convert.ToInt32(p.GetItem("p_WorkStationId").Value); return(_WorkStationId); } catch (Exception ex) { throw ex; } }