Exemple #1
0
        private async void btnCount_Click(object sender, EventArgs e)
        {
            BULKCOPY bulk  = new BULKCOPY();
            var      count = await bulk.GetCount().ConfigureAwait(false);

            MessageBox.Show(count.ToString(), "Total record");
        }
Exemple #2
0
        private async void btnUpdate_Click(object sender, EventArgs e)
        {
            BULKCOPY bulk   = new BULKCOPY();
            var      result = await bulk.UpdateByName(txtName.Text.Trim(), Convert.ToInt32(txtPrice.Text));

            MessageBox.Show(result.ToString() + " Updateted", "Info");
            await LoadData(Convert.ToInt32(lblCurPage.Text)).ConfigureAwait(false);
        }
Exemple #3
0
        private async void btnDelete_Click(object sender, EventArgs e)
        {
            var confirm = MessageBox.Show("Are you sure?", "Confirm delete", MessageBoxButtons.YesNo);

            if (confirm.Equals(DialogResult.Yes))
            {
                BULKCOPY bulk   = new BULKCOPY();
                var      result = await bulk.DeleteByName(txtName.Text.Trim());

                MessageBox.Show(result.ToString() + " Deleted", "Info");
                await LoadData(Convert.ToInt32(lblCurPage.Text)).ConfigureAwait(false);
            }
        }
Exemple #4
0
        private async Task LoadData(int page = 1, string query = "")
        {
            var      start   = (page - 1) * 10 + 1;
            var      end     = start + 10 - 1;
            BULKCOPY bulk    = new BULKCOPY();
            var      count   = bulk.GetCount(query);
            var      lstBulk = bulk.SelectPaging(start, end, query);
            await Task.WhenAll(count, lstBulk);

            grvData.DataSource = lstBulk.Result;
            lblTotal.Text      = count.Result.ToString();
            lblCurPage.Text    = page.ToString();
            lblttPage.Text     = (count.Result / 10) == 0 ? "1" : (count.Result / 10).ToString();
        }
Exemple #5
0
        private async void grvData_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            var row = grvData.CurrentRow;

            if (!row.IsNewRow)
            {
                string name   = row.Cells[0].Value.ToString().Trim();
                var    bulk   = new BULKCOPY();
                var    detail = await bulk.SelectByName(name);

                if (detail.Any())
                {
                    txtName.Text  = detail.First().NAME;
                    txtPrice.Text = detail.First().PRICE.ToString();
                }
            }
        }