Example #1
0
        /// <summary>
        /// Remove filter
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        /// Things get a tad complicated here in regards to keeping the current row
        /// as we need to make sure the row still exists
        /// </remarks>
        private void cmdRemoveFilter_Click(object sender, EventArgs e)
        {
            Customer tempCustomer = null;

            if (bsCustomers.CurrentRowIsValid())
            {
                tempCustomer = bsCustomers.Customer();
            }

            Customers customers = new Customers();

            blCustomers = new SortableBindingList <Customer>(customers.DataSource);

            bsCustomers.DataSource   = blCustomers;
            dataGridView1.DataSource = bsCustomers;

            if (tempCustomer.IsValid())
            {
                currentCustomer = blCustomers.Where(cust => cust.CustomerIdentifier == tempCustomer.CustomerIdentifier).FirstOrDefault();
                if (currentCustomer.IsValid())
                {
                    bsCustomers.Position = blCustomers.IndexOf(currentCustomer);
                }
            }
        }
Example #2
0
        private void osveziSudiju(SortableBindingList <Partija> a)
        {
            ISession s = DataLayer.GetSession();

            foreach (Partija p in a)
            {
                string sts = SudOP.ucitajSudiju(s, p.Sudija);
                dgv1.Rows[a.IndexOf(p)].Cells["sd"].Value = sts;
            }
            s.Close();
        }
Example #3
0
    public void SubmitButton_Handler(object sender, EventArgs e)
    {
        Person p = _personList.AddNew();

        if ((p.FirstName == string.Empty) || (p.LastName == string.Empty))
        {
            MessageBox.Show("First Name and Last Name cannot be blank!");
            _personList.CancelNew(_personList.IndexOf(p));
        }
        else
        {
            ClearEntryControls();
        }
    }
Example #4
0
        private void UpdateProcessGrid(object arg)
        {
            try
            {
                var currentProcesses = _computer.GetAllProcesses();
                Invoke((Action)(() =>
                {
                    var selectedProcess = (ProcessModel)processModelBindingSource.Current;
                    var scrollPosition = dataGridView1.FirstDisplayedScrollingRowIndex;
                    var currentSort = new
                    {
                        processModelBindingSource.SortDirection,
                        processModelBindingSource.SortProperty
                    };
                    _currentProcessModels.Clear();
                    foreach (var processModel in currentProcesses)
                    {
                        if (!string.IsNullOrWhiteSpace(processModel.Path) && _computer.RestrictedProcesses.Contains(processModel.Path.ToLower()))
                        {
                            _computer.KillProcess(processModel.Id);
                        }

                        _currentProcessModels.Add(processModel);
                    }

                    if (currentSort.SortProperty != null)
                    {
                        processModelBindingSource.ApplySort(currentSort.SortProperty, currentSort.SortDirection);
                    }

                    processModelBindingSource.Position = _currentProcessModels.IndexOf(selectedProcess);
                    if (scrollPosition > 0 && scrollPosition < _currentProcessModels.Count)
                    {
                        dataGridView1.FirstDisplayedScrollingRowIndex = scrollPosition;
                    }

                    isUpdated = true;
                }));
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Произошла ошибка - " + _computer.Name);
                isUpdated = true;
            }
        }
Example #5
0
        private void btnPrikazPartije_Click(object sender, EventArgs e)
        {
            if (!Provera.chkIfSelected(dgv1))
            {
                return;
            }
            lblNaslov.Text           = "Partije";
            btnPromovisi.Visible     = false;
            btnOtpusti.Visible       = false;
            btnPrikazPartije.Visible = false;
            btnVezaOrgSpon.Visible   = false;
            btnDodajPartiju.Visible  = false;
            showPotez.Visible        = true;

            try
            {
                if (dgv1.CurrentRow.DataBoundItem is Sahista)
                {
                    ISession s   = DataLayer.GetSession();
                    Sahista  sah = dgv1.CurrentRow.DataBoundItem as Sahista;

                    IList <Partija> lsp = (from o in s.Query <Partija>()
                                           where (o.BeliIgrac == sah || o.CrniIgrac == sah)
                                           select o).ToList <Partija>();

                    SortableBindingList <Partija> a = new SortableBindingList <Partija>(lsp);

                    dgv1.Columns.Clear();
                    dgv1.DataSource = a;

                    dgv1.Columns["Potezi"].Visible = false;
                    dgv1.Columns["Sudija"].Visible = false;
                    dgv1.Columns.Add("sd", "Sudija");
                    string sts;
                    foreach (Partija p in a)
                    {
                        sts = SudOP.ucitajSudiju(s, p.Sudija);
                        dgv1.Rows[a.IndexOf(p)].Cells["sd"].Value = sts;
                    }

                    //dgv1.Update();
                    //dgv1.Refresh();

                    s.Close();
                }
                else if (dgv1.CurrentRow.DataBoundItem is Turnir)
                {
                    ISession s = DataLayer.GetSession();

                    Turnir trn = dgv1.CurrentRow.DataBoundItem as Turnir;
                    s.Update(trn);

                    SortableBindingList <Partija> a = new SortableBindingList <Partija>(trn.TPartije);

                    dgv1.Columns.Clear();
                    dgv1.DataSource = a;

                    dgv1.Columns["Potezi"].Visible = false;
                    dgv1.Columns["Sudija"].Visible = false;
                    dgv1.Columns["Turnir"].Visible = false;

                    dgv1.Columns.Add("sd", "Sudija");
                    string sts;
                    foreach (Partija p in a)
                    {
                        sts = SudOP.ucitajSudiju(s, p.Sudija);
                        dgv1.Rows[a.IndexOf(p)].Cells["sd"].Value = sts;
                    }

                    //dgv1.Update();
                    //dgv1.Refresh();

                    s.Close();
                }
            }
            catch (Exception ec)
            {
                MessageBox.Show(ec.Message);
            }
        }