public bool Add(Location info) { bool result = false; try { result = WriteLocation(ProceduresNames.LocationAdd, info, true); } catch (Exception error) { throw error; } return result; }
public Fair() { locationInfo = new Location(); }
public Branch() { branchLocation = new Location(); }
public bool Update(Location info) { bool result = false; try { result = WriteLocation(ProceduresNames.LocationUpdate, info, false); } catch (Exception error) { throw error; } return result; }
private bool WriteLocation(string ProcedureName, Location info, bool IsNew) { bool result = false; try { SqlCommand command = new SqlCommand(ProcedureName, this.Connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Location.TableColumns.DistrictAr), info.DistrictAr); command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Location.TableColumns.DistrictEn), info.DistrictEn); if (IsNew) { command.Parameters.Add(string.Concat(CommonStrings.AtSymbol, Location.CommonColumns.ID), SqlDbType.Int); command.Parameters[string.Concat(CommonStrings.AtSymbol, Location.CommonColumns.ID)].Direction = ParameterDirection.Output; if (info.CreatedBy.HasValue) command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Location.CommonColumns.CreatedBy), info.CreatedBy.Value); else command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Location.CommonColumns.CreatedBy), DBNull.Value); } else { command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Location.CommonColumns.ID), info.ID); if (info.ModifiedBy.HasValue) command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Location.CommonColumns.ModifiedBy), info.ModifiedBy.Value); else command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Location.CommonColumns.ModifiedBy), DBNull.Value); } this.OpenConnection(); command.ExecuteNonQuery(); if (IsNew) info.ID = Convert.ToInt32(command.Parameters[string.Concat(CommonStrings.AtSymbol, Location.CommonColumns.ID)].Value); result = true; } catch (Exception error) { throw error; } finally { this.CloseConnection(); } return result; }
private void ReadLocationList(SqlDataReader reader, List<Location> infoList, bool? IsArabic) { try { Location info = null; if (!IsArabic.HasValue) { while (reader.Read()) { info = new Location(); info.ID = Convert.ToInt32(reader[Location.CommonColumns.ID]); info.DistrictAr = Convert.ToString(reader[Location.TableColumns.DistrictAr]); info.DistrictEn = Convert.ToString(reader[Location.TableColumns.DistrictEn]); info.CreationDate = Convert.ToDateTime(reader[Location.CommonColumns.CreationDate]); if (reader[Location.CommonColumns.CreatedBy] != DBNull.Value) info.CreatedBy = (Guid)reader[Location.CommonColumns.CreatedBy]; else info.CreatedBy = null; if (reader[Location.CommonColumns.ModificationDate] != DBNull.Value) info.ModificationDate = Convert.ToDateTime(reader[Location.CommonColumns.ModificationDate]); else info.ModificationDate = null; if (reader[Location.CommonColumns.ModifiedBy] != DBNull.Value) info.ModifiedBy = (Guid)reader[Location.CommonColumns.ModifiedBy]; else info.ModifiedBy = null; infoList.Add(info); } } else { if (IsArabic.Value) { while (reader.Read()) { info = new Location(); info.ID = Convert.ToInt32(reader[Location.CommonColumns.ID]); info.DistrictAr = Convert.ToString(reader[Location.TableColumns.DistrictAr]); infoList.Add(info); } } else { while (reader.Read()) { info = new Location(); info.ID = Convert.ToInt32(reader[Location.CommonColumns.ID]); info.DistrictEn = Convert.ToString(reader[Location.TableColumns.DistrictEn]); infoList.Add(info); } } } } catch (Exception error) { throw error; } }