Example #1
0
 private void toolStripButtonDelete_Click(object sender, EventArgs e)
 {
     try
     {
         DataGridViewSelectedRowCollection col = dgvList.SelectedRows;
         if (col.Count < 1)
         {
             MessageBox.Show("请选择要删除的项");
             return;
         }
         if (MessageBox.Show("确定要删除选中的项吗?数据删除后将不能恢复,点【确定】删除数据,【取消】不删除", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
         {
             return;
         }
         int       index = col[0].Index;
         DataTable dt    = dgvList.DataSource as DataTable;
         if (dt == null || dt.Rows.Count < 1)
         {
             return;
         }
         DataRow row = dt.Rows[index];
         string  Id  = row["Id"].ToString();
         if (Id == CommStatic.AdministratorRoleId)
         {
             MessageBox.Show("系统预置角色不能删除");
             return;
         }
         string  sql = "select * from Admin where Rights='" + Id + "'";
         DataSet ds  = DBHelper.ExecuteDataSet(sql);
         if (ds != null && ds.Tables[0].Rows.Count > 0)
         {
             MessageBox.Show("有员工还担任此角色,请将担任这一角色的员工都更改为其他角色或者删除掉这个员工,才可以删除此角色");
             return;
         }
         sql = "delete from AdminRole where Id='" + Id + "'";
         if (DBHelper.ExecuteNonQuery(sql) > 0)
         {
             MessageBox.Show("删除成功!");
             InItList();
             toolStripButtonAdd_Click(sender, e);
         }
     }
     catch (Exception ex)
     {
         TracingHelper.Error(ex, typeof(UCRoleSetting));
     }
 }
Example #2
0
        private void delButton_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection rows = mainDGV.SelectedRows;
            int n = rows.Count;

            if (n == 1)
            {
                if (MessageBox.Show(String.Format("Вы уверены, что хотите удалить запись о размере\n{0}?",
                                                  mainDGV[0, mainDGV.CurrentRow.Index].Value.ToString()), "Внимание", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.OK)
                {
                    string query = String.Format(@"
                                        DELETE FROM `size`
                                        WHERE id_size={0};", DB.GetRowCol(mainDGV.Rows[mainDGV.SelectedCells[0].RowIndex], "id_size"));
                    DB.SetNoResultQuery(query);
                }
                refreshData();
            }
            else
            {
                Func <string> GetWordForm = () =>
                {
                    if (n % 100 >= 11 && n % 100 <= 19)
                    {
                        return("записей");
                    }
                    if (n % 10 == 1)
                    {
                        return("запись");
                    }
                    if (n % 10 >= 2 && n % 10 <= 4)
                    {
                        return("записи");
                    }
                    return("записей");
                };
                if (MessageBox.Show(String.Format("Вы уверены, что хотите удалить {0} {1} о размерах?",
                                                  n, GetWordForm()), "Внимание", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.OK)
                {
                    var ids = from DataGridViewRow x in rows
                              select DB.GetRowCol(x, "id_costume_type");

                    string query = string.Format("DELETE FROM `size` WHERE `id_size` IN ({0})", string.Join(", ", ids));
                    DB.SetNoResultQuery(query);
                    refreshData();
                }
            }
        }
        private void btNext_Click(object sender, EventArgs e)
        {
            try
            {
                DataGridViewSelectedRowCollection rows = dataGridView1.SelectedRows;
                if (rows.Count > 0)
                {
                    int stt = 0;
                    int.TryParse(rows[0].Cells[0].Value.ToString(), out stt);
                    //MessageBox.Show(rows[0].Cells[1].Value.ToString());

                    var tk = BLLHuuNghi.Instance.CallAny(connectString, loginObj.UserId, equipCode, stt, today, (int)eDailyRequireType.KhamBenh);
                    if (tk.IsSuccess)
                    {
                        sttDangGoi           = tk.Data_3.TicketNumber;
                        lbCurrentTicket.Text = sttDangGoi.ToString();
                        SendDisplay(tk.Data_3.TicketNumber.ToString());

                        var requireJSON = JsonConvert.SerializeObject(new RequireMainDisplay()
                        {
                            EquipCode = equipCode, TicketNumber = tk.Data_3.TicketNumber
                        });
                        BLLCounterSoftRequire.Instance.Insert(connectString, requireJSON, (int)eCounterSoftRequireType.SendNextToMainDisplay, counterId);
                        var readTemplateIds = BLLUserCmdReadSound.Instance.GetReadTemplateIds(connectString, loginObj.UserId, eCodeHex.Next);
                        if (readTemplateIds.Count > 0)
                        {
                            GetSound(readTemplateIds, tk.Data_3.TicketNumber.ToString(), counterId);
                        }

                        var infoArr = (tk.Data_3.Note as string).Split(',').ToArray();
                        if (infoArr != null && infoArr.Length == 4)
                        {
                            maBN          = infoArr[1];
                            maPK          = infoArr[0];
                            lbBNinfo.Text = maBN + " - " + infoArr[2] + " - " + infoArr[3];
                        }
                        ShowResult();
                    }
                }
                else
                {
                    MessageBox.Show("Xin vui lòng chọn bệnh nhân cần gọi.", "Lỗi thao tác", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception)
            { }
        }
Example #4
0
        void ExportSaveButtonClick(object sender, EventArgs e)
        {
            #region Debug
            log.Debug("───────────────────────────────────────────────────────────────────────────────\n" +
                      "Export Save Button Click\n");
            #endregion

            DataGridView dgv  = GetDataGridView(focusedMemoryCard);
            MemoryCard   card = GetActualCard(dgv.Name);

            if (card != null)
            {
                DataGridViewSelectedRowCollection savesCollection = dgv.SelectedRows;
                string filePath = String.Empty;

                #region Debug
                log.Debug("Exporting files\n");
                log.Debug(String.Format("{0,-20} {1,5} {2,-25} {3}", "Name", "Size", "Date", "Description\n"));
                #endregion

                foreach (DataGridViewRow row in savesCollection)
                {
                    Utils.Card.ExportSave(card.GetPath(), row.Cells[0].Value.ToString(), userExportFolder, mode);

                    #region Debug
                    log.Debug(String.Format("{0,-20} {1,5} {2,-25} {3}", row.Cells[0].Value.ToString(), row.Cells[1].Value.ToString(),
                                            row.Cells[2].Value.ToString(), row.Cells[3].Value.ToString()));
                    #endregion
                }
                #region Debug
                log.Debug("Export Finished.\n");
                #endregion

                MessageBox.Show("Finish export files.");
            }
            #region Debug
            else
            {
                log.Debug("No memory card opened.");
            }
            #endregion

            #region Debug
            log.Debug("Export Save Button Click - Exit\n" +
                      "───────────────────────────────────────────────────────────────────────────────");
            #endregion
        }
Example #5
0
        private void btnalterar_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection linha = dgvpesquisa.SelectedRows;



            if (linha.Count != 1)
            {
                MessageBox.Show("Selecione 1 funcionário para editar", "Funcionário não selecionado", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            Pessoa pes = new Pessoa();

            pes.Id_Funcionario = Convert.ToInt32(linha[0].Cells[0].Value);
            pes.Nome           = linha[0].Cells[1].Value.ToString();
            pes.Cpf            = linha[0].Cells[2].Value.ToString();
            pes.Dt_nascimento  = Convert.ToDateTime(linha[0].Cells[3].Value.ToString());
            pes.Endereco       = linha[0].Cells[4].Value.ToString();
            pes.Id_Profissao   = Convert.ToInt32(linha[0].Cells[8].Value);
            pes.Email          = linha[0].Cells[5].Value.ToString();
            pes.Bairro         = linha[0].Cells[11].Value.ToString();
            pes.Cep            = linha[0].Cells[12].Value.ToString();
            pes.Id_Turno       = Convert.ToInt32(linha[0].Cells[16].Value);
            pes.Exame          = Convert.ToByte(linha[0].Cells[15].Value);



            if (linha[0].Cells[14].Value.ToString() != "")
            {
                pes.Id_Cidade = Convert.ToInt32(linha[0].Cells[13].Value);
            }

            if (linha[0].Cells[13].Value.ToString() != "")
            {
                pes.Id_Estado = Convert.ToInt32(linha[0].Cells[14].Value);
            }


            Cadastro Cadastro = new Cadastro();


            Cadastro.pessoa_carrega = pes;
            Cadastro.ShowDialog();
            txtpesquisa_TextChanged(sender, e);
        }
Example #6
0
        /// <summary>
        /// Refreshes planning page ListView1. View includes product creation requirements (product name, amount, unit, batch).
        /// </summary>
        private void RefreshPlanningPageTopRightListView()
        {
            DataGridViewSelectedRowCollection selectedRows = this.dataGridViewPlanning1.SelectedRows;
            DataGridViewRow selectedRow = null;

            if (selectedRows.Count != 1 || textBoxNeededAmount.Text == "")
            {
                return;
            }
            selectedRow = selectedRows[0];

            using (sqlConnection = new SqlConnection(connectionString))
            {
                sqlConnection.Open();
                listViewPlanning1.Items.Clear();

                SqlCommand command = new SqlCommand(
                    "SELECT resepti.resepti, resepti.item, resepti.maara, tuote.yksikko, tuote.nimi, saldo.eraId " +
                    "FROM resepti " +
                    "INNER JOIN tuote " +
                    "ON resepti.item=tuote.id " +
                    "INNER JOIN saldo " +
                    "ON tuote.id=saldo.tuoteId " +
                    "WHERE resepti.resepti=" + (int)selectedRow.Cells[0].Value +
                    ";", sqlConnection);

                Debug.WriteLine((int)selectedRow.Cells[0].Value);
                SqlDataReader reader = command.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ListViewItem listItem = new ListViewItem(reader.GetString(4));
                        listItem.SubItems.Add(((float)(double)reader[2] * int.Parse(textBoxNeededAmount.Text)).ToString());
                        listItem.SubItems.Add(reader.GetString(3));
                        listItem.SubItems.Add(reader.GetInt32(5).ToString());

                        listViewPlanning1.Items.Add(listItem);
                    }
                }
                else
                {
                    Console.WriteLine("No rows found.");
                }
                reader.Close();
            }
        }
        /// <summary>
        /// Преобразовывает данную коллекцию выделенных строк в список.
        /// В случае равенства коллекции Null, будет также возвращен результат Null.
        /// </summary>
        /// <param name="collection"></param>
        /// <returns></returns>
        public static List <DataGridViewRow> ToList(this DataGridViewSelectedRowCollection collection)
        {
            // Проверяем входные параметры.
            if (collection == null)
            {
                return(null);
            }
            // Проеобразовываем коллекцию.
            List <DataGridViewRow> result = new List <DataGridViewRow>();

            foreach (DataGridViewRow row in collection)
            {
                result.Add(row);
            }

            return(result);
        }
Example #8
0
        private void btn_del_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection rows = this.dgview_data.SelectedRows;

            if (rows == null || rows.Count == 0)
            {
                MessageBox.Show("提示", "请选择一行");
                return;
            }

            int    id  = Convert.ToInt32(rows[0].Cells[0].Value.ToString());
            string url = rows[0].Cells[1].Value.ToString();

            dao.DeleteTask(id, url);

            this.btn_search_Click(null, null);
        }
        private void btnUpD_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection r = dataGridView2.SelectedRows;
            Model1 db = new Model1();

            if (r.Count == 1)
            {
                foreach (Drink i in db.Drink)
                {
                    if (String.Compare(i.name.ToString(), r[0].Cells[0].Value.ToString(), false) == 0)
                    {
                        UpdateDoUong f4 = new UpdateDoUong(i.id_Drink);
                        f4.ShowDialog();
                    }
                }
            }
        }
Example #10
0
        private void Fill_Items()
        {
            Item item = new Item();
            DataGridViewSelectedRowCollection r = DGV_Show.SelectedRows;

            if (r.Count == 1)
            {
                string ID = r[0].Cells[0].Value.ToString();
                item               = BLL.QL_Items_BLL.Instance.getItems_byID_BLL(ID);
                txt_IDItems.Text   = item.ID_Items;
                txt_NameItems.Text = item.Items_Name;
                txt_Price.Text     = item.Price.ToString();
                txt_State.Text     = item.Status;
                txt_Ctg.Text       = item.Category.Category_Name;
                txt_Values.Text    = item.Reserve.ToString();
            }
        }
Example #11
0
        public void DataGridViewSelectedRowCollection_CopyTo_InvokeNotEmpty_ReturnsExpected()
        {
            using var control = new DataGridView
                  {
                      ColumnCount = 1,
                      RowCount    = 3
                  };
            control.Rows[0].Selected = true;
            control.Rows[1].Selected = false;
            control.Rows[2].Selected = true;

            DataGridViewSelectedRowCollection collection = control.SelectedRows;
            var array = new object[] { 1, 2, 3 };

            collection.CopyTo(array, 1);
            Assert.Equal(new object[] { 1, control.Rows[2], control.Rows[0] }, array);
        }
Example #12
0
        public void razduzi(DataGridView dgPrikaz, ComboBox combo)
        {
            DataGridViewSelectedRowCollection red = dgPrikaz.SelectedRows;


            Zaduzenje z = new Zaduzenje();

            z.ZaduzenjeID     = Convert.ToInt32(red[0].Cells[0].Value);
            z.DatumZaduzenja  = Convert.ToDateTime(red[0].Cells[1].Value);
            z.DatumRazduzenja = Convert.ToDateTime(red[0].Cells[2].Value);
            z.UkIznos         = Convert.ToInt32(red[0].Cells[3].Value);
            z.ClanID          = (combo.SelectedItem as Clan).ClanID;
            z.Zaduzen         = false;
            kal.razduzi(z);

            popuniGridPrikaz(dgPrikaz, combo);
        }
Example #13
0
        /// <summary>
        /// Handles the SelectionChanged event of the dgvPersons control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void dgvPersons_SelectionChanged(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection dgvsrc = this.dgvPersons.SelectedRows;

            if (dgvsrc != null && dgvsrc.Count > 0)
            {
                if (dgvsrc[0].Index >= 0 &&
                    dgvsrc[0].Index >= this._current_amount)
                {
                    this.editCmsItem.Text = "Neu...";
                }
                else
                {
                    this.editCmsItem.Text = "Bearbeiten...";
                }
            }
        }
Example #14
0
        private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                DataGridViewSelectedRowCollection row = dataGridView1.SelectedRows;
                if (row.Count > 0)
                {
                    if (dataGridView1.CurrentCell.RowIndex >= 0 && dataGridView1.CurrentCell.RowIndex < dataGridView1.Rows.Count)
                    {
                        string id = row[0].Cells["id"].Value.ToString();

                        ViewRecipeWindow viewRecipeWindow = new ViewRecipeWindow(Int32.Parse(id));
                        viewRecipeWindow.ShowDialog();
                    }
                }
            }
        }
Example #15
0
        /// <summary>
        /// 删除行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void WndDeleteRows_Click(object sender, EventArgs e)
        {
            DataGridView grid = GetSelect();
            DataGridViewSelectedRowCollection rs = grid.SelectedRows;

            if (rs.Count > 0)
            {
                foreach (DataGridViewRow item in rs)
                {
                    grid.Rows.Remove(item);
                }
            }
            else if (grid.CurrentCell != null)
            {
                grid.Rows.RemoveAt(grid.CurrentCell.RowIndex);
            }
        }
Example #16
0
        private List <PresetSetting> GetSelectedPresets()
        {
            DataGridViewSelectedRowCollection rows = this.presetSettingsGridBox.SelectedRows;

            int[] ids = new int[rows.Count];
            for (int i = 0; i < rows.Count; i++)
            {
                ids[i] = int.Parse(rows[i].Cells[0].Value.ToString());
            }
            List <PresetSetting> presetSettings = new List <PresetSetting>();

            foreach (var id in ids)
            {
                presetSettings.Add(_presetSettingRepository.GetById(id));
            }
            return(presetSettings);
        }
Example #17
0
        private List <Preset> GetSelectedPresets()
        {
            DataGridViewSelectedRowCollection rows = MainMenuDataGrid.SelectedRows;

            int[] idsToBeDeleted = new int[rows.Count];
            for (int i = 0; i < rows.Count; i++)
            {
                idsToBeDeleted[i] = int.Parse(rows[i].Cells[0].Value.ToString());
            }
            List <Preset> presets = new List <Preset>();

            foreach (var id in idsToBeDeleted)
            {
                presets.Add(_presetRepository.GetById(id));
            }
            return(presets);
        }
Example #18
0
        private void Deletebutton_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection r = dataGridView1.SelectedRows;

            if (r.Count > 0)
            {
                List <string> dt = new List <string>();
                foreach (DataGridViewRow i in r)
                {
                    dt.Add(i.Cells["MSSV"].Value.ToString());
                    CSDL_OOP.Instance.DeleteSV(dt);
                }
                dataGridView1.DataSource = CSDL_OOP.Instance.GetListSV(((CBBItems)cbbLopSH.SelectedItem).Value, null);

                txtSearch.Text = "";
            }
        }
Example #19
0
        private void button1_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection rowCollection = dgvPedidos.SelectedRows;

            if (rowCollection.Count == 0)
            {
                MessageBox.Show(this, "ERROR, debe seleccionar una fila de la tabla para poder editar", "Mensaje de ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            DataGridViewRow gridRow = rowCollection[0];
            DataRow         drow    = ((DataRowView)gridRow.DataBoundItem).Row;

            ReporteClienteDetallePedido rdp = new ReporteClienteDetallePedido();

            rdp.Ide = Convert.ToInt32(drow["Id_Cliente"].ToString());
            rdp.ShowDialog();
        }
Example #20
0
 private void btnDelToday_Click(object sender, EventArgs e)
 {
     if (dgvToday.SelectedRows.Count > 0 && MessageHandle.MessageAsk("注意:该日程还没执行!\n 确定要删除该日程事务?", "确定删除") == DialogResult.OK)
     {
         DataGridViewSelectedRowCollection selectedRows = dgvToday.SelectedRows;
         if (BusAdminDaily.DeleteDailyById(selectedRows[0].Cells[0].Value.ToString()))
         {
             if (_dailyEntity != null && _dailyEntity.ID == selectedRows[0].Cells[0].Value.ToString())
             {
                 _dailyEntity = null;
                 ClearForm();
             }
             dgvToday.Rows.Remove(selectedRows[0]);
             MessageHandle.MessageInfo("恭喜,删除成功!", "提示信息");
         }
     }
 }
Example #21
0
        private void sourceGrid_MouseDown(object sender, MouseEventArgs e)
        {
            //捕获鼠标点击区域的信息
            DataGridView.HitTestInfo hitTestInfo = this.sourceGrid.HitTest(e.X, e.Y);

            if (e.X < 30 && hitTestInfo.RowIndex > -1)
            {
                if (this.sourceGrid.SelectedRows.Count > 0)
                {
                    sourceRowCollection = this.sourceGrid.SelectedRows;
                }
            }
            else
            {
                sourceRowCollection = null;
            }
        }
Example #22
0
        private void button9_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection rowCollection = dgvVenta.SelectedRows;

            if (rowCollection.Count == 0)
            {
                MessageBox.Show(this, "ERROR, debe seleccionar una fila de la tabla para Generar el  Reporte", "Mensaje de ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            DataGridViewRow gridRow = rowCollection[0];
            DataRow         drow    = ((DataRowView)gridRow.DataBoundItem).Row;

            ReporteDetalleVentaCliente ventaCliente = new ReporteDetalleVentaCliente();

            ventaCliente.ID1 = int.Parse(drow["Id_Venta"].ToString());
            ventaCliente.ShowDialog();
        }
Example #23
0
        public void DataGridViewSelectedRowCollection_IListItem_GetNotEmpty_ReturnsExpected()
        {
            using var control = new DataGridView
                  {
                      ColumnCount = 1,
                      RowCount    = 3
                  };
            control.Rows[0].Selected = true;
            control.Rows[1].Selected = false;
            control.Rows[2].Selected = true;

            DataGridViewSelectedRowCollection collection = control.SelectedRows;
            IList iList = collection;

            Assert.Equal(control.Rows[2], iList[0]);
            Assert.Equal(control.Rows[0], iList[1]);
        }
        /// <summary>
        /// 移除预警
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_CancelNotify_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection selectRows = this.gridAlarmCondition.SelectedRows;

            if (selectRows == null || selectRows.Count == 0)
            {
                USeFuturesSpiritUtility.ShowWarningMessageBox(this, "请选择要移除的预警");
                return;
            }
            ;

            foreach (DataGridViewRow row in selectRows)
            {
                ArbitrageAlarmArgumentViewModel model = row.DataBoundItem as ArbitrageAlarmArgumentViewModel;
                m_dataSourceAlarm.Remove(model);
            }
        }
Example #25
0
        // delete product
        private void btnDELETE_Click(object sender, EventArgs e)
        {
            List <string> listIdProduct            = new List <string>();
            DataGridViewSelectedRowCollection data = dgvLISTPRODUCT.SelectedRows;

            foreach (DataGridViewRow dgvRow in data)
            {
                listIdProduct.Add(dgvRow.Cells["MaHangHoa"].Value.ToString());
            }
            DialogResult answer = MessageBox.Show("Bạn chắc chắn xóa hàng hóa này", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (answer == DialogResult.Yes)
            {
                BLL_PRODUCT.Instance.FuncDeleteProduct(listIdProduct); // delete product
                LoadData();                                            // load form sau khi delete
            }
        }
        private void button4_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("삭제하시겠습니까?", "경고", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (dr == DialogResult.Yes)
            {
                //현재 선택된 행들을 가져옴
                DataGridViewSelectedRowCollection rows = dataGridView1.SelectedRows;
                //DB연결 엶
                for (int i = 0; i < rows.Count; i++)//여러행이 있기때문에 돌면서 삭제
                {
                    string key = rows[i].Cells["코드번호"].Value.ToString();
                    ExecuteQuery(string.Format("delete from goods where 코드번호 = {0}", key));
                }
                BindData("select * from goods", dataGridView1);
            }
        }
Example #27
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection selectedRows = dgvProductList.SelectedRows;

            foreach (DataGridViewRow dgv in selectedRows)
            {
                CustomerService customerService = new CustomerService();
                int             id = ObjectHelper.GetValueFromAnonymousType <int>(dgv.DataBoundItem, "Id");

                if (!customerService.DeleteCustomer(id))
                {
                    MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
                }
            }
            loadCustomerList();
        }
Example #28
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            // delete selected rows
            DataGridViewSelectedRowCollection selectedRows = dataGridView.SelectedRows;

            if (selectedRows.Count > 0)
            {
                for (int i = selectedRows.Count - 1; i >= 0; i--)
                {
                    dataGridView.Rows.RemoveAt(selectedRows[i].Index);
                }
            }
            else if (dataGridView.CurrentRow != null)
            {
                dataGridView.Rows.RemoveAt(dataGridView.CurrentRow.Index);
            }
        }
Example #29
0
        private async void btnDelete_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection r = dgvResult.SelectedRows;

            if (r.Count > 0)
            {
                DialogResult dialogResult = MessageBox.Show("Xác nhận xoá ?", "Bình tĩnh !", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    foreach (DataGridViewRow row in r)
                    {
                        await repository.Delete(Convert.ToInt32(row.Cells["Id"].Value));
                    }
                }
                await LoadTableFromDatabase();
            }
        }
Example #30
0
        private void btn_delete_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection r = datagridview_dssv.SelectedRows;

            if (r.Count == 0 || r[0].Cells["MSSV"].Value == null)
            {
                MessageBox.Show("Vui lòng chọn SV để xóa !");
            }
            else
            {
                string s = "";
                foreach (DataGridViewRow i in r)
                {
                    s += i.Cells["NameSV"].Value.ToString() + " ";
                    if (i.Cells == null)
                    {
                        MessageBox.Show("Vui lòng chọn toàn bộ nội dung SV để xóa !");
                    }
                    else
                    {
                        result = MessageBox.Show("Bạn chắc chắn muốn xóa SV " + s + " ?", "Confirmation", MessageBoxButtons.YesNo);
                        if (result == DialogResult.Yes)
                        {
                            BLL_QLSV Bll  = new BLL_QLSV();
                            string   MSSV = i.Cells["MSSV"].Value.ToString();
                            if (Bll.DeleteSV_BLL(MSSV))
                            {
                                MessageBox.Show("Xóa thành công!");
                                show(1);
                            }
                            else
                            {
                                MessageBox.Show("Không thể xóa !");
                                s = "";
                                continue;
                            }
                        }
                        else
                        {
                            s = "";
                            continue;
                        }
                    }
                }
            }
        }
Example #31
0
 public SPLookupFormItemSelectedEventArgs(DataGridViewRow FirstItem, DataGridViewSelectedRowCollection SelectedItems)
 {
     this._FirstItem = FirstItem;
     this._SelectedItems = SelectedItems;
 }
Example #32
0
            public void SimpleResults_DoubleClick(object sender, System.EventArgs e)
            {
                if ((SimpleResults.SelectedRows != null)&& SimpleResults.SelectedRows.Count > 0)
                {
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    if (ItemSelectedEvent != null)
                        ItemSelectedEvent(new SPLookupFormItemSelectedEventArgs(SimpleResults.SelectedRows[0], SimpleResults.SelectedRows));

                    _FirstResult = SimpleResults.SelectedRows[0];
                    _SearchResults = SimpleResults.SelectedRows;
                }
            }