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;
        }
Exemple #2
0
        private void SearchByCongTrinh(string keySearch, DateTime dtFormDate, DateTime dtToDate, int maKhachHang, string maTinhTrang)
        {
            DataSet       _dsCT     = new DataSet();
            BLL_CongTrinh adapter   = new BLL_CongTrinh();
            BLL_HangMuc   adapterHM = new BLL_HangMuc();

            List <CongTrinh>      _listCT   = adapter.GetList(maKhachHang, maTinhTrang, dtFormDate, dtToDate, keySearch);
            List <HangMuc>        _listHM   = new List <HangMuc>();
            List <ChiTietHangMuc> _listCTHM = new List <ChiTietHangMuc>();

            if (_listCT != null)
            {
                foreach (CongTrinh _ct in _listCT)
                {
                    List <HangMuc> _temp = adapterHM.GetList(_ct.MaCongTrinh, string.Empty, string.Empty);
                    if (_temp != null)
                    {
                        _listHM.AddRange(_temp);
                    }
                }

                foreach (HangMuc _hm in _listHM)
                {
                    List <ChiTietHangMuc> _temp1 = adapterHM.ChiTiet_GetList(_hm.MaHangMuc, string.Empty);
                    if (_temp1 != null)
                    {
                        _listCTHM.AddRange(_temp1);
                    }
                }
            }
            else
            {
                _listCT = new List <CongTrinh>();
            }
            DataTable _congtrinh      = Utils.ToDataTable <CongTrinh>(_listCT);
            DataTable _hangmuc        = Utils.ToDataTable <HangMuc>(_listHM);
            DataTable _chitiethangmuc = Utils.ToDataTable <ChiTietHangMuc>(_listCTHM);

            _congtrinh.ExtendedProperties.Add("ShowColumns", _showColumnCT);
            _hangmuc.ExtendedProperties.Add("ShowColumns", _showColumnHM);
            _chitiethangmuc.ExtendedProperties.Add("ShowColumns", _showColumnCTHM);

            _dsCT.Tables.Add(_congtrinh);
            _dsCT.Tables.Add(_hangmuc);
            _dsCT.Tables.Add(_chitiethangmuc);

            _dsCT.Relations.Add("CongTrinh_HangMuc",
                                _dsCT.Tables["CongTrinh"].Columns["MaCongTrinh"],
                                _dsCT.Tables["HangMuc"].Columns["MaCongTrinh"]);

            _dsCT.Relations.Add("HangMuc_ChiTietHangMuc",
                                _dsCT.Tables["HangMuc"].Columns["MaHangMuc"],
                                _dsCT.Tables["ChiTietHangMuc"].Columns["MaHangMuc"]);

            flexCongTrinh.SetDataBinding(_dsCT, "CongTrinh");
        }
Exemple #3
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;
            }
        }