Ejemplo n.º 1
0
        private void moveDown()
        {
            if (DGV.RowCount > 0)
            {
                if (DGV.SelectedRows.Count > 0)
                {
                    int rowCount = DGV.Rows.Count;
                    int index    = DGV.SelectedCells[0].OwningRow.Index;

                    if (index == (rowCount - 2)) // include the header row
                    {
                        return;
                    }
                    DataGridViewRowCollection rows = DGV.Rows;

                    // remove the next row and add it in front of the selected row.
                    DataGridViewRow row         = rows[index];
                    DataGridViewRow prevRow     = rows[index + 1];
                    String          rowDate     = row.Cells[5].Value.ToString();
                    String          prevRowDate = prevRow.Cells[5].Value.ToString();
                    row.Cells[5].Value     = prevRowDate;
                    prevRow.Cells[5].Value = rowDate;
                    DataGridViewRow nextRow = rows[index + 1];
                    rows.Remove(nextRow);
                    nextRow.Frozen = false;
                    rows.Insert(index, nextRow);
                    DGV.ClearSelection();
                    DGV.Rows[index + 1].Selected = true;
                }
                else if (DGV.SelectedCells.Count == 1 && DGV.CurrentCell.RowIndex != DGV.Rows.Count - 2)
                {
                    DGV.CurrentCell = DGV.Rows[DGV.CurrentCell.RowIndex + 1].Cells[DGV.CurrentCell.ColumnIndex];
                }
            }
        }
Ejemplo n.º 2
0
 private void DGV_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Escape)
     {
         DGV.ClearSelection();
     }
 }
Ejemplo n.º 3
0
        private void moveUp()
        {
            if (DGV.RowCount > 0)
            {
                if (DGV.SelectedRows.Count > 0)
                {
                    int rowCount = DGV.Rows.Count;
                    int index    = DGV.SelectedCells[0].OwningRow.Index;

                    if (index == 0)
                    {
                        return;
                    }
                    DataGridViewRowCollection rows = DGV.Rows;

                    // remove the previous row and add it behind the selected row.
                    DataGridViewRow row         = rows[index];
                    DataGridViewRow prevRow     = rows[index - 1];
                    String          rowDate     = row.Cells[5].Value.ToString();
                    String          prevRowDate = prevRow.Cells[5].Value.ToString();
                    row.Cells[5].Value     = prevRowDate;
                    prevRow.Cells[5].Value = rowDate;
                    rows.Remove(prevRow);
                    prevRow.Frozen = false;
                    rows.Insert(index, prevRow);
                    DGV.ClearSelection();
                    DGV.Rows[index - 1].Selected = true;
                }
                else if (DGV.SelectedCells.Count == 1 && DGV.CurrentCell.RowIndex != 0)
                {
                    DGV.CurrentCell = DGV.Rows[DGV.CurrentCell.RowIndex - 1].Cells[DGV.CurrentCell.ColumnIndex];
                }
            }
        }
Ejemplo n.º 4
0
        private void LoadData()
        {
            BindingSource bindingsource = new BindingSource();

            bindingsource.DataSource = servicio.GetAll();

            DGV.DataSource = bindingsource;
            DGV.ClearSelection();
        }
Ejemplo n.º 5
0
 private void DGV_MouseDown(object sender, MouseEventArgs e)
 {
     try
     {
         if (e.Button == MouseButtons.Right)
         {
             var hti = DGV.HitTest(e.X, e.Y);
             DGV.ClearSelection();
             DGV.CurrentCell = DGV.Rows[hti.RowIndex].Cells[hti.ColumnIndex];
         }
     }
     catch { }
 }
Ejemplo n.º 6
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            // TODO: add the checks for the input fields used

            Program.myController.AddTransaction((int)comboBox1.SelectedValue, DiscounttextBox.Value, ValueTextBox.Value, ReceivedValueTextBox.Value, checkBox1.Checked);
            Form6_Load(sender, e);

            // show the add transaction details
            TransactionDetails detailsForm = new TransactionDetails(true, (int)DGV.Rows[DGV.RowCount - 1].Cells[0].Value);

            detailsForm.ShowDialog(this);

            DGV.ClearSelection();
        }
Ejemplo n.º 7
0
        private void DGV_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.Escape:
                DGV.ClearSelection();
                break;

            case Keys.Enter:
                OnEditClick(EventArgs.Empty);
                e.Handled = true;
                break;

            case Keys.Delete:
                if (DGV.SelectedRows.Count == 1)
                {
                    if (!allowDeleteRow)
                    {
                        e.Handled = true;
                    }
                }
                break;
            }
        }
Ejemplo n.º 8
0
        private void DGV_MouseClick(object sender, MouseEventArgs e)
        {
            var ht = DGV.HitTest(e.X, e.Y);

            if (0 <= ht.RowIndex)
            {
                var allowed = (_DGV_MouseDown_HitTestInfo.RowIndex == ht.RowIndex) &&
                              ((_DGV_MouseDown_HitTestInfo.Type == DataGridViewHitTestType.Cell) ||
                               (_DGV_MouseDown_HitTestInfo.Type == DataGridViewHitTestType.RowHeader));
                if (allowed)
                {
                    DGV.Rows[ht.RowIndex].Selected = true;

                    if (e.Button == MouseButtons.Right)
                    {
                        MouseClickRightButton?.Invoke(e, GetSelectedDownloadRow());
                    }
                }
            }
            else if ((ht.Type == DataGridViewHitTestType.None) || (ht.Type == DataGridViewHitTestType.Cell))
            {
                switch (e.Button)
                {
                case MouseButtons.Left:
                    if (_DGV_MouseDown_HitTestInfo.Type == DataGridViewHitTestType.None)
                    {
                        DGV.ClearSelection();
                    }
                    break;

                case MouseButtons.Right:
                    MouseClickRightButton?.Invoke(e, null);
                    break;
                }
            }
        }
Ejemplo n.º 9
0
 private void BtnClear_Click(object sender, EventArgs e)
 {
     SelectedProcess = null;
     tlpProFields.AC_ClearFields();
     DGV.ClearSelection();
 }
Ejemplo n.º 10
0
 void RefreshDGV(List <OSASProcess> processes, bool showColumns = false)
 {
     ProDGV.DataSource = processes.Where(a => a.Id > -1).AC_AsDataTable();
     VisualiseProDGV(showColumns);
     DGV.ClearSelection();
 }
Ejemplo n.º 11
0
        private void program_manage_Load(object sender, EventArgs e)
        {
            GF.showLoading(this);
            using (DataTable DT = DB.getS("SELECT * FROM SPA_PROGRAM_TYPE WHERE IS_USE = 1", null, "GET ALL SPA PROGRAM TYPE", false))
            {
                foreach (DataRow row in DT.Rows)
                {
                    program_type_id.Items.Add(new ComboItem(Int32.Parse(row["SPA_PROGRAM_TYPE_ID"].ToString()), row["SPA_PROGRAM_TYPE_NAME"].ToString()));
                }
            }
            GF.resizeComboBox(program_type_id);

            if (manage_btn.Text.Trim() == "UPDATE")
            {
                string queryString = @"
                SELECT TOP 1 * 
                FROM SPA_PROGRAM A
                INNER JOIN SPA_PROGRAM_TYPE B ON A.SPA_PROGRAM_TYPE_ID = B.SPA_PROGRAM_TYPE_ID
                WHERE SPA_PROGRAM_ID = " + GF.selected_id.ToString();
                using (DataTable DT = DB.getS(queryString, null, "GET SPA_PROGRAM[" + GF.selected_id.ToString() + "]", false))
                {
                    foreach (DataRow row in DT.Rows)
                    {
                        code.Text              = row["CODE"].ToString();
                        program_type_id.Text   = row["SPA_PROGRAM_TYPE_NAME"].ToString();
                        program_name.Text      = row["PROGRAM_NAME"].ToString();
                        rus_name.Text          = row["RUS_NAME"].ToString();
                        price.Text             = row["PRICE"].ToString();
                        masseur_use.Text       = row["MASSEUR_USE"].ToString();
                        description.Text       = row["DESCRIPTION"].ToString();
                        hours.Text             = row["HOURS"].ToString();
                        minutes.Text           = row["MINUTES"].ToString();
                        apply_discount.Checked = (row["APPLY_DISCOUNT"].ToString() == "1" ? true : false);
                        select_oil.Checked     = (row["SELECT_OIL"].ToString() == "1" ? true : false);
                        select_scrub.Checked   = (row["SELECT_SCRUB"].ToString() == "1" ? true : false);

                        initDGV();
                        queryString = @"
                    SELECT D.ITEM_TYPE_NAME, C.ITEM_NAME, A.*, E.UNIT_NAME
                    FROM SPA_PROGRAM_ITEM A
                    INNER JOIN SPA_ITEM B ON A.SPA_ITEM_ID = B.SPA_ITEM_ID
                    INNER JOIN ITEM C ON B.ITEM_ID = C.ITEM_ID
                    INNER JOIN ITEM_TYPE D ON C.ITEM_TYPE_ID = D.ITEM_TYPE_ID
                    INNER JOIN UNIT E ON A.UNIT_ID = E.UNIT_ID
                    WHERE SPA_PROGRAM_ID = " + GF.selected_id.ToString();
                        using (DataTable tmpDT = DB.getS(queryString, null, "GET SPA_PROGRAM_ITEM FROM SPA_PROGRAM[" + GF.selected_id.ToString() + "]", false))
                        {
                            foreach (DataRow myRow in tmpDT.Rows)
                            {
                                DGV.Rows.Add(
                                    myRow["ITEM_TYPE_NAME"].ToString(),
                                    myRow["ITEM_NAME"].ToString(),
                                    myRow["AMOUNT"].ToString(),
                                    myRow["UNIT_NAME"].ToString(),
                                    ((myRow["customer_choose"].ToString() == "1") ? "YES" : "NO"),

                                    myRow["customer_choose"].ToString(),
                                    myRow["UNIT_ID"].ToString(),
                                    myRow["SPA_ITEM_ID"].ToString(),
                                    myRow["SPA_PROGRAM_ITEM_ID"].ToString()
                                    );
                                DGV[1, DGV.Rows.Count - 1].Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
                            }
                        }
                        GF.updateRowNum(DGV);
                        DGV.ClearSelection();
                        DGV.Visible = true;
                    }
                }
            }
            GF.closeLoading();
        }
Ejemplo n.º 12
0
 private void Form4_Click(object sender, EventArgs e)
 {
     DGV.ClearSelection();
 }
Ejemplo n.º 13
0
 private void SelectNoneToolStripMenuItem_Click(object sender, EventArgs e)
 {
     DGV.ClearSelection();
 }