Ejemplo n.º 1
0
        public void display()
        {
            this.cMaCVChiTieu.DataPropertyName     = nameof(ChiPhi.MaCongViecChiTieu);
            this.cCongViecChiTieu.DataPropertyName = nameof(ChiPhi.CongViecChiTieu);
            this.cNgayThucHien.DataPropertyName    = nameof(ChiPhi.ThucHien);
            this.cChiPhi.DataPropertyName          = nameof(ChiPhi.ChiPhiCongViec);

            List <ChiPhi> lstChiPhi = ChiPhiControllers.getListChiPhifromDB();
            BindingSource src       = new BindingSource();

            src.DataSource           = lstChiPhi;
            dataGridView1.DataSource = src;

            //dataGridView1.Columns[3].Visible = false;
        }
Ejemplo n.º 2
0
        private void btnThemChiPhi_Click(object sender, EventArgs e)
        {
            if (this.txtMaCongViec.Text.Trim().Length <= 0)
            {
                this.errorProvider1.SetError(this.txtMaCongViec, "nhap ten ma cong viec");
                return;
            }
            else
            {
                this.errorProvider1.Clear();
            }
            if (this.txtCongViec.Text.Trim().Length <= 0)
            {
                this.errorProvider1.SetError(this.txtCongViec, "nhap ten cong viec");
                return;
            }
            else
            {
                this.errorProvider1.Clear();
            }
            if (this.txtChiPhi.Text.Trim().Length <= 0)
            {
                this.errorProvider1.SetError(this.txtChiPhi, "nhap chi phi");
                return;
            }
            else
            {
                this.errorProvider1.Clear();
            }
            ChiPhi cp = new ChiPhi();

            cp.MaCongViecChiTieu = txtMaCongViec.Text.Trim();
            cp.CongViecChiTieu   = txtCongViec.Text.Trim();
            cp.ChiPhiCongViec    = int.Parse(txtChiPhi.Text.Trim());
            cp.ThucHien          = dateTimeNgayThucHien.Value;

            ChiPhiControllers.AddChiPhi(cp);
            BindingSource source = new BindingSource();

            source.DataSource             = ChiPhiControllers.getListChiPhifromDB();
            this.dataGridView1.DataSource = source;
        }