protected void uiButtonUpdate_Click(object sender, EventArgs e)
 {
     if (CurrentVedio != null)
     {
         BLL.Vedios objData = CurrentVedio;
         objData.ArTitle = uiTextBoxArName.Text;
         objData.EnTitle = uiTextBoxEnName.Text;
         objData.URL = uiTextBoxURL.Text;
         objData.Save();
     }
     else
     {
         Companies objCompany = new Companies();
         objCompany.GetCompanyByUserName(User.Identity.Name);
         BLL.Vedios objData = new BLL.Vedios();
         objData.AddNew();
         objData.ArTitle = uiTextBoxArName.Text;
         objData.EnTitle = uiTextBoxEnName.Text;
         objData.URL = uiTextBoxURL.Text;
         objData.CompanyID = objCompany.CompanyID;
         objData.CreatedDate = DateTime.Now;
         objData.Save();
     }
     uiPanelEdit.Visible = false;
     uiPanelViewVideos.Visible = true;
     Clearfields();
     CurrentVedio = null;
     BindData();
 }
        protected void uiButtonUpdate_Click(object sender, EventArgs e)
        {
            if (CurrentServices != null)
            {
                BLL.Services objData = CurrentServices;
                objData.EnName = uiTextBoxEnName.Text;
                objData.ArName = uiTextBoxArName.Text;
                objData.EnDescription = Server.HtmlEncode(uiFCKeditorEnDesc.Value);
                objData.ArDescription = Server.HtmlEncode(uiFCKeditorArDesc.Value);
                objData.Save();
            }
            else
            {
                Companies objCompany = new Companies();
                objCompany.GetCompanyByUserName(User.Identity.Name);

                BLL.Services objData = new BLL.Services();
                objData.AddNew();
                objData.CompanyID = objCompany.CompanyID;
                objData.EnName = uiTextBoxEnName.Text;
                objData.ArName = uiTextBoxArName.Text;
                objData.EnDescription = Server.HtmlEncode(uiFCKeditorEnDesc.Value);
                objData.ArDescription = Server.HtmlEncode(uiFCKeditorArDesc.Value);
                objData.TypeID = Convert.ToInt32(uiDropDownListAllServiceType.SelectedValue);
                objData.CreatedDate = DateTime.Now;
                objData.Save();
            }
            uiPanelEdit.Visible = false;
            uiPanelViewServices.Visible = true;
            Clearfields();
            CurrentServices = null;
        }
 public void FilterCompanies()
 {
     Companies comp = new Companies();
     comp.SearchCompanies(uiTextBoxSearch.Text,0,Convert.ToInt32(uiDropDownListCategoryFilter.SelectedValue), Convert.ToInt32(uiDropDownListSubCategoryFilter.SelectedValue));
     uiGridViewCompanies.DataSource = comp.DefaultView;
     uiGridViewCompanies.DataBind();
 }
        private void BindData()
        {
            Companies currentCompany = new Companies();
            currentCompany.GetCompanyByUserName(Page.User.Identity.Name);
            BLL.Photos objData = new BLL.Photos();
            objData.GetPhotosByCompanyID(currentCompany.CompanyID);

            uiDataListPhotos.DataSource = objData.DefaultView;
            uiDataListPhotos.DataBind();
        }
        protected void uiLinkButtonAdd_Click(object sender, EventArgs e)
        {
            Companies currentCompany = new Companies();
            currentCompany.GetCompanyByUserName(Page.User.Identity.Name);
            if (uiFileUpload.HasFile)
            {
                DirectoryInfo Dir = new DirectoryInfo(Server.MapPath("~/FileUploads/Companies/" + currentCompany.CompanyID.ToString()));
                if (!Dir.Exists)
                    Dir.Create();

                uiFileUpload.SaveAs(Server.MapPath("~/FileUploads/Companies/" + currentCompany.CompanyID.ToString() + "/" + uiFileUpload.FileName));
                currentCompany.SchedulePath = "/FileUploads/Companies/" + currentCompany.CompanyID.ToString() + "/" + uiFileUpload.FileName;
                currentCompany.Save();
                uiLabelmsg.Visible = true;
            }
        }
        protected void uiGridViewAirLines_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                DataRowView objData = (DataRowView)e.Row.DataItem;
                AirPorts From = new AirPorts();
                AirPorts To = new AirPorts();
                Companies Comp = new Companies();
                From.LoadByPrimaryKey(Convert.ToInt32(objData["FromAirPortID"].ToString()));
                Label temp = (Label)e.Row.FindControl("uiLabelFromName");
                temp.Text = From.EnName;

                To.LoadByPrimaryKey(Convert.ToInt32(objData["ToAirPortID"].ToString()));
                Label temp2 = (Label)e.Row.FindControl("uiLabelToName");
                temp2.Text = To.EnName;

                Comp.LoadByPrimaryKey(Convert.ToInt32(objData["CompanyID"].ToString()));
                Label temp3 = (Label)e.Row.FindControl("uiLabelCompanyName");
                temp3.Text = Comp.ArName;
            }
        }
 protected void uiLinkButtonAdd_Click(object sender, EventArgs e)
 {
     Companies currentCompany = new Companies();
     currentCompany.GetCompanyByUserName(Page.User.Identity.Name);
     BLL.Photos objData = new BLL.Photos();
     objData.AddNew();
     objData.EnTitle = uiTextBoxEnName.Text;
     objData.ArTitle = uiTextBoxArName.Text;
     DirectoryInfo Dir = new DirectoryInfo(Server.MapPath("~/FileUploads/Companies/" + currentCompany.CompanyID.ToString()));
     if (!Dir.Exists)
         Dir.Create();
     if (uiFileUploadPhoto.HasFile)
     {
         uiFileUploadPhoto.SaveAs(Server.MapPath("~/FileUploads/Companies/" + currentCompany.CompanyID.ToString() + "/" + uiFileUploadPhoto.FileName));
         objData.PhotoPath = "/FileUploads/Companies/" + currentCompany.CompanyID.ToString() + "/" + uiFileUploadPhoto.FileName;
     }
     objData.CreatedDate = DateTime.Now;
     objData.CompanyID = currentCompany.CompanyID;
     objData.Save();
     BindData();
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         bool servicesEnabled = false;
         Companies currentCompany = new Companies();
         currentCompany.GetCompanyByUserName(Page.User.Identity.Name);
         CompanyEnabledOptions options = new CompanyEnabledOptions();
         options.GetCompanyEnabledOptionsByCompanyID(currentCompany.CompanyID);
         for (int i = 0; i < options.RowCount;i++ )
         {
             if ((options.PackageOptionID == 11 || options.PackageOptionID == 12 || options.PackageOptionID == 13 || options.PackageOptionID == 14) && !servicesEnabled)
             {
                 servicesEnabled = true;
                 if(options.Enabled)
                     uiLiteralMenu.Text += "<li class='VMenuBorder'></li><li><a class='hide' href='../Company/Services.aspx'>الخدمات</a></li>";
             }
             if (options.PackageOptionID == 16)
             {
                 if (options.Enabled)
                     uiLiteralMenu.Text += " <li class='VMenuBorder'></li><li><a class='hide' href='../Company/Photos.aspx'>الصور</a></li>";
             }
             if (options.PackageOptionID == 17)
             {
                 if (options.Enabled)
                     uiLiteralMenu.Text += " <li class='VMenuBorder'></li><li><a class='hide' href='../Company/Vidoes.aspx'>الفيديو</a></li>";
             }
             if (options.PackageOptionID == 19)
             {
                 if (options.Enabled)
                     uiLiteralMenu.Text += " <li class='VMenuBorder'></li><li><a class='hide' href='../Company/Schedule.aspx'>الجدول الملاحى</a></li>";
             }
             options.MoveNext();
         }
     }
 }
        private void BindData()
        {
            BLL.Services objData = new BLL.Services();
            Companies objCompany = new Companies();
            objCompany.GetCompanyByUserName(User.Identity.Name);

            objData.GetServicesByCompanyIDAndTypeID(objCompany.CompanyID, string.IsNullOrEmpty(uiDropDownListAllServiceType.SelectedValue) ? 0 : Convert.ToInt32(uiDropDownListAllServiceType.SelectedValue));
            uiGridViewServices.DataSource = objData.DefaultView;
            uiGridViewServices.DataBind();
        }
        private void LoadDDLs()
        {
            Companies comp = new Companies();
            comp.SearchCompanies("", 0, 1, 1);
            uiDropDownListCompanies.DataSource = comp.DefaultView;
            uiDropDownListCompanies.DataTextField = "ArName";
            uiDropDownListCompanies.DataValueField = "CompanyID";
            uiDropDownListCompanies.DataBind();

            Companies comp1 = new Companies();
            comp1.SearchCompanies("", 0, 1, 1);
            uiDropDownListCompanyUpload.DataSource = comp1.DefaultView;
            uiDropDownListCompanyUpload.DataTextField = "ArName";
            uiDropDownListCompanyUpload.DataValueField = "CompanyID";
            uiDropDownListCompanyUpload.DataBind();

            AirPorts city = new AirPorts();
            city.LoadAll();
            uiDropDownListFromCity.DataSource = city.DefaultView;
            uiDropDownListToCity.DataSource = city.DefaultView;

            uiDropDownListFromCity.DataTextField = "EnName";
            uiDropDownListToCity.DataTextField = "EnName";

            uiDropDownListFromCity.DataValueField = "AirPortID";
            uiDropDownListToCity.DataValueField = "AirPortID";

            uiDropDownListFromCity.DataBind();
            uiDropDownListToCity.DataBind();
        }
        protected void uiButtonUpdate_Click(object sender, EventArgs e)
        {
            string filepath = "";
            if (uiFileUploadLogoPath.HasFile)
            {
                uiFileUploadLogoPath.SaveAs(Server.MapPath("~/FileUploads/Companies" + "/" + uiFileUploadLogoPath.FileName));
                filepath = "/Fileuploads/Companies" + "/" + uiFileUploadLogoPath.FileName;
            }

            if (CurrentCompany != null)
            {
                Companies objData = CurrentCompany;
                string temp = objData.LogoPath;
                objData.EnName = uiTextBoxEnName.Text;
                objData.ArName = uiTextBoxArName.Text;
                objData.EnAddress = uiTextBoxEnAddress.Text;
                objData.ArAddress = uiTextBoxArAddress.Text;
                objData.Tele = uiTextBoxTele.Text;
                objData.Fax = uiTextBoxFax.Text;
                try
                {
                    objData.Rank = Convert.ToInt32(uiTextBoxRank.Text);
                }
                catch (Exception ee)
                {
                    objData.Rank = 0;
                }
                objData.CityID = Convert.ToInt32(uiDropDownListCity.SelectedValue);
                objData.CategoryID = Convert.ToInt32(uiDropDownListCategory.SelectedValue);
                if (!string.IsNullOrEmpty(uiDropDownListSubCategory.SelectedValue))
                {
                    objData.SubCategoryID = Convert.ToInt32(uiDropDownListSubCategory.SelectedValue);
                }
                objData.PackageTypeID = Convert.ToInt32(uiDropDownListPackages.SelectedValue);
                if (!string.IsNullOrEmpty(filepath))
                {
                    objData.LogoPath = filepath;
                }
                objData.Save();

                CompanyEnabledOptions option = new CompanyEnabledOptions();
                option.GetCompanyEnabledOptionsByCompanyID(objData.CompanyID);
                foreach (ListItem item in uiCheckBoxListPackageOptions.Items)
                {
                    bool found = false;
                    for (int i = 0; i < option.RowCount; i++)
                    {
                        if (item.Value == option.PackageOptionID.ToString())
                        {
                            option.Enabled = item.Selected;
                            found = true;
                        }
                        if (found)
                        { break; }
                    }
                    if (!found)
                    {
                        option.AddNew();
                        option.CompanyID = objData.CompanyID;
                        option.PackageOptionID = Convert.ToInt32(item.Value);
                        option.Enabled = item.Selected;

                    }
                    option.MoveNext();
                }
                option.Save();

            }
            else
            {
                MembershipCreateStatus obj;
                MembershipUser objUser = Membership.CreateUser(uiTextBoxUserName.Text, uiTextBoxPassword.Text, "*****@*****.**", null, null, true, out obj);
                bool success = true;
                switch (obj)
                {
                    case MembershipCreateStatus.DuplicateUserName:
                        uiLabelError.Text = "duplicate username";
                        uiLabelError.Visible = true;
                        success = false;
                        break;
                    case MembershipCreateStatus.InvalidPassword:
                        uiLabelError.Text = "invalid password. password must be (6) characters or more.";
                        uiLabelError.Visible = true;
                        success = false;
                        break;
                    case MembershipCreateStatus.ProviderError:
                    case MembershipCreateStatus.UserRejected:
                        uiLabelError.Text = "an error occurred. please try again.";
                        uiLabelError.Visible = true;
                        success = false;
                        break;
                    default:
                        break;
                }
                if (!Roles.IsUserInRole(uiTextBoxUserName.Text, "Company"))
                {
                    Roles.AddUserToRole(uiTextBoxUserName.Text, "Company");
                }

                if (success)
                {
                    Companies objData = new Companies();
                    objData.AddNew();
                    objData.EnName = uiTextBoxEnName.Text;
                    objData.ArName = uiTextBoxArName.Text;
                    objData.EnAddress = uiTextBoxEnAddress.Text;
                    objData.ArAddress = uiTextBoxArAddress.Text;
                    objData.Tele = uiTextBoxTele.Text;
                    objData.Fax = uiTextBoxFax.Text;
                    objData.CityID = Convert.ToInt32(uiDropDownListCity.SelectedValue);
                    objData.CategoryID = Convert.ToInt32(uiDropDownListCategory.SelectedValue);
                    if (!string.IsNullOrEmpty(uiDropDownListSubCategory.SelectedValue))
                    {
                        objData.SubCategoryID = Convert.ToInt32(uiDropDownListSubCategory.SelectedValue);
                    }
                    objData.LogoPath = filepath;
                    objData.UserName = uiTextBoxUserName.Text;
                    objData.PackageTypeID = Convert.ToInt32(uiDropDownListPackages.SelectedValue);
                    try
                    {
                        objData.Rank = Convert.ToInt32(uiTextBoxRank.Text);
                    }
                    catch (Exception ee)
                    {
                        objData.Rank = 0;
                    }
                    objData.Save();
                    CompanyEnabledOptions option = new CompanyEnabledOptions();
                    foreach (ListItem item in uiCheckBoxListPackageOptions.Items)
                    {

                        option.AddNew();
                        option.PackageOptionID = Convert.ToInt32(item.Value);
                        option.CompanyID = objData.CompanyID;
                        option.Enabled = item.Selected;

                    }
                    option.Save();
                }
                else
                {
                    return;
                }

            }

            uiPanelEdit.Visible = false;
            uiPanelViewCompanies.Visible = true;
            BindData();
            Clearfields();

            CurrentCompany = null;
        }
 private void BindData()
 {
     Companies objData = new Companies();
     objData.LoadAll();
     uiGridViewCompanies.DataSource = objData.DefaultView;
     uiGridViewCompanies.DataBind();
 }
        protected void uiButtonUpdate_Click(object sender, EventArgs e)
        {
            Companies currentCompany = new Companies();
            currentCompany.GetCompanyByUserName(Page.User.Identity.Name);
            CompanyEnabledOptions options = new CompanyEnabledOptions();
            options.GetCompanyEnabledOptionsByCompanyID(currentCompany.CompanyID);

            currentCompany.EnName = uiTextBoxEnName.Text ;
            currentCompany.ArName = uiTextBoxArName.Text ;
            currentCompany.EnAddress = uiTextBoxEnAddress.Text;
            currentCompany.ArAddress = uiTextBoxArAddress.Text;
            currentCompany.Tele = uiTextBoxTele.Text ;
            currentCompany.Fax = uiTextBoxFax.Text;

            for (int i = 0; i < options.RowCount; i++)
            {
                switch (options.PackageOptionID)
                {
                    case 1:
                        if (options.Enabled)
                        {
                            if (uiFileUploadLogoPath.HasFile)
                            {
                                uiFileUploadLogoPath.SaveAs(Server.MapPath("~/FileUploads/Companies" + "/" + uiFileUploadLogoPath.FileName));
                                currentCompany.LogoPath = "/FileUploads/Companies" + "/" + uiFileUploadLogoPath.FileName;
                            }
                        }
                        break;
                    case 7:
                        if (options.Enabled)
                            currentCompany.WebSite = uiTextBoxWebSite.Text;
                        break;
                    case 8:
                        if (options.Enabled)
                        {
                            currentCompany.EnBranches = Server.HtmlEncode(uiFCKeditorEnBranches.Value);
                            currentCompany.ArBranches  = Server.HtmlEncode(uiFCKeditorArBranches.Value);
                        }
                        break;
                    case 9:
                        if (options.Enabled)
                            currentCompany.MapPath = Server.HtmlEncode(uiTextBoxMapURL.Text);
                        break;
                    case 10:
                        if (options.Enabled)
                        {
                            currentCompany.EnAbout = Server.HtmlEncode(uiFCKeditorEnAbout.Value);
                            currentCompany.ArAbout = Server.HtmlEncode(uiFCKeditorArAbout.Value);
                        }
                        break;
                    case 15:
                        if (options.Enabled)
                        {
                            currentCompany.EnContact = Server.HtmlEncode(uiFCKeditorEnContacts.Value);
                            currentCompany.ArContact = Server.HtmlEncode(uiFCKeditorArContacts.Value);
                        }
                        break;
                    default:
                        break;
                }

                options.MoveNext();
            }

            currentCompany.Save();
        }
        protected void uiGridViewCompanies_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "EditCompany")
            {
                Companies objData = new Companies();
                objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));
                uiTextBoxEnName.Text = objData.EnName;
                uiTextBoxArName.Text = objData.ArName;
                uiTextBoxEnAddress.Text = objData.EnAddress;
                uiTextBoxArAddress.Text = objData.ArAddress;
                uiTextBoxTele.Text = objData.Tele;
                uiTextBoxFax.Text = objData.Fax;
                uiDropDownListCity.SelectedValue = objData.CityID.ToString();
                uiDropDownListCategory.SelectedValue = objData.CategoryID.ToString();
                if (!objData.IsColumnNull("SubCategoryID"))
                {
                    uiDropDownListSubCategory.SelectedValue = objData.SubCategoryID.ToString();
                }
                uiImageLogo.ImageUrl = objData.LogoPath;
                uiLinkButtonResetPassword.Enabled = true;
                uiTextBoxUserName.Text = objData.UserName;
                uiTextBoxPassword.TextMode = TextBoxMode.SingleLine;
                uiTextBoxPassword.Text = Membership.GetUser(objData.UserName).GetPassword();
                uiTextBoxPassword.Enabled = false;
                uiTextBoxUserName.Enabled = false;

                if (!objData.IsColumnNull("PackageTypeID"))
                {
                    uiDropDownListPackages.SelectedValue = objData.PackageTypeID.ToString();
                }
                //  load packjage
                CompanyEnabledOptions options = new CompanyEnabledOptions();
                options.GetCompanyEnabledOptionsByCompanyID(Convert.ToInt32(e.CommandArgument.ToString()));
                for (int i = 0; i < options.RowCount; i++)
                {
                    foreach (ListItem item in uiCheckBoxListPackageOptions.Items)
                    {
                        if (item.Value == options.PackageOptionID.ToString())
                        {
                            item.Selected = options.Enabled;
                            break;
                        }

                    }
                    options.MoveNext();
                }

                uiPanelViewCompanies.Visible = false;
                uiPanelEdit.Visible = true;
                CurrentCompany = objData;
            }
            else if (e.CommandName == "DeleteCompany")
            {

                Companies objData = new Companies();
                objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));

                if (Membership.GetUser(objData.UserName) != null)
                {
                    Membership.DeleteUser(objData.UserName);
                }

                CompanyEnabledOptions options = new CompanyEnabledOptions();
                options.GetCompanyEnabledOptionsByCompanyID(objData.CompanyID);
                options.DeleteAll();
                options.Save();

                Photos pics = new Photos();
                pics.GetPhotosByCompanyID(objData.CompanyID);
                pics.DeleteAll();
                pics.Save();

                BLL.Vedios videos = new BLL.Vedios();
                videos.GetVedioByCompanyID(objData.CompanyID);
                videos.DeleteAll();
                videos.Save();

                objData.MarkAsDeleted();
                objData.Save();

                BindData();
                uiPanelViewCompanies.Visible = true;
                uiPanelEdit.Visible = false;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Companies currentCompany = new Companies();
                currentCompany.GetCompanyByUserName(Page.User.Identity.Name);
                CompanyEnabledOptions options = new CompanyEnabledOptions();
                options.GetCompanyEnabledOptionsByCompanyID(currentCompany.CompanyID);
                ResetAllFields();
                for (int i = 0; i < options.RowCount; i++)
                {
                    switch (options.PackageOptionID)
                    {
                        case 1:
                            if (options.Enabled)
                            {
                                CompanyLogo.Attributes.Add("style", "display:block");
                                uiImageLogo.ImageUrl = currentCompany.LogoPath;
                            }
                            else
                            {
                                CompanyLogo.Attributes.Add("style", "display:none");
                            }
                            break;
                        case 7:

                            if (options.Enabled)
                            {
                                CompanyWebsite.Attributes.Add("style", "display:block");
                                uiTextBoxWebSite.Text = currentCompany.WebSite;
                            }
                            else
                            {
                                CompanyWebsite.Attributes.Add("style", "display:none");
                            }
                            break;
                        case 8:
                            if (options.Enabled)
                            {
                                CompanyBranches.Attributes.Add("style", "display:block");
                                uiFCKeditorEnBranches.Value = Server.HtmlDecode(currentCompany.EnBranches);
                                uiFCKeditorArBranches.Value = Server.HtmlDecode(currentCompany.ArBranches);
                            }
                            else
                            {
                                CompanyBranches.Attributes.Add("style", "display:none");
                            }
                            break;
                        case 9:
                            if (options.Enabled)
                            {
                                CompanyMap.Attributes.Add("style", "display:block");
                                uiTextBoxMapURL.Text = Server.HtmlDecode(currentCompany.MapPath);
                            }
                            else
                            {
                                CompanyMap.Attributes.Add("style", "display:none");
                            }
                            break;
                        case 10:
                            if (options.Enabled)
                            {
                                CompanyAbout.Attributes.Add("style", "display:block");
                                uiFCKeditorEnAbout.Value = Server.HtmlDecode(currentCompany.EnAbout);
                                uiFCKeditorArAbout.Value = Server.HtmlDecode(currentCompany.ArAbout);
                            }
                            else
                            {
                                CompanyAbout.Attributes.Add("style", "display:none");
                            }
                            break;
                        case 15:
                            if (options.Enabled)
                            {
                                CompanyContacts.Attributes.Add("style", "display:block") ;
                                uiFCKeditorEnContacts.Value = Server.HtmlDecode(currentCompany.EnContact);
                                uiFCKeditorArContacts.Value = Server.HtmlDecode(currentCompany.ArContact);
                            }
                            else
                            {
                                CompanyContacts.Attributes.Add("style", "display:none");
                            }
                            break;
                        default:
                            break;
                    }

                    options.MoveNext();
                }

                uiTextBoxEnName.Text = currentCompany.EnName;
                uiTextBoxArName.Text = currentCompany.ArName;
                uiTextBoxEnAddress.Text = currentCompany.EnAddress;
                uiTextBoxArAddress.Text = currentCompany.ArAddress;
                uiTextBoxTele.Text = currentCompany.Tele;
                uiTextBoxFax.Text = currentCompany.Fax;
                uiTextBoxUserName.Text = currentCompany.UserName;

            }
        }
        private void LoadDDLs()
        {
            ServiceTypes types = new ServiceTypes();
            types.LoadAll();
            Companies objCompany = new Companies();
            objCompany.GetCompanyByUserName(User.Identity.Name);

            CompanyEnabledOptions options = new CompanyEnabledOptions();
            options.GetCompanyEnabledOptionsByCompanyID(objCompany.CompanyID);
            string filter =" ServiceTypeID in ( ";
            for (int i = 0; i < options.RowCount; i++)
            {
                if ((options.PackageOptionID == 11 || options.PackageOptionID == 12 || options.PackageOptionID == 13 || options.PackageOptionID == 14))
                {
                    if (options.Enabled && options.PackageOptionID == 11)
                        filter += " 1 , ";
                    else if (options.Enabled && options.PackageOptionID == 12)
                        filter += " 6 , ";
                    else if (options.Enabled && options.PackageOptionID == 13)
                        filter += " 3 , ";
                    else if (options.Enabled && options.PackageOptionID == 14)
                        filter += " 7 , ";
                }
                options.MoveNext();
            }

            filter = filter.Substring(0, filter.LastIndexOf(",") - 1);
            filter += ")";
            types.Filter = filter;
            uiDropDownListAllServiceType.DataSource = types.DefaultView;
            uiDropDownListAllServiceType.DataTextField = "ArName";
            uiDropDownListAllServiceType.DataValueField = "ServiceTypeID";
            uiDropDownListAllServiceType.DataBind();
            uiDropDownListAllServiceType.SelectedIndex = 0;
        }
        private void BindData()
        {
            int catid = 0;
            if (Request.QueryString["cid"] != null)
            {
                try
                {
                    catid = Convert.ToInt32(Request.QueryString["cid"].ToString());
                }
                catch (Exception ex)
                {
                    catid = 0;
                }
            }

            int subcatid = 0;
            if (Request.QueryString["scid"] != null)
            {
                try
                {
                    subcatid = Convert.ToInt32(Request.QueryString["scid"].ToString());
                }
                catch (Exception ex)
                {
                    subcatid = 0;
                }
            }

            string searchfor = "";
            if (Request.QueryString["f"] != null)
            {
                try
                {
                    searchfor = Request.QueryString["f"].ToString();
                }
                catch (Exception ex)
                {
                    searchfor = "";
                }
            }

            PagedDataSource dt = new PagedDataSource();
            Companies objData = new Companies();
            if (!string.IsNullOrEmpty(searchfor) && searchfor == "sh")
                objData.SearchCompaniesForShipping(subcatid);
            else if (!string.IsNullOrEmpty(searchfor) && searchfor == "off")
            {
                objData.SearchCompaniesForOffers(catid, subcatid);
            }
            else
            {
                objData.SearchCompanies("", 0, catid, subcatid);
            }

            Categories cat = new Categories();
            cat.LoadByPrimaryKey(catid);
            SubCategories subcat = new SubCategories();
            subcat.LoadByPrimaryKey(subcatid);
            dt.DataSource = objData.DefaultView;
            dt.AllowPaging = true;
            dt.PageSize = 10;
            dt.CurrentPageIndex = PageIndex;
            if (objData.RowCount > 0 && dt != null)
            {
                if(cat.RowCount > 0 )
                    uiLabelTitle.Text = " - " + cat.EnName;
                if (subcat.RowCount > 0)
                    uiLabelTitle.Text += " -> " + subcat.EnName;

                uiRepeaterResults.DataSource = dt;
                uiRepeaterResults.DataBind();
                uiLinkButtonPrev.Enabled = !dt.IsFirstPage;
                uiLinkButtonNext.Enabled = !dt.IsLastPage;
                uiLabelPages.Text = "Page " + (PageIndex + 1).ToString() + " of " + dt.PageCount.ToString() + " Pages";
                uiPanelNoResults.Visible = false;
                uiPanelResults.Visible = true;
            }
            else
            {
                uiPanelNoResults.Visible = true;
                uiPanelResults.Visible = false;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int compId = 0;
                if (Request.QueryString["cid"] != null)
                {
                    if (!string.IsNullOrEmpty(Request.QueryString["cid"].ToString()))
                    {
                        try
                        {
                            compId = Convert.ToInt32(Request.QueryString["cid"].ToString());
                        }
                        catch (Exception ex)
                        {
                            compId = 0;
                        }
                    }
                }

                if (compId == 0)
                {
                    Response.Redirect("~/Default.aspx");
                }
                else
                {
                    Companies current = new Companies();
                    current.LoadByPrimaryKey(compId);

                    uiLabelCompanyName.Text = current.EnName;
                    Categories cat = new Categories();
                    cat.LoadByPrimaryKey(current.CategoryID);
                    SubCategories subcat = new SubCategories();
                    subcat.LoadByPrimaryKey(current.SubCategoryID);

                    string path = "";
                    if(cat.RowCount > 0 )
                        path += cat.EnName;
                    if (subcat.RowCount > 0)
                        path += " -> " + subcat.EnName;

                    Master.Page.Title += "Global Logistics" + " -> " + path + " -> " + current.EnName;
                    uiLabelPath.Text = path + " ->";

                    CompanyEnabledOptions options = new CompanyEnabledOptions();
                    options.GetCompanyEnabledOptionsByCompanyID(compId);

                    for (int i = 0; i < options.RowCount; i++)
                    {
                        switch (options.PackageOptionID)
                        {

                            case 7:
                                if (options.Enabled)
                                {
                                    LIWebsite.Attributes.Add("style", "display:block");
                                    uiHyperLinkWebsite.Text = current.WebSite;
                                    uiHyperLinkWebsite.NavigateUrl = current.WebSite;
                                    CompanyTabs_12.Attributes.Add("style", "display:block");
                                }
                                else
                                {
                                    LIWebsite.Attributes.Add("style", "display:none");
                                    CompanyTabs_12.Attributes.Add("style", "display:none");
                                }
                                break;
                            case 8:
                                if (options.Enabled)
                                {
                                    LIBranch.Attributes.Add("style", "display:block");
                                    CompanyTabs_2.Attributes.Add("style", "display:block");
                                    uiLiteralBranches.Text = Server.HtmlDecode(current.EnBranches);
                                }
                                else
                                {
                                    CompanyTabs_2.Attributes.Add("style", "display:none");
                                    LIBranch.Attributes.Add("style", "display:none");
                                }
                                break;
                            case 9:
                                if (options.Enabled)
                                {
                                    LIMap.Attributes.Add("style", "display:block");
                                    CompanyTabs_3.Attributes.Add("style", "display:block");
                                    uiLiteralMap.Text = Server.HtmlDecode(current.MapPath);
                                }
                                else
                                {
                                    LIMap.Attributes.Add("style", "display:none");
                                    CompanyTabs_3.Attributes.Add("style", "display:none");
                                }
                                break;
                            case 10:
                                if (options.Enabled)
                                {
                                    CompanyTabs_1.Attributes.Add("style", "display:block");
                                    LIAbout.Attributes.Add("style", "display:block");
                                    uiLiteralAbout.Text = Server.HtmlDecode(current.EnAbout);
                                }
                                else
                                {
                                    LIAbout.Attributes.Add("style", "display:none");
                                    CompanyTabs_1.Attributes.Add("style", "display:none");
                                }
                                break;
                            case 11:
                                if (options.Enabled)
                                {
                                    CompanyTabs_5.Attributes.Add("style", "display:block");
                                    LIOffers.Attributes.Add("style", "display:block");
                                    Services offers = new Services();
                                    offers.GetServicesByCompanyIDAndTypeID(current.CompanyID, 1);
                                    if (offers.RowCount > 0)
                                    {
                                        uiRepeaterOffers.DataSource = offers.DefaultView;
                                        uiRepeaterOffers.DataBind();
                                    }
                                    else
                                    {
                                        uiLiteralOffers.Text = "No Offers found.";
                                    }

                                }
                                else
                                {
                                    LIOffers.Attributes.Add("style", "display:none");
                                    CompanyTabs_5.Attributes.Add("style", "display:none");
                                }
                                break;
                            case 12:
                                if (options.Enabled)
                                {
                                    CompanyTabs_6.Attributes.Add("style", "display:block");
                                    LIRequests.Attributes.Add("style", "display:block");
                                    Services requests = new Services();
                                    requests.GetServicesByCompanyIDAndTypeID(current.CompanyID, 6);
                                    if (requests.RowCount > 0)
                                    {
                                        uiRepeaterRequests.DataSource = requests.DefaultView;
                                        uiRepeaterRequests.DataBind();
                                    }
                                    else
                                    {
                                        uiLiteralRequests.Text = "No requests found.";
                                    }
                                }
                                else
                                {
                                    LIRequests.Attributes.Add("style", "display:none");
                                    CompanyTabs_6.Attributes.Add("style", "display:none");
                                }
                                break;
                            case 13:
                                if (options.Enabled)
                                {
                                    CompanyTabs_7.Attributes.Add("style", "display:block");
                                    LIJobs.Attributes.Add("style", "display:block");
                                    Services jobs = new Services();
                                    jobs.GetServicesByCompanyIDAndTypeID(current.CompanyID, 3);
                                    if (jobs.RowCount > 0)
                                    {
                                        uiRepeaterJobs.DataSource = jobs.DefaultView;
                                        uiRepeaterJobs.DataBind();
                                    }
                                    else
                                    {
                                        uiLiteralJobs.Text = "No jobs found.";
                                    }
                                }
                                else
                                {
                                    LIJobs.Attributes.Add("style", "display:none");
                                    CompanyTabs_7.Attributes.Add("style", "display:none");
                                }
                                break;
                            case 14:
                                if (options.Enabled)
                                {
                                    CompanyTabs_4.Attributes.Add("style", "display:block");
                                    LIServices.Attributes.Add("style", "display:block");
                                    Services services = new Services();
                                    services.GetServicesByCompanyIDAndTypeID(current.CompanyID, 7);
                                    if (services.RowCount > 0)
                                    {
                                        uiRepeaterService.DataSource = services.DefaultView;
                                        uiRepeaterService.DataBind();
                                    }
                                    else
                                    {
                                        uiLiteralServices.Text = "No services found.";
                                    }
                                }
                                else
                                {
                                    LIServices.Attributes.Add("style", "display:none");
                                    CompanyTabs_4.Attributes.Add("style", "display:none");
                                }
                                break;
                            case 15:
                                if (options.Enabled)
                                {
                                    LIContacts.Attributes.Add("style", "display:block");
                                    CompanyTabs_11.Attributes.Add("style", "display:block");
                                    uiLiteralContacts.Text = Server.HtmlDecode(current.EnContact);
                                }
                                else
                                {
                                    LIContacts.Attributes.Add("style", "display:none");
                                    CompanyTabs_11.Attributes.Add("style", "display:none");
                                }
                                break;
                            case 17:
                                if (options.Enabled)
                                {
                                    LIPic.Attributes.Add("style", "display:block");
                                    CompanyTabs_8.Attributes.Add("style", "display:block");
                                    Photos pics = new Photos();
                                    pics.GetPhotosByCompanyID(current.CompanyID);
                                    uiDataListPhotos.DataSource = pics.DefaultView;
                                    uiDataListPhotos.DataBind();
                                }
                                else
                                {
                                    LIPic.Attributes.Add("style", "display:none");
                                    CompanyTabs_8.Attributes.Add("style", "display:none");
                                }
                                break;
                            case 16:
                                if (options.Enabled)
                                {
                                    LIVideos.Attributes.Add("style", "display:block");
                                    CompanyTabs_9.Attributes.Add("style", "display:block");
                                    BLL.Vedios Videos = new BLL.Vedios();
                                    Videos.GetVedioByCompanyID(current.CompanyID);
                                    uiDataListVideos.DataSource = Videos.DefaultView;
                                    uiDataListVideos.DataBind();
                                }
                                else
                                {
                                    LIVideos.Attributes.Add("style", "display:none");
                                    CompanyTabs_9.Attributes.Add("style", "display:none");
                                }
                                break;
                            case 19:
                                if (options.Enabled)
                                {
                                    LISchedule.Attributes.Add("style", "display:block");
                                    CompanyTabs_10.Attributes.Add("style", "display:block");
                                    if (!string.IsNullOrEmpty(current.SchedulePath))
                                        uiLiteralSchedule.Text = "<a href='" + current.SchedulePath + "' >Click here to download schedule</a>";
                                    else
                                        uiLiteralSchedule.Text = "No schedule found.";
                                }
                                else
                                {
                                    LISchedule.Attributes.Add("style", "display:none");
                                    CompanyTabs_10.Attributes.Add("style", "display:none");
                                }
                                break;
                            default:
                                break;
                        }

                        options.MoveNext();
                    }
                }
            }
        }
        private void BindData()
        {
            PagedDataSource dt = new PagedDataSource();
            Companies objData = new Companies();

            int cityid = 0;
            int catid = 0;
            int scatid = 0;
            int fromport = 0;
            int toport = 0;
            bool IsAir = false;
            bool IsShipping = false;
            string filter = "";
            if (Request.QueryString["q"] != null)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["q"].ToString()))
                {
                    filter = Request.QueryString["q"].ToString();
                }
            }

            if (Request.QueryString["cat"] != null)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["cat"].ToString()))
                {
                    try
                    {
                        catid = Convert.ToInt32(Request.QueryString["cat"].ToString());
                    }
                    catch (Exception ex)
                    {
                        catid = 0;
                    }
                }
            }

            if (Request.QueryString["scat"] != null)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["scat"].ToString()))
                {
                    try
                    {
                        scatid = Convert.ToInt32(Request.QueryString["scat"].ToString());
                    }
                    catch (Exception ex)
                    {
                        scatid = 0;
                    }
                }
            }

            if (Request.QueryString["cid"] != null)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["cid"].ToString()))
                {
                    try
                    {
                        cityid = Convert.ToInt32(Request.QueryString["cid"].ToString());
                    }
                    catch (Exception ex)
                    {
                        cityid = 0;
                    }
                }
            }

            if (Request.QueryString["fcid"] != null)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["fcid"].ToString()))
                {
                    try
                    {
                        fromport = Convert.ToInt32(Request.QueryString["fcid"].ToString());
                    }
                    catch (Exception ex)
                    {
                        fromport = 0;
                    }
                }
            }

            if (Request.QueryString["tcid"] != null)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["tcid"].ToString()))
                {
                    try
                    {
                        toport = Convert.ToInt32(Request.QueryString["tcid"].ToString());
                    }
                    catch (Exception ex)
                    {
                        toport = 0;
                    }
                }
            }

            if (Request.QueryString["al"] != null)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["al"].ToString()))
                {
                    try
                    {
                        IsAir = Convert.ToBoolean(Request.QueryString["al"].ToString());
                    }
                    catch (Exception ex)
                    {
                        IsAir = false;
                    }
                }
            }

            if (Request.QueryString["sl"] != null)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["sl"].ToString()))
                {
                    try
                    {
                        IsShipping = Convert.ToBoolean(Request.QueryString["sl"].ToString());
                    }
                    catch (Exception ex)
                    {
                        IsShipping = false;
                    }
                }
            }

            if (!IsAir && !IsShipping)
            {
                objData.SearchCompanies(filter, cityid, catid, scatid);
            }
            else if (IsAir)
            {
                objData.SearchCompaniesForAirLines(fromport, toport);
            }
            else if (IsShipping)
            {
                objData.SearchCompaniesForSeaLines(fromport, toport);
            }

            dt.DataSource = objData.DefaultView;
            dt.AllowPaging = true;
            dt.PageSize = 10;
            dt.CurrentPageIndex = PageIndex;

            if (objData.RowCount > 0 && dt != null)
            {
                uiPanelResults.Visible = true;
                uiPanelNoResults.Visible = false;
                uiRepeaterResults.DataSource = dt;
                uiRepeaterResults.DataBind();

                uiLinkButtonPrev.Enabled = !dt.IsFirstPage;
                uiLinkButtonNext.Enabled = !dt.IsLastPage;
                uiLabelPages.Text = "Page " + (PageIndex + 1).ToString() + " of " + dt.PageCount.ToString() + " Pages";
            }
            else
            {
                uiPanelResults.Visible = false;
                uiPanelNoResults.Visible = true;
            }
        }
        protected void uiButtonUpdate_Click(object sender, EventArgs e)
        {
            if (uiFileUpload.HasFile)
            {
                ArrayList notUploaded = new ArrayList();
                uiFileUpload.SaveAs(Server.MapPath("~/FileUploads/" + uiFileUpload.FileName));
                string connectionString = string.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 12.0;HDR=NO;""", Server.MapPath("~/FileUploads/" + uiFileUpload.FileName));

                string strSQL = "SELECT * FROM [ورقة1$]";
                OleDbConnection excelConnection = new OleDbConnection(connectionString);
                excelConnection.Open();
                OleDbCommand dbCommand = new OleDbCommand(strSQL, excelConnection);
                OleDbDataAdapter dataAdapter = new OleDbDataAdapter(dbCommand);

                DataTable dTable = new DataTable();

                dataAdapter.Fill(dTable);
                Companies objData = new Companies();
                foreach (DataRow item in dTable.Rows)
                {

                    MembershipCreateStatus obj;
                    string Username = item[1].ToString().Replace(" ", "");
                    Username = Username.Replace("&", "");
                    string Password = "";
                    if (Username.Length > 10)
                    {
                        Password = Username.Substring(0,10);
                    }
                    else
                    {
                        Password = Username;
                    }

                    if (Password.Length < 6)
                    {
                        Password = Password + Password;
                    }
                    MembershipUser objUser = Membership.CreateUser(Username, Password, "*****@*****.**", null, null, true, out obj);
                    bool success = true;
                    switch (obj)
                    {
                        case MembershipCreateStatus.DuplicateUserName:
                            success = false;
                            break;
                        case MembershipCreateStatus.InvalidPassword:
                            success = false;
                            break;
                        case MembershipCreateStatus.ProviderError:
                        case MembershipCreateStatus.UserRejected:
                            success = false;
                            break;
                        default:
                            break;
                    }
                    try
                    {

                        if (!Roles.IsUserInRole(Username, "Company"))
                        {
                            Roles.AddUserToRole(Username, "Company");
                        }
                    }
                    catch (Exception ex)
                    {
                        uiLabelError.Text += "001";
                        uiLabelError.Visible = true;
                    }

                    if (success)
                    {
                        try
                        {

                            objData.AddNew();
                            objData.EnName = item[1].ToString();
                            objData.ArName = item[0].ToString();
                            objData.EnAddress = item[3].ToString();
                            objData.ArAddress = item[2].ToString();
                            objData.Rank = 0;
                            try
                            {
                                objData.Tele = item[4].ToString();
                            }
                            catch (Exception ex)
                            {
                            }
                            try
                            {
                                objData.Fax = item[5].ToString();
                            }
                            catch (Exception ex)
                            {
                            }

                            objData.CityID = Convert.ToInt32(uiDropDownListCity.SelectedValue);
                            objData.CategoryID = Convert.ToInt32(uiDropDownListCategory.SelectedValue);
                            if(!string.IsNullOrEmpty(uiDropDownListSubCategory.SelectedValue))
                                objData.SubCategoryID = Convert.ToInt32(uiDropDownListSubCategory.SelectedValue);
                            objData.UserName = Username;

                        }
                        catch (Exception ex)
                        {
                            uiLabelError.Visible = true;
                            Membership.DeleteUser(Username);
                            notUploaded.Add(item[1].ToString() + " - " + ex.Message);
                            objData.MarkAsDeleted();
                        }
                    }
                    else
                    {
                        notUploaded.Add(item[1].ToString() + " - " + obj.ToString());
                        continue;
                    }
                }
                objData.Save();

                if (notUploaded.Count < dTable.Rows.Count)
                    uiLabelmsg.Visible = true;

                uiGridViewLog.DataSource = notUploaded;
                uiGridViewLog.Columns[0].HeaderText = "These items faild to insert";
                uiGridViewLog.DataBind();
            }
        }
        private void LoadCompanies(int catid, int subcatid)
        {
            PagedDataSource dt = new PagedDataSource();
            Companies objData = new Companies();
            objData.SearchCompanies("", 0, catid, subcatid);
            Categories cat = new Categories();
            cat.LoadByPrimaryKey(catid);
            SubCategories subcat = new SubCategories();
            subcat.LoadByPrimaryKey(subcatid);

            dt.DataSource = objData.DefaultView;
            dt.AllowPaging = true;
            dt.PageSize = 10;
            dt.CurrentPageIndex = PageIndex;
            if (objData.RowCount > 0 && dt != null)
            {
                if (cat.RowCount > 0)
                    uiLabelTitle.Text = " - " + cat.ArName;
                if (subcat.RowCount > 0)
                    uiLabelTitle.Text += " -> " + subcat.ArName;

                uiRepeaterResults.DataSource = dt;
                uiRepeaterResults.DataBind();
                uiLinkButtonPrev.Enabled = !dt.IsFirstPage;
                uiLinkButtonNext.Enabled = !dt.IsLastPage;
                uiLabelPages.Text = "صفحة " + (PageIndex + 1).ToString() + " من " + dt.PageCount.ToString() + " صفحات";
                uiPanelNoResults.Visible = false;
                uiPanelResults.Visible = true;
                uiPanelCategories.Visible = false;
            }
            else
            {
                uiPanelNoResults.Visible = true;
                uiPanelResults.Visible = false;
                uiPanelCategories.Visible = false;
            }
        }
 private void BindData()
 {
     BLL.Vedios objData = new BLL.Vedios();
     Companies objCompany = new Companies();
     objCompany.GetCompanyByUserName(User.Identity.Name);
     objData.GetVedioByCompanyID(objCompany.CompanyID);
     uiGridViewVideos.DataSource = objData.DefaultView;
     uiGridViewVideos.DataBind();
 }