Пример #1
0
        private void GetSelectedValue()
        {
            if (this.dgvVoucherStt.SelectedCells.Count > 0 && this.dgvVoucherStt.CurrentRow.Index < this.dgvVoucherStt.Rows.Count - 1)
            {
                int selectedrowindex = this.dgvVoucherStt.SelectedCells[0].RowIndex;

                DataGridViewRow selectedRow = this.dgvVoucherStt.Rows[selectedrowindex];
                string          name        = Convert.ToString(selectedRow.Cells["clmnReader"].Value);
                bool            ob          = Convert.ToBoolean(selectedRow.Cells["clmnObject"].Value);
                string          id          = Convert.ToString(selectedRow.Cells["clmnCertificateId"].Value);
                DateTime        payday      = Convert.ToDateTime(selectedRow.Cells["clmnPayDay"].Value);
                this.txtReaderName.Text = name;
                if (ob)
                {
                    this.txtObject.Text = "Cán Bộ Công Nhân Viên";
                }
                else
                {
                    this.txtObject.Text = "Sinh Viên";
                }
                this.txtPayDay.Text      = payday.ToShortDateString();
                this.txtCertificate.Text = id;

                /*if (id == "")
                 * {
                 *  this.btnDelete.Enabled = false;
                 *  this.btnSave.Enabled = false;
                 * }
                 * else
                 * {
                 *  this.btnDelete.Enabled = true;
                 *  this.btnSave.Enabled = true;
                 * }*/
                if (this.dgvVoucherStt.SelectedCells.Count > 0 && this.dgvVoucherStt.CurrentRow.Index < this.dgvVoucherStt.Rows.Count - 1)
                {
                    this.dgvDetailVoucher.Rows.Clear();
                    DetailVoucherBLL        manageVoucherBLL = new DetailVoucherBLL();
                    List <DetailVoucherBLL> manageVoucherArr = new List <DetailVoucherBLL>();
                    manageVoucherArr = VoucherDAL.getDetailVoucherList(Convert.ToInt32(selectedRow.Cells["clmnVoucherId"].Value));
                    //MessageBox.Show("ok");
                    foreach (DetailVoucherBLL row in manageVoucherArr)
                    {
                        this.dgvDetailVoucher.Rows.Add(row.Masachtra, row.Tensachtra);
                    }
                }
            }
            else
            {
                this.txtReaderName.Text  = "";
                this.txtPayDay.Text      = "";
                this.txtObject.Text      = "";
                this.txtCertificate.Text = "";
                this.dgvDetailVoucher.Rows.Clear();
            }
        }
Пример #2
0
        public static List <DetailVoucherBLL> getDetailVoucherList(Int32 maphieutra)
        {
            String    sql = "SELECT * FROM [sachtra] INNER JOIN [sach] ON sachtra.masach = sach.masach INNER JOIN [dausach] ON sach.madausach = dausach.madausach where sachtra.maphieutra = " + maphieutra;
            DataTable dt  = VoucherDAL._condb.getDataTable(sql);
            List <DetailVoucherBLL> manageVoucherBLLList = new List <DetailVoucherBLL>();

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow row in dt.Rows)
                {
                    DetailVoucherBLL manageVoucherBLL = new DetailVoucherBLL(Int32.Parse(row["masach"].ToString()), row["tensach"].ToString());
                    manageVoucherBLLList.Add(manageVoucherBLL);
                }
                return(manageVoucherBLLList);
            }
            else
            {
                return(null);
            }
        }