示例#1
0
        protected void AddFavoritesClicked(object sender, ImageClickEventArgs e)
        {
            //Thread.Sleep(40000);
            var currentUserGuid = new Guid(Session["CurrentUser"].ToString());

            string[] commandArguents  = ((ImageButton)sender).CommandArgument.Split(';');
            bool     isFavorite       = bool.Parse(commandArguents[1]);
            var      favoriteUserGuid = new Guid(commandArguents[0]);

            SqlConnection connection  = DBHelper.GetConnection();
            string        commandText = isFavorite ? "RemoveFavorites" : "AddFavorites";
            var           cmd         = new SqlCommand(commandText, connection)
            {
                CommandType = CommandType.StoredProcedure
            };

            cmd.Parameters.Add("@ParentUserGuid", SqlDbType.UniqueIdentifier);
            cmd.Parameters["@ParentUserGuid"].Value = currentUserGuid;
            cmd.Parameters.Add("@FavoriteUserGuid", SqlDbType.UniqueIdentifier);
            cmd.Parameters["@FavoriteUserGuid"].Value = favoriteUserGuid;
            try
            {
                connection.Open();
                cmd.ExecuteNonQuery();
                EmployeesListView.DataBind();
            }
            catch (Exception ex)
            {
                ShellLogger.WriteLog("DB.log", "Ошибка добаления сотрудника в избранное", ex);
            }
            finally
            {
                connection.Close();
            }
        }
示例#2
0
 /// <summary>
 ///     Простой поиск
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void SimpleSearchClicked(object sender, EventArgs e)
 {
     //обычный поиск
     Session["SelectedPage"]        = 1;
     Session["SimpleSearch"]        = SearchTextBox.Text;
     Session["CustomSearch"]        = null;
     EmployeesListView.DataSourceID = "FilteredEmployeesDataSource";
     EmployeesListView.DataBind();
 }
示例#3
0
        private void LoadData(string userId)
        {
            DateTime now = DateTime.Now;

            _context = new fbLudoDBEntities3();
            IEnumerable <Ausleihe>       listAusleihen;
            IEnumerable <Ausleihe_Spiel> list = Enumerable.Empty <Ausleihe_Spiel>();

            listAusleihen = _context.Ausleihe.Where(x => x.PersonenID == userId).ToList();

            foreach (Ausleihe ausleiheid in listAusleihen)
            {
                var id = ausleiheid.Ausleihe_ID;

                if (list == null)
                {
                    list = _context.Ausleihe_Spiel.Where(x => x.Ausleihe_ID == id && x.DatumBis > now).ToList();
                }
                else
                {
                    list = list.Concat(_context.Ausleihe_Spiel.Where(x => x.Ausleihe_ID == id && x.DatumBis > now).ToList());
                }
            }

            EmployeesListView.DataSource = list;
            EmployeesListView.DataBind();


            IEnumerable <Ausleihe>       listAusleihenInactive;
            IEnumerable <Ausleihe_Spiel> listInactive = Enumerable.Empty <Ausleihe_Spiel>();

            listAusleihenInactive = _context.Ausleihe.Where(x => x.PersonenID == userId).ToList();

            foreach (Ausleihe ausleiheid in listAusleihenInactive)
            {
                var id = ausleiheid.Ausleihe_ID;

                if (listInactive == null)
                {
                    listInactive = _context.Ausleihe_Spiel.Where(x => x.Ausleihe_ID == id && x.DatumBis <= now).ToList();
                }
                else
                {
                    listInactive = listInactive.Concat(_context.Ausleihe_Spiel.Where(x => x.Ausleihe_ID == id && x.DatumBis <= now).ToList());
                }
            }
            ListView2.DataSource = listInactive;
            ListView2.DataBind();



            /*IEnumerable<Ausleihe> list2 = _context.Ausleihe.Where(x => x.PersonenID == userId && x.DatumBis <= now).ToList();
             * ListView2.DataSource = list2;
             * ListView2.DataBind();*/
        }
示例#4
0
        //private void InitUserDepartment()
        //{
        //    if (Session["CurrentUserDepartment"] != null && Session["CurrentUser"]!=null)
        //        Session["CurrentUserDepartment"] =
        //            DBHelper.GetUserDepartment(new Guid(Session["CurrentUser"].ToString()));
        //}

        protected void DepartmentTree_SelectedNodeChanged(object sender, EventArgs e)
        {
            //Запоминаем выбранный элемент в дереве только для DepartmentState
            if (((DepartmentTreeNodeType)((CustomTreeNode)DepartmentTree.SelectedNode).Tag) ==
                DepartmentTreeNodeType.DepartmentState)
            {
                Session["CurrentSelectedDepartment"] = DepartmentTree.SelectedValue;
                Session["Tree"] = DepartmentTree.Nodes[0];
                Session["CurrentSelectedDepartmentNode"] = DepartmentTree.SelectedNode;
            }

            SearchTextBox.Text      = string.Empty;
            Session["SimpleSearch"] = null;
            Session["CustomSearch"] = null;
            Session["SelectedPage"] = 1;

            EmployeesListView.DataSourceID = "EmployeesDataSource";
            EmployeesListView.DataBind();
        }
示例#5
0
 //This Method populates the cureent Crews and their assigned job sites
 protected void PopulateEmployeeAndSiteType()
 {
     MessageUserControl.TryRun(() =>
     {
         EmployeeControllers employeeManager = new EmployeeControllers();
         if (UnitsDDL.SelectedIndex == 0)
         {
             //Validate that a Unit was selected
             EmployeesListView.DataSource = null;
             EmployeesListView.DataBind();
             EmployeesListView.Visible = false;
             MessageUserControl.ShowInfo("You must select a Unit to proceed");
             RouteCategory.Visible = false;
         }
         else
         {
             EmployeesListView.Visible = true;
             RouteCategory.Visible     = true;
             SelectSiteButton.Visible  = true;
             Route.Text = "Crew Member";
         }
     });
 }
示例#6
0
        /// <summary>
        ///     Расширенный поиск
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void AdditionalSearchClicked(object sender, EventArgs e)
        {
            //расширенный поиск
            Session["SelectedPage"] = 1;
            var customSearch = new CustomSearchStorage
            {
                Department = DepartmentTextBox.Text,
                Position   = PositionTextBox.Text,
                HasPhone   = HasPhoneCheckBox.Checked,
            };

            var birthDayStart = Page.Request.Form["birthDayStartTextBox"];
            var birthDayEnd   = Page.Request.Form["birthDayFinishTextBox"];

            var startDate = ParseDate(birthDayStart);
            var endDate   = ParseDate(birthDayEnd);

            RestoreBirthdayDates(startDate, endDate);

            if (startDate.HasValue)
            {
                customSearch.StartBirthday = startDate.Value;
            }

            if (endDate.HasValue)
            {
                customSearch.FinishBirthday = endDate.Value;
            }

            Session["SimpleSearch"] = null;
            Session["CustomSearch"] = customSearch;

            UpdateCustomSearchParametrs();
            EmployeesListView.DataSourceID = "CustomFilteredEmployeesDataSource";
            EmployeesListView.DataBind();
        }
示例#7
0
        // The id parameter name should match the DataKeyNames value set on the control

        /*   public void PremisesListView_DeleteItem(string Id)
         * {
         *     premises.Remove(premises.Single(b => b.premise_id == Id));
         * }
         *
         * public void EmployeesListView_DeleteItem(string Id)
         * {
         *     employees.Remove(employees.Single(b => b.employee_id == Id));
         * }
         *
         * public void ReviewsListView_DeleteItem(string Id)
         * {
         *     reviews.Remove(reviews.Single(b => b.review_id == Id));
         * }
         *
         * public void OffersListView_DeleteItem(string Id)
         * {
         *     offers.Remove(offers.Single(b => b.offer_id == Id));
         * }
         */



        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            // До срещане на грешка се предполага, че всичко е наред.
            DbStatusLabel.Text      = "Успешно записване в БД.";
            DbStatusLabel.ForeColor = Color.Green;

            XmlStatusLabel.Text      = "Успешно записване в XML файл.";
            XmlStatusLabel.ForeColor = Color.Green;

            HotelsModels.Hotel hotel = null;

            try
            {
                hotel = ControlsToModel();
                context.Hotels.Add(hotel);
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                DbStatusLabel.Text      = "Грешка при записване в БД: " + ex.Message;
                DbStatusLabel.ForeColor = Color.Red;
                hotel = null;
            }

            try
            {
                if (hotel == null)
                {
                    throw new Exception("Не се записва XML файл при грешка в записването в БД");
                }
                XDocument hotelXml = ModelToXml(hotel);
                hotelXml.Save(Server.MapPath("~/App_Data/" + hotel.name + hotel.id + ".xml"));
            }
            catch (Exception ex)
            {
                XmlStatusLabel.Text      = "Грешка при записване в XML файл: " + ex.Message;
                XmlStatusLabel.ForeColor = Color.Red;

                hotel = null;
            }

            if (hotel != null)
            {
                // При успешно записване се изчистват всички данни в контролите
                foreach (Control control in Master.FindControl("ContentPlaceHolder1").Controls)
                {
                    if (control is TextBox)
                    {
                        (control as TextBox).Text = "";
                    }
                }

                // Изчистване на запазените списъци в ViewState и обновяване на ListView
                premises = new List <HotelsModels.Premise>();
                ViewState["premises"] = premises;
                PremisesListView.DataBind();


                offers = new List <HotelsModels.Offer>();
                ViewState["offers"] = offers;
                OffersListView.DataBind();

                employees = new List <HotelsModels.Employee>();
                ViewState["employees"] = employees;
                EmployeesListView.DataBind();

                reviews = new List <HotelsModels.Review>();
                ViewState["reviews"] = reviews;
                ReviewsListView.DataBind();
            }
        }
示例#8
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //InitUserDepartment();

                SetVisibilityReportButtons();
                if (Session["Tree"] != null)
                {
                    if (Session["CurrentSelectedDepartmentNode"] != null)
                    {
                        DepartmentTree.FillTree((CustomTreeNode)Session["Tree"],
                                                (CustomTreeNode)Session["CurrentSelectedDepartmentNode"]);
                    }
                    else
                    {
                        DepartmentTree.FillTree((CustomTreeNode)Session["Tree"], null);
                    }
                }
                else
                {
                    if (Session["CurrentUserDivision"] != null)
                    {
                        DepartmentTree.FillTreeByDivision(new Guid(Session["CurrentUserDivision"].ToString()));
                        Session["CurrentSelectedDepartment"]     = new Guid(Session["CurrentUserDivision"].ToString());
                        Session["CurrentSelectedDepartmentNode"] = DepartmentTree.CurrentSelectedNode;
                    }
                    else
                    {
                        DepartmentTree.FillTree(Guid.Empty);
                    }
                }

                if (Session["Tree"] == null)
                {
                    Session["Tree"] = DepartmentTree.Nodes[0];
                }


                if (Session["SimpleSearch"] != null && !string.IsNullOrEmpty(Session["SimpleSearch"].ToString()))
                {
                    SearchTextBox.Text             = Session["SimpleSearch"].ToString();
                    EmployeesListView.DataSourceID = "FilteredEmployeesDataSource";
                    EmployeesListView.DataBind();
                }
                else if (Session["CustomSearch"] != null && !string.IsNullOrEmpty(Session["CustomSearch"].ToString()))
                {
                    var customSearchParams = (CustomSearchStorage)Session["CustomSearch"];
                    PositionTextBox.Text     = customSearchParams.Position;
                    DepartmentTextBox.Text   = customSearchParams.Department;
                    HasPhoneCheckBox.Checked = customSearchParams.HasPhone;
                    RestoreBirthdayDates(customSearchParams.StartBirthday, customSearchParams.FinishBirthday);
                    //BirthDayStartTextBox.Text = customSearchParams.StartBirthday.ToShortDateString();
                    //BirthDayFinishTextBox.Text = customSearchParams.FinishBirthday.ToShortDateString();

                    UpdateCustomSearchParametrs();
                    EmployeesListView.DataSourceID = "CustomFilteredEmployeesDataSource";
                    EmployeesListView.DataBind();
                }

                if (Session["SelectedPage"] != null)
                {
                    var pager = ((DataPager)EmployeesListView.FindControl("DataPager"));
                    if (pager != null)
                    {
                        pager.SetPageProperties(int.Parse(Session["SelectedPage"].ToString()), pager.MaximumRows, true);
                    }
                }
            }
        }
示例#9
0
 private void DeselectAll_Click(object sender, RoutedEventArgs e)
 {
     EmployeesListView.UnselectAll();
 }