Exemple #1
0
 public bool Add(Fair info)
 {
     bool result = false;
     try
     {
         result = WriteFair(ProceduresNames.FairAdd, info, true);
     }
     catch (Exception error)
     {
         throw error;
     }
     return result;
 }
Exemple #2
0
    private string ConfirmSavingAndUploading(Fair info, bool isRecordSaved, bool isFileUploaded, string savedFile, string confirmationPage, string BackUrl, bool deleteOldFile, string oldFilePath, bool IsNewFile, bool IsInsert)
    {
        string result = null;

        List<KeyValue> qsParameters;

        if (isRecordSaved && isFileUploaded)
        {
            if (IsNewFile && Utility.CheckFileExists(savedFile))
            {
                string[] fileInfo = Utility.GetFileInfo(savedFile);
                Utility.ResizeImage(savedFile, string.Concat(fileInfo[0], CommonStrings.Small, fileInfo[1]), 200);
                Utility.DeleteFile(savedFile);
            }

            if (deleteOldFile && !string.IsNullOrEmpty(oldFilePath))
            {
                string[] fileInfo = Utility.GetFileInfo(oldFilePath);
                if (Utility.CheckFileExists(Server.MapPath(string.Concat(fileInfo[0], CommonStrings.Small, fileInfo[1]))))
                {
                    Utility.DeleteFile(Server.MapPath(string.Concat(fileInfo[0], CommonStrings.Small, fileInfo[1])));
                }
            }

            result = Utility.AppendQueryString(confirmationPage, new KeyValue(CommonStrings.BackUrl, BackUrl));
        }
        else if (!isRecordSaved && isFileUploaded)
        {
            if (IsNewFile && Utility.CheckFileExists(savedFile))
            {
                Utility.DeleteFile(savedFile);
            }

            qsParameters = new List<KeyValue>();
            qsParameters.Add(new KeyValue(CommonStrings.BackUrl, BackUrl));
            qsParameters.Add(new KeyValue(CommonStrings.Error, CommonStrings.RecoredSavingFailed));

            result = Utility.AppendQueryString(PagesPathes.ErrorPage, qsParameters);
        }
        else if (isRecordSaved && !isFileUploaded)
        {
            if (IsInsert)
            {
                fairsOperator.Delete(info.ID);
            }

            qsParameters = new List<KeyValue>();
            qsParameters.Add(new KeyValue(CommonStrings.BackUrl, BackUrl));
            qsParameters.Add(new KeyValue(CommonStrings.Error, CommonStrings.FileUploadingFailed));

            result = Utility.AppendQueryString(PagesPathes.ErrorPage, qsParameters);
        }
        else
        {
            result = Utility.AppendQueryString(PagesPathes.ErrorPage, new KeyValue(CommonStrings.BackUrl, BackUrl));
        }

        return result;
    }
Exemple #3
0
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            string redirectPage = null;
            try
            {
                Fair info = new Fair();

                info.NameAr = txtNameAr.Text.Trim();
                info.NameEn = txtNameEn.Text.Trim();
                info.AddressAr = txtAddressAr.Value.Trim();
                info.AddressEn = txtAddressEn.Value.Trim();
                info.ShortDescriptionAr = txtShortDescriptionAr.Value.Trim();
                info.ShortDescriptionEn = txtShortDescriptionEn.Value.Trim();
                info.ContactPerson = txtContactPerson.Text.Trim();

                if (!string.IsNullOrEmpty(txtDescriptionAr.Value.Trim()))
                    info.DescriptionAr = txtDescriptionAr.Value.Trim();
                else
                    info.DescriptionAr = null;

                if (!string.IsNullOrEmpty(txtDescriptionEn.Value.Trim()))
                    info.DescriptionEn = txtDescriptionEn.Value.Trim();
                else
                    info.DescriptionEn = null;

                if (!string.IsNullOrEmpty(txtContactPersonEmail.Text.Trim()))
                    info.ContactPersonEmail = txtContactPersonEmail.Text.Trim();
                else
                    info.ContactPersonEmail = null;

                if (!string.IsNullOrEmpty(txtContactPersonMobile.Text.Trim()))
                    info.ContactPersonMobile = txtContactPersonMobile.Text.Trim();
                else
                    info.ContactPersonMobile = null;

                if (!string.IsNullOrEmpty(txtWebsite.Text.Trim()))
                    info.Website = txtWebsite.Text.Trim();
                else
                    info.Website = null;

                if (!string.IsNullOrEmpty(txtEmail.Text.Trim()))
                    info.Email = txtEmail.Text.Trim();
                else
                    info.Email = null;

                if (!string.IsNullOrEmpty(txtPhone1.Text.Trim()))
                    info.Phone1 = txtPhone1.Text.Trim();
                else
                    info.Phone1 = null;

                if (!string.IsNullOrEmpty(txtPhone2.Text.Trim()))
                    info.Phone2 = txtPhone2.Text.Trim();
                else
                    info.Phone2 = null;

                if (!string.IsNullOrEmpty(txtPhone3.Text.Trim()))
                    info.Phone3 = txtPhone3.Text.Trim();
                else
                    info.Phone3 = null;

                if (!string.IsNullOrEmpty(txtMobile1.Text.Trim()))
                    info.Mobile1 = txtMobile1.Text.Trim();
                else
                    info.Mobile1 = null;

                if (!string.IsNullOrEmpty(txtMobile2.Text.Trim()))
                    info.Mobile2 = txtMobile2.Text.Trim();
                else
                    info.Mobile2 = null;

                if (!string.IsNullOrEmpty(txtMobile3.Text.Trim()))
                    info.Mobile3 = txtMobile1.Text.Trim();
                else
                    info.Mobile3 = null;

                if (!string.IsNullOrEmpty(txtFax.Text.Trim()))
                    info.Fax = txtFax.Text.Trim();
                else
                    info.Fax = null;

                if (drpLocation.SelectedIndex > 0)
                    info.LocationInfo.ID = Convert.ToInt32(drpLocation.SelectedItem.Value);

                if (!string.IsNullOrEmpty(txtStartDate.Text.Trim()))
                {
                    string[] tempDate = txtStartDate.Text.Trim().Split('/');
                    info.StartDate = new DateTime(Convert.ToInt32(tempDate[2]), Convert.ToInt32(tempDate[1]), Convert.ToInt32(tempDate[0]));
                }

                if (!string.IsNullOrEmpty(txtEndDate.Text.Trim()))
                {
                    string[] tempDate = txtEndDate.Text.Trim().Split('/');
                    info.EndDate = new DateTime(Convert.ToInt32(tempDate[2]), Convert.ToInt32(tempDate[1]), Convert.ToInt32(tempDate[0]));
                }

                bool IsRecordSaved = false;
                bool IsFileUploaded = false;

                if (Request.QueryString[CommonStrings.ID] != null)
                {
                    info.ID = Convert.ToInt32(Request.QueryString[CommonStrings.ID]);

                    if (hidImageFlag.Value == CommonStrings.NewImage)
                    {
                        string oldFileName = null;
                        bool changeFile = false;
                        if (ViewState["FairImage"] != null)
                        {
                            oldFileName = ViewState["FairImage"].ToString();
                            changeFile = true;
                        }

                        string savedFileName;
                        string savedFilePath;
                        IsFileUploaded = Utility.UploadFile(fuImage, Server.MapPath(CommonStrings.FairsImages), out savedFilePath, out savedFileName);
                        info.Image = string.Concat(CommonStrings.FairsImages, savedFileName);
                        IsRecordSaved = fairsOperator.Update(info);
                        redirectPage = ConfirmSavingAndUploading(info,
                                                                 IsRecordSaved,
                                                                 IsFileUploaded,
                                                                 savedFilePath,
                                                                 PagesPathes.ConfirmUpdate,
                                                                 "ListFairs",
                                                                 changeFile,
                                                                 oldFileName,
                                                                 true, false);
                    }
                    else
                    {
                        IsFileUploaded = true;
                        info.Image = ViewState["FairImage"].ToString();
                        IsRecordSaved = fairsOperator.Update(info);
                        redirectPage = ConfirmSavingAndUploading(info,
                                                                 IsRecordSaved,
                                                                 IsFileUploaded,
                                                                 info.Image,
                                                                 PagesPathes.ConfirmUpdate,
                                                                 "ListFairs",
                                                                 false, null, false, false);
                    }
                    if (IsRecordSaved)
                    {
                        if (chkIsActive.Checked)
                            fairsOperator.Activate(info.ID, null);
                        else
                            fairsOperator.Deactivate(info.ID, null);
                    }
                }
                else
                {
                    string savedFileName;
                    string savedFilePath;
                    IsFileUploaded = Utility.UploadFile(fuImage, Server.MapPath(CommonStrings.FairsImages), out savedFilePath, out savedFileName);
                    info.Image = string.Concat(CommonStrings.FairsImages, savedFileName);
                    IsRecordSaved = fairsOperator.Add(info);
                    redirectPage = ConfirmSavingAndUploading(info,
                                                             IsRecordSaved,
                                                             IsFileUploaded,
                                                             savedFilePath,
                                                             PagesPathes.ConfirmInsert,
                                                             "ListFairs",
                                                             false, null, true, true);

                    if (IsRecordSaved)
                    {
                        if (chkIsActive.Checked)
                            fairsOperator.Activate(info.ID, null);
                        else
                            fairsOperator.Deactivate(info.ID, null);
                    }
                }
            }
            catch
            {
                redirectPage = Utility.AppendQueryString(PagesPathes.ErrorPage, new KeyValue(CommonStrings.BackUrl, "ListFairs"));
            }
            finally
            {
                Response.Redirect(redirectPage);
            }
        }
    }
Exemple #4
0
        private bool WriteFair(string ProcedureName, Fair 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, Fair.TableColumns.NameAr), info.NameAr);
                command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.NameEn), info.NameEn);
                command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.ShortDescriptionAr), info.ShortDescriptionAr);
                command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.ShortDescriptionEn), info.ShortDescriptionEn);
                command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.AddressAr), info.AddressAr);
                command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.AddressEn), info.AddressEn);
                command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.LocationID), info.LocationInfo.ID);
                command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.StartDate), info.StartDate);
                command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.EndDate), info.EndDate);

                if (!string.IsNullOrEmpty(info.DescriptionAr))
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.DescriptionAr), info.DescriptionAr);
                else
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.DescriptionAr), DBNull.Value);

                if (!string.IsNullOrEmpty(info.DescriptionEn))
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.DescriptionEn), info.DescriptionEn);
                else
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.DescriptionEn), DBNull.Value);

                if (!string.IsNullOrEmpty(info.ContactPerson))
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.ContactPerson), info.ContactPerson);
                else
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.ContactPerson), DBNull.Value);

                if (!string.IsNullOrEmpty(info.ContactPersonMobile))
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.ContactPersonMobile), info.ContactPersonMobile);
                else
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.ContactPersonMobile), DBNull.Value);

                if (!string.IsNullOrEmpty(info.ContactPersonEmail))
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.ContactPersonEmail), info.ContactPersonEmail);
                else
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.ContactPersonEmail), DBNull.Value);

                if (!string.IsNullOrEmpty(info.Phone1))
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.Phone1), info.Phone1);
                else
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.Phone1), DBNull.Value);

                if (!string.IsNullOrEmpty(info.Phone2))
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.Phone2), info.Phone2);
                else
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.Phone2), DBNull.Value);

                if (!string.IsNullOrEmpty(info.Phone3))
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.Phone3), info.Phone3);
                else
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.Phone3), DBNull.Value);

                if (!string.IsNullOrEmpty(info.Mobile1))
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.Mobile1), info.Mobile1);
                else
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.Mobile1), DBNull.Value);

                if (!string.IsNullOrEmpty(info.Mobile2))
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.Mobile2), info.Mobile2);
                else
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.Mobile2), DBNull.Value);

                if (!string.IsNullOrEmpty(info.Mobile3))
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.Mobile3), info.Mobile3);
                else
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.Mobile3), DBNull.Value);

                if (!string.IsNullOrEmpty(info.Fax))
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.Fax), info.Fax);
                else
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.Fax), DBNull.Value);

                if (!string.IsNullOrEmpty(info.Website))
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.Website), info.Website);
                else
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.Website), DBNull.Value);

                if (!string.IsNullOrEmpty(info.Email))
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.Email), info.Email);
                else
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.Email), DBNull.Value);

                if (!string.IsNullOrEmpty(info.Image))
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.Image), info.Image);
                else
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.TableColumns.Image), DBNull.Value);

                if (IsNew)
                {
                    command.Parameters.Add(string.Concat(CommonStrings.AtSymbol, Fair.CommonColumns.ID), SqlDbType.Int);
                    command.Parameters[string.Concat(CommonStrings.AtSymbol, Fair.CommonColumns.ID)].Direction = ParameterDirection.Output;

                    if (info.CreatedBy.HasValue)
                        command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.CommonColumns.CreatedBy), info.CreatedBy.Value);
                    else
                        command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.CommonColumns.CreatedBy), DBNull.Value);
                }
                else
                {
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.CommonColumns.ID), info.ID);

                    if (info.ModifiedBy.HasValue)
                        command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.CommonColumns.ModifiedBy), info.ModifiedBy.Value);
                    else
                        command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, Fair.CommonColumns.ModifiedBy), DBNull.Value);
                }

                this.OpenConnection();

                command.ExecuteNonQuery();

                if (IsNew)
                {
                    info.ID = Convert.ToInt32(command.Parameters[string.Concat(CommonStrings.AtSymbol, Fair.CommonColumns.ID)].Value);
                }

                result = true;
            }
            catch (Exception error)
            {
                throw error;
            }
            finally
            {
                this.CloseConnection();
            }
            return result;
        }
Exemple #5
0
        private void ReadFairList(SqlDataReader reader, List<Fair> infoList, bool? IsArabic)
        {
            try
            {
                Fair info = null;

                if (!IsArabic.HasValue)
                {
                    while (reader.Read())
                    {
                        info = new Fair();

                        info.ID = Convert.ToInt32(reader[Fair.CommonColumns.ID]);
                        info.LocationInfo.ID = Convert.ToInt32(reader[Fair.TableColumns.LocationID]);
                        info.LocationInfo.DistrictAr = Convert.ToString(reader[Location.TableColumns.DistrictAr]);
                        info.LocationInfo.DistrictEn = Convert.ToString(reader[Location.TableColumns.DistrictEn]);
                        info.StartDate = Convert.ToDateTime(reader[Fair.TableColumns.StartDate]);
                        info.EndDate = Convert.ToDateTime(reader[Fair.TableColumns.EndDate]);
                        info.NameAr = Convert.ToString(reader[Fair.TableColumns.NameAr]);
                        info.NameEn = Convert.ToString(reader[Fair.TableColumns.NameEn]);
                        info.ShortDescriptionAr = Convert.ToString(reader[Fair.TableColumns.ShortDescriptionAr]);
                        info.ShortDescriptionEn = Convert.ToString(reader[Fair.TableColumns.ShortDescriptionEn]);
                        info.AddressAr = Convert.ToString(reader[Fair.TableColumns.AddressAr]);
                        info.AddressEn = Convert.ToString(reader[Fair.TableColumns.AddressEn]);
                        info.IsActive = Convert.ToBoolean(reader[Fair.TableColumns.IsActive]);
                        info.CreationDate = Convert.ToDateTime(reader[Fair.CommonColumns.CreationDate]);

                        if (reader[Fair.TableColumns.ContactPerson] != DBNull.Value)
                            info.ContactPerson = Convert.ToString(reader[Fair.TableColumns.ContactPerson]);

                        if (reader[Fair.TableColumns.ContactPersonMobile] != DBNull.Value)
                            info.ContactPersonMobile = Convert.ToString(reader[Fair.TableColumns.ContactPersonMobile]);

                        if (reader[Fair.TableColumns.ContactPersonEmail] != DBNull.Value)
                            info.ContactPersonEmail = Convert.ToString(reader[Fair.TableColumns.ContactPersonEmail]);

                        if (reader[Fair.TableColumns.Phone1] != DBNull.Value)
                            info.Phone1 = Convert.ToString(reader[Fair.TableColumns.Phone1]);

                        if (reader[Fair.TableColumns.Phone2] != DBNull.Value)
                            info.Phone2 = Convert.ToString(reader[Fair.TableColumns.Phone2]);

                        if (reader[Fair.TableColumns.Phone3] != DBNull.Value)
                            info.Phone3 = Convert.ToString(reader[Fair.TableColumns.Phone3]);

                        if (reader[Fair.TableColumns.Mobile1] != DBNull.Value)
                            info.Mobile1 = Convert.ToString(reader[Fair.TableColumns.Mobile1]);

                        if (reader[Fair.TableColumns.Mobile2] != DBNull.Value)
                            info.Mobile2 = Convert.ToString(reader[Fair.TableColumns.Mobile2]);

                        if (reader[Fair.TableColumns.Mobile3] != DBNull.Value)
                            info.Mobile3 = Convert.ToString(reader[Fair.TableColumns.Mobile3]);

                        if (reader[Fair.TableColumns.Fax] != DBNull.Value)
                            info.Fax = Convert.ToString(reader[Fair.TableColumns.Fax]);

                        if (reader[Fair.TableColumns.Website] != DBNull.Value)
                            info.Website = Convert.ToString(reader[Fair.TableColumns.Website]);

                        if (reader[Fair.TableColumns.Email] != DBNull.Value)
                            info.Email = Convert.ToString(reader[Fair.TableColumns.Email]);

                        if (reader[Fair.TableColumns.Image] != DBNull.Value)
                            info.Image = Convert.ToString(reader[Fair.TableColumns.Image]);

                        if (reader[Fair.TableColumns.Rate] != DBNull.Value)
                            info.Rate = Convert.ToInt32(reader[Fair.TableColumns.Rate]);
                        else
                            info.Rate = null;

                        if (reader[Fair.TableColumns.RateTotal] != DBNull.Value)
                            info.RateTotal = Convert.ToInt32(reader[Fair.TableColumns.RateTotal]);
                        else
                            info.RateTotal = null;

                        if (reader[Fair.TableColumns.RateCount] != DBNull.Value)
                            info.RateCount = Convert.ToInt32(reader[Fair.TableColumns.RateCount]);
                        else
                            info.RateCount = null;

                        if (reader[Fair.TableColumns.Likes] != DBNull.Value)
                            info.Likes = Convert.ToInt32(reader[Fair.TableColumns.Likes]);
                        else
                            info.Likes = null;

                        if (reader[Fair.TableColumns.DescriptionAr] != DBNull.Value)
                            info.DescriptionAr = Convert.ToString(reader[Fair.TableColumns.DescriptionAr]);

                        if (reader[Fair.TableColumns.DescriptionEn] != DBNull.Value)
                            info.DescriptionEn = Convert.ToString(reader[Fair.TableColumns.DescriptionEn]);

                        if (reader[Fair.TableColumns.ActivationDate] != DBNull.Value)
                            info.ActivationDate = Convert.ToDateTime(reader[Fair.TableColumns.ActivationDate]);
                        else
                            info.ActivationDate = null;

                        if (reader[Fair.TableColumns.ActivatedBy] != DBNull.Value)
                            info.ActivatedBy = (Guid)reader[Fair.TableColumns.ActivatedBy];
                        else
                            info.ActivatedBy = null;

                        if (reader[Fair.TableColumns.DeactivationDate] != DBNull.Value)
                            info.DeactivationDate = Convert.ToDateTime(reader[Fair.TableColumns.DeactivationDate]);
                        else
                            info.DeactivationDate = null;

                        if (reader[Fair.TableColumns.DeactivatedBy] != DBNull.Value)
                            info.DeactivatedBy = (Guid)reader[Fair.TableColumns.DeactivatedBy];
                        else
                            info.DeactivatedBy = null;

                        if (reader[Fair.CommonColumns.CreatedBy] != DBNull.Value)
                            info.CreatedBy = (Guid)reader[Fair.CommonColumns.CreatedBy];
                        else
                            info.CreatedBy = null;

                        if (reader[Fair.CommonColumns.ModificationDate] != DBNull.Value)
                            info.ModificationDate = Convert.ToDateTime(reader[Fair.CommonColumns.ModificationDate]);
                        else
                            info.ModificationDate = null;

                        if (reader[Fair.CommonColumns.ModifiedBy] != DBNull.Value)
                            info.ModifiedBy = (Guid)reader[Fair.CommonColumns.ModifiedBy];
                        else
                            info.ModifiedBy = null;

                        infoList.Add(info);
                    }
                }
                else
                {
                    if (IsArabic.Value)
                    {
                        while (reader.Read())
                        {
                            info = new Fair();

                            info.ID = Convert.ToInt32(reader[Fair.CommonColumns.ID]);
                            info.LocationInfo.ID = Convert.ToInt32(reader[Fair.TableColumns.LocationID]);
                            info.LocationInfo.DistrictAr = Convert.ToString(reader[Location.TableColumns.DistrictAr]);
                            info.StartDate = Convert.ToDateTime(reader[Fair.TableColumns.StartDate]);
                            info.EndDate = Convert.ToDateTime(reader[Fair.TableColumns.EndDate]);
                            info.NameAr = Convert.ToString(reader[Fair.TableColumns.NameAr]);
                            info.ShortDescriptionAr = Convert.ToString(reader[Fair.TableColumns.ShortDescriptionAr]);
                            info.AddressAr = Convert.ToString(reader[Fair.TableColumns.AddressAr]);

                            if (reader[Fair.TableColumns.ContactPerson] != DBNull.Value)
                                info.ContactPerson = Convert.ToString(reader[Fair.TableColumns.ContactPerson]);

                            if (reader[Fair.TableColumns.ContactPersonMobile] != DBNull.Value)
                                info.ContactPersonMobile = Convert.ToString(reader[Fair.TableColumns.ContactPersonMobile]);

                            if (reader[Fair.TableColumns.ContactPersonEmail] != DBNull.Value)
                                info.ContactPersonEmail = Convert.ToString(reader[Fair.TableColumns.ContactPersonEmail]);

                            if (reader[Fair.TableColumns.Phone1] != DBNull.Value)
                                info.Phone1 = Convert.ToString(reader[Fair.TableColumns.Phone1]);

                            if (reader[Fair.TableColumns.Phone2] != DBNull.Value)
                                info.Phone2 = Convert.ToString(reader[Fair.TableColumns.Phone2]);

                            if (reader[Fair.TableColumns.Phone3] != DBNull.Value)
                                info.Phone3 = Convert.ToString(reader[Fair.TableColumns.Phone3]);

                            if (reader[Fair.TableColumns.Mobile1] != DBNull.Value)
                                info.Mobile1 = Convert.ToString(reader[Fair.TableColumns.Mobile1]);

                            if (reader[Fair.TableColumns.Mobile2] != DBNull.Value)
                                info.Mobile2 = Convert.ToString(reader[Fair.TableColumns.Mobile2]);

                            if (reader[Fair.TableColumns.Mobile3] != DBNull.Value)
                                info.Mobile3 = Convert.ToString(reader[Fair.TableColumns.Mobile3]);

                            if (reader[Fair.TableColumns.Fax] != DBNull.Value)
                                info.Fax = Convert.ToString(reader[Fair.TableColumns.Fax]);

                            if (reader[Fair.TableColumns.Website] != DBNull.Value)
                                info.Website = Convert.ToString(reader[Fair.TableColumns.Website]);

                            if (reader[Fair.TableColumns.Email] != DBNull.Value)
                                info.Email = Convert.ToString(reader[Fair.TableColumns.Email]);

                            if (reader[Fair.TableColumns.Image] != DBNull.Value)
                                info.Image = Convert.ToString(reader[Fair.TableColumns.Image]);

                            if (reader[Fair.TableColumns.Rate] != DBNull.Value)
                                info.Rate = Convert.ToInt32(reader[Fair.TableColumns.Rate]);
                            else
                                info.Rate = null;

                            if (reader[Fair.TableColumns.RateTotal] != DBNull.Value)
                                info.RateTotal = Convert.ToInt32(reader[Fair.TableColumns.RateTotal]);
                            else
                                info.RateTotal = null;

                            if (reader[Fair.TableColumns.RateCount] != DBNull.Value)
                                info.RateCount = Convert.ToInt32(reader[Fair.TableColumns.RateCount]);
                            else
                                info.RateCount = null;

                            if (reader[Fair.TableColumns.Likes] != DBNull.Value)
                                info.Likes = Convert.ToInt32(reader[Fair.TableColumns.Likes]);
                            else
                                info.Likes = null;

                            if (reader[Fair.TableColumns.DescriptionAr] != DBNull.Value)
                                info.DescriptionAr = Convert.ToString(reader[Fair.TableColumns.DescriptionAr]);

                            infoList.Add(info);
                        }
                    }
                    else
                    {
                        while (reader.Read())
                        {
                            info = new Fair();

                            info.ID = Convert.ToInt32(reader[Fair.CommonColumns.ID]);
                            info.LocationInfo.ID = Convert.ToInt32(reader[Fair.TableColumns.LocationID]);
                            info.LocationInfo.DistrictEn = Convert.ToString(reader[Location.TableColumns.DistrictEn]);
                            info.StartDate = Convert.ToDateTime(reader[Fair.TableColumns.StartDate]);
                            info.EndDate = Convert.ToDateTime(reader[Fair.TableColumns.EndDate]);
                            info.NameEn = Convert.ToString(reader[Fair.TableColumns.NameEn]);
                            info.ShortDescriptionEn = Convert.ToString(reader[Fair.TableColumns.ShortDescriptionEn]);
                            info.AddressEn = Convert.ToString(reader[Fair.TableColumns.AddressEn]);

                            if (reader[Fair.TableColumns.ContactPerson] != DBNull.Value)
                                info.ContactPerson = Convert.ToString(reader[Fair.TableColumns.ContactPerson]);

                            if (reader[Fair.TableColumns.ContactPersonMobile] != DBNull.Value)
                                info.ContactPersonMobile = Convert.ToString(reader[Fair.TableColumns.ContactPersonMobile]);

                            if (reader[Fair.TableColumns.ContactPersonEmail] != DBNull.Value)
                                info.ContactPersonEmail = Convert.ToString(reader[Fair.TableColumns.ContactPersonEmail]);

                            if (reader[Fair.TableColumns.Phone1] != DBNull.Value)
                                info.Phone1 = Convert.ToString(reader[Fair.TableColumns.Phone1]);

                            if (reader[Fair.TableColumns.Phone2] != DBNull.Value)
                                info.Phone2 = Convert.ToString(reader[Fair.TableColumns.Phone2]);

                            if (reader[Fair.TableColumns.Phone3] != DBNull.Value)
                                info.Phone3 = Convert.ToString(reader[Fair.TableColumns.Phone3]);

                            if (reader[Fair.TableColumns.Mobile1] != DBNull.Value)
                                info.Mobile1 = Convert.ToString(reader[Fair.TableColumns.Mobile1]);

                            if (reader[Fair.TableColumns.Mobile2] != DBNull.Value)
                                info.Mobile2 = Convert.ToString(reader[Fair.TableColumns.Mobile2]);

                            if (reader[Fair.TableColumns.Mobile3] != DBNull.Value)
                                info.Mobile3 = Convert.ToString(reader[Fair.TableColumns.Mobile3]);

                            if (reader[Fair.TableColumns.Fax] != DBNull.Value)
                                info.Fax = Convert.ToString(reader[Fair.TableColumns.Fax]);

                            if (reader[Fair.TableColumns.Website] != DBNull.Value)
                                info.Website = Convert.ToString(reader[Fair.TableColumns.Website]);

                            if (reader[Fair.TableColumns.Email] != DBNull.Value)
                                info.Email = Convert.ToString(reader[Fair.TableColumns.Email]);

                            if (reader[Fair.TableColumns.Image] != DBNull.Value)
                                info.Image = Convert.ToString(reader[Fair.TableColumns.Image]);

                            if (reader[Fair.TableColumns.Rate] != DBNull.Value)
                                info.Rate = Convert.ToInt32(reader[Fair.TableColumns.Rate]);
                            else
                                info.Rate = null;

                            if (reader[Fair.TableColumns.RateTotal] != DBNull.Value)
                                info.RateTotal = Convert.ToInt32(reader[Fair.TableColumns.RateTotal]);
                            else
                                info.RateTotal = null;

                            if (reader[Fair.TableColumns.RateCount] != DBNull.Value)
                                info.RateCount = Convert.ToInt32(reader[Fair.TableColumns.RateCount]);
                            else
                                info.RateCount = null;

                            if (reader[Fair.TableColumns.Likes] != DBNull.Value)
                                info.Likes = Convert.ToInt32(reader[Fair.TableColumns.Likes]);
                            else
                                info.Likes = null;

                            if (reader[Fair.TableColumns.DescriptionEn] != DBNull.Value)
                                info.DescriptionEn = Convert.ToString(reader[Fair.TableColumns.DescriptionEn]);

                            infoList.Add(info);
                        }
                    }
                }
            }
            catch (Exception error)
            {
                throw error;
            }
        }
Exemple #6
0
 public bool Update(Fair info)
 {
     bool result = false;
     try
     {
         result = WriteFair(ProceduresNames.FairUpdate, info, false);
     }
     catch (Exception error)
     {
         throw error;
     }
     return result;
 }