private void btnAccept_Click(object sender, EventArgs e)
        {
            CongTrinh _congtrinh = new CongTrinh();

            _congtrinh.TenCongTrinh  = txtTenCongTrinh.Text;
            _congtrinh.MaHieuCT      = txtMaHieuCT.Text;
            _congtrinh.SoHopDong     = txtSoHopDong.Text;
            _congtrinh.MaKhachHang   = Convert.ToInt32(cboKhachHang1.SelectedValue);
            _congtrinh.TinhTrangID   = Convert.ToInt32(cboTinhTrang1.SelectedValue);
            _congtrinh.NgayKy        = dtNgayKy.Value;
            _congtrinh.NgayBatDauCT  = dtNgayBatDau.Value;
            _congtrinh.NgayKetThucCT = dtNgayKetThuc.Value;
            _congtrinh.NguoiTao      = SessionUser.UserName;
            _congtrinh.GhiChu        = txtGhiChu.Text;

            if (txtMaCongTrinh.Text != string.Empty)
            {
                _congtrinh.CongTrinhID = Convert.ToInt32(txtMaCongTrinh.Text);
            }

            BLL_CongTrinh adapter = new BLL_CongTrinh();

            adapter.Add(_congtrinh);

            BindingCongTrinh(string.Empty, Convert.ToInt32(cboKhachHang.SelectedValue), Convert.ToInt32(cboTinhTrang.SelectedValue), dtTuNgay.Value, dtDenNgay.Value);
            tabControl_CongTrinh.SelectedIndex = 0;
        }
Esempio n. 2
0
        private void btnAccept_Click(object sender, EventArgs e)
        {
            if (ValidateData())
            {
                CongTrinh _congtrinh = new CongTrinh();
                _congtrinh.TenCongTrinh  = txtTenCongTrinh.Text;
                _congtrinh.MaHieuCT      = txtMaHieuCT.Text;
                _congtrinh.SoHopDong     = txtSoHopDong.Text;
                _congtrinh.MaKhachHang   = Convert.ToInt32(cboKhachHang1.SelectedValue);
                _congtrinh.MaTinhTrang   = Convert.ToString(cboTinhTrang1.SelectedValue);
                _congtrinh.NgayKy        = dtNgayKy.Value;
                _congtrinh.NgayBatDauCT  = dtNgayBatDau.Value;
                _congtrinh.NgayKetThucCT = dtNgayKetThuc.Value;
                _congtrinh.NguoiTao      = SessionUser.UserName;
                _congtrinh.GhiChu        = txtGhiChu.Text;

                int           _idCT     = 0;
                BLL_CongTrinh adapterCT = new BLL_CongTrinh();
                if (txtMaCongTrinh.Text != string.Empty)
                {
                    _idCT = Convert.ToInt32(txtMaCongTrinh.Text);
                    _congtrinh.MaCongTrinh = _idCT;
                    adapterCT.Update(_congtrinh);
                }
                else
                {
                    // add công trình
                    _idCT = adapterCT.Add(_congtrinh);
                }
                // add hạng mục
                UpdateHangMuc(_ds.Tables["HangMuc"], _idCT, _congtrinh.MaHieuCT);

                //BindingCongTrinh(string.Empty, Convert.ToInt32(cboKhachHang.SelectedValue), Convert.ToInt32(cboTinhTrang.SelectedValue), dtTuNgay.Value, dtDenNgay.Value);
                //tabControl_CongTrinh.SelectedIndex = 0;
            }
        }