public object UpdateHcServicecenterInfo(object param) { Database db = DatabaseFactory.CreateDatabase(); object retObj = null; using (DbConnection connection = db.CreateConnection()) { connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { HcServicecenterEntity hcServicecenterEntity = (HcServicecenterEntity)param; HcServicecenterDAL hcServicecenterDAL = new HcServicecenterDAL(); retObj = (object)hcServicecenterDAL.UpdateHcServicecenterInfo(hcServicecenterEntity, db, transaction); transaction.Commit(); } catch { transaction.Rollback(); throw; } finally { connection.Close(); } } return(retObj); }
public DataTable GetAllHcServicecenterRecord(object param) { Database db = DatabaseFactory.CreateDatabase(); string sql = @"SELECT Distinct A.Id, A.serviceCenterName, A.serviceCenerAddress, A.Latitude, A.Longitude, A.Phone, A.Email, A.ownerName, A.status, A.createdBy, A.createdAt, A.serviceType, B.Name as ServiceName, A.serviceTags FROM HC_ServiceCenter A, HC_Services B where A.serviceType = B.ID"; HcServicecenterEntity obj = new HcServicecenterEntity(); if (param != null) { obj = (HcServicecenterEntity)param; } if (!string.IsNullOrEmpty(obj.Status)) { sql += " And A.Status = '" + obj.Status + "'"; } if (!string.IsNullOrEmpty(obj.Servicetype)) { sql += " And A.serviceType = '" + obj.Servicetype + "'"; } DbCommand dbCommand = db.GetSqlStringCommand(sql); DataSet ds = db.ExecuteDataSet(dbCommand); return(ds.Tables[0]); }
public bool UpdateHcServicecenterInfo(HcServicecenterEntity hcServicecenterEntity, Database db, DbTransaction transaction) { string sql = "UPDATE HC_ServiceCenter SET serviceCenterName= @Servicecentername, serviceCenerAddress= @Serviceceneraddress, Latitude= @Latitude, Longitude= @Longitude, Phone= @Phone, Email= @Email, ownerName= @Ownername, status= @Status, createdBy= @Createdby, createdAt= @Createdat, serviceType= @Servicetype, serviceTags= @Servicetags WHERE Id=@Id"; DbCommand dbCommand = db.GetSqlStringCommand(sql); db.AddInParameter(dbCommand, "Id", DbType.String, hcServicecenterEntity.Id); db.AddInParameter(dbCommand, "Servicecentername", DbType.String, hcServicecenterEntity.Servicecentername); db.AddInParameter(dbCommand, "Serviceceneraddress", DbType.String, hcServicecenterEntity.Serviceceneraddress); db.AddInParameter(dbCommand, "Latitude", DbType.String, hcServicecenterEntity.Latitude); db.AddInParameter(dbCommand, "Longitude", DbType.String, hcServicecenterEntity.Longitude); db.AddInParameter(dbCommand, "Phone", DbType.String, hcServicecenterEntity.Phone); db.AddInParameter(dbCommand, "Email", DbType.String, hcServicecenterEntity.Email); db.AddInParameter(dbCommand, "Ownername", DbType.String, hcServicecenterEntity.Ownername); db.AddInParameter(dbCommand, "Status", DbType.String, hcServicecenterEntity.Status); db.AddInParameter(dbCommand, "Createdby", DbType.String, hcServicecenterEntity.Createdby); db.AddInParameter(dbCommand, "Createdat", DbType.String, hcServicecenterEntity.Createdat); db.AddInParameter(dbCommand, "Servicetype", DbType.String, hcServicecenterEntity.Servicetype); db.AddInParameter(dbCommand, "Servicetags", DbType.String, hcServicecenterEntity.Servicetags); db.ExecuteNonQuery(dbCommand, transaction); return(true); }
public bool SaveHcServicecenterInfo(HcServicecenterEntity hcServicecenterEntity, Database db, DbTransaction transaction) { string sql = "INSERT INTO HC_ServiceCenter ( Id, serviceCenterName, serviceCenerAddress, Latitude, Longitude, Phone, Email, ownerName, status, createdBy, createdAt, serviceType, serviceTags) VALUES ( @Id, @Servicecentername, @Serviceceneraddress, @Latitude, @Longitude, @Phone, @Email, @Ownername, @Status, @Createdby, @Createdat, @Servicetype, @Servicetags )"; DbCommand dbCommand = db.GetSqlStringCommand(sql); db.AddInParameter(dbCommand, "Id", DbType.String, hcServicecenterEntity.Id); db.AddInParameter(dbCommand, "Servicecentername", DbType.String, hcServicecenterEntity.Servicecentername); db.AddInParameter(dbCommand, "Serviceceneraddress", DbType.String, hcServicecenterEntity.Serviceceneraddress); db.AddInParameter(dbCommand, "Latitude", DbType.String, hcServicecenterEntity.Latitude); db.AddInParameter(dbCommand, "Longitude", DbType.String, hcServicecenterEntity.Longitude); db.AddInParameter(dbCommand, "Phone", DbType.String, hcServicecenterEntity.Phone); db.AddInParameter(dbCommand, "Email", DbType.String, hcServicecenterEntity.Email); db.AddInParameter(dbCommand, "Ownername", DbType.String, hcServicecenterEntity.Ownername); db.AddInParameter(dbCommand, "Status", DbType.String, hcServicecenterEntity.Status); db.AddInParameter(dbCommand, "Createdby", DbType.String, hcServicecenterEntity.Createdby); db.AddInParameter(dbCommand, "Createdat", DbType.String, hcServicecenterEntity.Createdat); db.AddInParameter(dbCommand, "Servicetype", DbType.String, hcServicecenterEntity.Servicetype); db.AddInParameter(dbCommand, "Servicetags", DbType.String, hcServicecenterEntity.Servicetags); db.ExecuteNonQuery(dbCommand, transaction); return(true); }
public HcServicecenterEntity GetSingleHcServicecenterRecordById(object param) { Database db = DatabaseFactory.CreateDatabase(); string sql = "SELECT Id, serviceCenterName, serviceCenerAddress, Latitude, Longitude, Phone, Email, ownerName, status, createdBy, createdAt, serviceType, serviceTags FROM HC_ServiceCenter WHERE Id=@Id"; DbCommand dbCommand = db.GetSqlStringCommand(sql); db.AddInParameter(dbCommand, "Id", DbType.String, param); HcServicecenterEntity hcServicecenterEntity = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { hcServicecenterEntity = new HcServicecenterEntity(); if (dataReader["Id"] != DBNull.Value) { hcServicecenterEntity.Id = dataReader["Id"].ToString(); } if (dataReader["serviceCenterName"] != DBNull.Value) { hcServicecenterEntity.Servicecentername = dataReader["serviceCenterName"].ToString(); } if (dataReader["serviceCenerAddress"] != DBNull.Value) { hcServicecenterEntity.Serviceceneraddress = dataReader["serviceCenerAddress"].ToString(); } if (dataReader["Latitude"] != DBNull.Value) { hcServicecenterEntity.Latitude = dataReader["Latitude"].ToString(); } if (dataReader["Longitude"] != DBNull.Value) { hcServicecenterEntity.Longitude = dataReader["Longitude"].ToString(); } if (dataReader["Phone"] != DBNull.Value) { hcServicecenterEntity.Phone = dataReader["Phone"].ToString(); } if (dataReader["Email"] != DBNull.Value) { hcServicecenterEntity.Email = dataReader["Email"].ToString(); } if (dataReader["ownerName"] != DBNull.Value) { hcServicecenterEntity.Ownername = dataReader["ownerName"].ToString(); } if (dataReader["status"] != DBNull.Value) { hcServicecenterEntity.Status = dataReader["status"].ToString(); } if (dataReader["createdBy"] != DBNull.Value) { hcServicecenterEntity.Createdby = dataReader["createdBy"].ToString(); } if (dataReader["createdAt"] != DBNull.Value) { hcServicecenterEntity.Createdat = dataReader["createdAt"].ToString(); } if (dataReader["serviceType"] != DBNull.Value) { hcServicecenterEntity.Servicetype = dataReader["serviceType"].ToString(); } if (dataReader["serviceTags"] != DBNull.Value) { hcServicecenterEntity.Servicetags = dataReader["serviceTags"].ToString(); } } } return(hcServicecenterEntity); }