Пример #1
0
        private void btnprint_Click(object sender, EventArgs e)
        {
            DataTable dt = BUS_DT.hienthiDTcuthe(cbmatkdt.Text.Trim());

            if (dt.Rows.Count == 0)
            {
                MessageBox.Show("Bạn chưa chọn bản ghi nào", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            dtprint = true;
            madt    = cbmatkdt.Text.Trim();
            PRINTPREVIEW pp = new PRINTPREVIEW();

            pp.ShowDialog();

            DANGNHAP.thaotac += "In báo cáo, ";
        }
Пример #2
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            DataTable dt = BUS_DT.hienthiDTcuthe(cbmatkdt.Text.Trim());

            if (dt.Rows.Count == 0)
            {
                MessageBox.Show("Bạn chưa chọn bản ghi nào", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (MessageBox.Show("Bạn có chắc chắn muốn xóa không?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                BUS_DT.RunDelSQL(cbmatkdt.Text.Trim());

                //Cập nhật lại dữ liệu trên combobox mã dt.
                BUS_DT.FillComboMaTKDT(cbmatkdt, "IdDT", "IdDT");
                cbmatkdt.SelectedIndex = -1;

                ResetValues();
                LoadDataGridView();
                DANGNHAP.thaotac += "Xoá, ";
            }
        }
Пример #3
0
        private void cbmatkdt_TextChanged(object sender, EventArgs e)
        {
            if (cbmatkdt.Text.Trim() != string.Empty)
            {
                bool flag = true;
                for (int i = 0; i < cbmatkdt.Items.Count; ++i)
                {
                    if (cbmatkdt.Text.Trim() == cbmatkdt.Items[i].ToString())
                    {
                        flag = true;
                        break;
                    }
                    else
                    {
                        flag = false;
                    }
                }

                if (flag)
                {
                    DataTable dt = BUS_DT.hienthiDTcuthe(cbmatkdt.Text.Trim());

                    if (dt.Rows.Count == 1)
                    {
                        DataRow dr = dt.Rows[0];
                        cbmanv.Text            = dr[1].ToString();
                        txtDoanhSoban.Text     = dr[2].ToString();
                        txtdoanhthu.Text       = dr[3].ToString();
                        txtloinhuan.Text       = dr[4].ToString();
                        dtpngaytk.Text         = dr[5].ToString();
                        dgvdoanhthu.DataSource = dt;
                    }
                    else
                    {
                        cbmanv.Text            = string.Empty;
                        txtdoanhthu.Text       = string.Empty;
                        txtDoanhSoban.Text     = string.Empty;
                        txtloinhuan.Text       = string.Empty;
                        dtpngaytk.Text         = DateTime.Now.ToString();
                        dgvdoanhthu.DataSource = dt;
                    }
                }
                else
                {
                    cbmanv.Text            = string.Empty;
                    txtdoanhthu.Text       = string.Empty;
                    txtDoanhSoban.Text     = string.Empty;
                    txtloinhuan.Text       = string.Empty;
                    dtpngaytk.Text         = DateTime.Now.ToString();
                    dgvdoanhthu.DataSource = BUS_DT.hienthiDTcuthe(cbmatkdt.Text.Trim());
                }
            }
            else
            {
                cbmanv.Text            = string.Empty;
                txtdoanhthu.Text       = string.Empty;
                txtDoanhSoban.Text     = string.Empty;
                txtloinhuan.Text       = string.Empty;
                dtpngaytk.Text         = DateTime.Now.ToString();
                dgvdoanhthu.DataSource = BUS_DT.hienthiDTcuthe(cbmatkdt.Text.Trim());
            }
        }