private void cboLoaiKham_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         if (!m_blnLoaded)
         {
             return;
         }
         string       _RowFilter      = "1=1";
         DmucKieukham objExamTypeList = DmucKieukham.FetchByID(Utility.Int32Dbnull(cboLoaiKham.SelectedValue));
         if (objExamTypeList != null)
         {
             if (objExamTypeList.MaDoituongkcb == "ALL")
             {
                 _RowFilter = string.Format("{0}", "1=1");
             }
             else
             {
                 _RowFilter = string.Format("{0}='{1}'", DmucDoituongkcb.Columns.MaDoituongKcb,
                                            objExamTypeList.MaDoituongkcb);
             }
         }
         v_ObjectTypeList.DefaultView.RowFilter = _RowFilter;
         v_ObjectTypeList.AcceptChanges();
     }
     catch (Exception ex)
     {
         Utility.ShowMsg("Lỗi:" + ex.Message);
         // throw;
     }
 }
        /// <summary>
        /// /hàm thực heien thông tin update thông tin lại
        /// </summary>
        private void PerformActionUpdate()
        {
            string          MaDoituongKcb = "ALL";
            string          NhomBaocao    = "-1";
            DmucDoituongkcb objectType    = DmucDoituongkcb.FetchByID(Utility.Int16Dbnull(cboDoituong.SelectedValue, -1));

            if (objectType != null)
            {
                MaDoituongKcb = objectType.MaDoituongKcb;
            }
            else
            {
                MaDoituongKcb = "ALL";
            }
            DmucKieukham objKieukham = DmucKieukham.FetchByID(Utility.Int16Dbnull(cboLoaiKham.SelectedValue, -1));

            if (objKieukham != null)
            {
                NhomBaocao = Utility.sDbnull(objKieukham.NhomBaocao, "");
            }
            else
            {
                NhomBaocao = "-1";
            }
            int record = new Update(DmucDichvukcb.Schema)
                         .Set(DmucDichvukcb.Columns.IdKhoaphong).EqualTo(Utility.Int16Dbnull(cboDepartment1.SelectedValue, 1))
                         .Set(DmucDichvukcb.Columns.MaDichvukcb).EqualTo(txtCode.Text.Trim())
                         .Set(DmucDichvukcb.Columns.HoatDong).EqualTo(chkhoatdong.Checked)
                         .Set(DmucDichvukcb.Columns.MaGia).EqualTo(txtmagiabhyt.Text.Trim())
                         .Set(DmucDichvukcb.Columns.TenDichvukcb).EqualTo(txtName.Text.Trim())
                         .Set(DmucDichvukcb.Columns.MotaThem).EqualTo(txtDesc.Text.Trim())
                         .Set(DmucDichvukcb.Columns.SttHthi).EqualTo(Utility.Int16Dbnull(nmrSTT.Value))
                         .Set(DmucDichvukcb.Columns.NhomBaocao).EqualTo(NhomBaocao)
                         .Set(DmucDichvukcb.Columns.MaDoituongKcb).EqualTo(MaDoituongKcb)
                         .Set(DmucDichvukcb.Columns.IdPhongkham).EqualTo(Utility.Int16Dbnull(cboRoomDept.SelectedValue, 1))
                         .Set(DmucDichvukcb.Columns.IdBacsy).EqualTo(
                Convert.ToInt16(cboBacSy.Items.Count > 0 ? Utility.Int16Dbnull(cboBacSy.SelectedValue, 1) : -1))
                         .Set(DmucDichvukcb.Columns.IdKieukham).EqualTo(Utility.Int16Dbnull(cboLoaiKham.SelectedValue, 1))
                         .Set(DmucDichvukcb.Columns.IdDoituongKcb).EqualTo(Utility.Int16Dbnull(cboDoituong.SelectedValue, -1))
                         .Set(DmucDichvukcb.Columns.DonGia).EqualTo(Utility.DecimaltoDbnull(txtDongia.Text, 0))
                         .Set(DmucDichvukcb.Columns.DongiaNgoaigio).EqualTo(Utility.DecimaltoDbnull(txtGiangoaigio.Text, 0))
                         .Set(DmucDichvukcb.Columns.PhuthuNgoaigio).EqualTo(Utility.DecimaltoDbnull(txtPhuthungoaigio.Text, 0))
                         .Set(DmucDichvukcb.Columns.TuTuc).EqualTo(Utility.Bool2byte(chkTutuc.Checked))
                         .Set(DmucDichvukcb.Columns.PhuthuDungtuyen).EqualTo(Utility.DecimaltoDbnull(txtPTDT.Text, 0))
                         .Set(DmucDichvukcb.Columns.PhuthuTraituyen).EqualTo(Utility.DecimaltoDbnull(txtPTTT.Text, 0))
                         .Where(DmucDichvukcb.Columns.IdDichvukcb).IsEqualTo(Utility.DecimaltoDbnull(txtInsObject_ID.Text, -1)).
                         Execute();

            if (record > 0)
            {
                DataRow[] dr =
                    m_dtDataRelation.Select(DmucDichvukcb.Columns.IdDichvukcb + "=" +
                                            Utility.Int32Dbnull(txtInsObject_ID.Text, -1));
                if (dr.GetLength(0) > 0)
                {
                    dr[0][DmucDichvukcb.Columns.IdDoituongKcb] = Utility.DecimaltoDbnull(cboDoituong.SelectedValue);
                    dr[0][DmucDichvukcb.Columns.IdKhoaphong]   = Utility.Int16Dbnull(cboDepartment1.SelectedValue, -1);
                    dr[0][DmucDichvukcb.Columns.IdPhongkham]   = Utility.Int16Dbnull(cboRoomDept.SelectedValue, -1);
                    dr[0][DmucDichvukcb.Columns.IdBacsy]       = cboBacSy.Items.Count > 0
                                                               ? Utility.Int16Dbnull(cboBacSy.SelectedValue, -1)
                                                               : -1;
                    dr[0][DmucDichvukcb.Columns.IdKieukham] = Utility.Int16Dbnull(cboLoaiKham.SelectedValue, -1);
                    dr[0][DmucKieukham.Columns.TenKieukham] = cboLoaiKham.Text;
                    dr[0]["ten_khoa"]  = cboDepartment1.SelectedIndex <= -1 ? "Tất cả các khoa KCB" : cboDepartment1.Text;
                    dr[0]["ten_phong"] = cboRoomDept.Text;
                    dr[0][DmucDichvukcb.Columns.MaDichvukcb]  = txtCode.Text.Trim();
                    dr[0][DmucDichvukcb.Columns.MaBhyt]       = txtMaBhyt.Text.Trim();
                    dr[0][DmucDichvukcb.Columns.MaGia]        = txtmagiabhyt.Text.Trim();
                    dr[0][DmucDichvukcb.Columns.TenDichvukcb] = txtName.Text.Trim();
                    dr[0]["ten_bacsi"] = cboBacSy.SelectedIndex > 0 ? cboBacSy.Text : "";
                    dr[0][DmucDichvukcb.Columns.MaDoituongKcb]    = objectType != null ? objectType.MaDoituongKcb : "ALL";
                    dr[0][DmucDoituongkcb.Columns.TenDoituongKcb] = objectType != null
                                                                        ? cboDoituong.Text
                                                                        : "Tất cả các đối tượng";
                    dr[0][DmucDichvukcb.Columns.MotaThem] = Utility.DoTrim(txtDesc.Text);
                    dr[0][DmucDichvukcb.Columns.SttHthi]  = Utility.Int16Dbnull(nmrSTT.Value, 1);

                    dr[0][DmucDichvukcb.Columns.DonGia]          = Utility.DecimaltoDbnull(txtDongia.Text, 0);
                    dr[0][DmucDichvukcb.Columns.DongiaNgoaigio]  = Utility.DecimaltoDbnull(txtGiangoaigio.Text, 0);
                    dr[0][DmucDichvukcb.Columns.PhuthuNgoaigio]  = Utility.DecimaltoDbnull(txtPhuthungoaigio.Text, 0);
                    dr[0][DmucDichvukcb.Columns.TuTuc]           = Utility.Bool2byte(chkTutuc.Checked);
                    dr[0][DmucDichvukcb.Columns.HoatDong]        = Utility.Bool2byte(chkhoatdong.Checked);
                    dr[0][DmucDichvukcb.Columns.PhuthuDungtuyen] = Utility.DecimaltoDbnull(txtPTDT.Text, 0);
                    dr[0][DmucDichvukcb.Columns.PhuthuTraituyen] = Utility.DecimaltoDbnull(txtPTTT.Text, 0);
                }
                m_dtDataRelation.AcceptChanges();
                Close();
            }
            else
            {
                Utility.ShowMsg("Lỗi trong quá trình cập nhập dữ liệu");
                return;
            }
        }
        private void PerformActionInsert()
        {
            var objDmucDichvukcb = new DmucDichvukcb();

            objDmucDichvukcb.MaDichvukcb  = Utility.sDbnull(txtCode.Text.Trim(), "");
            objDmucDichvukcb.MaGia        = Utility.sDbnull(txtmagiabhyt.Text.Trim(), "");
            objDmucDichvukcb.HoatDong     = chkhoatdong.Checked;
            objDmucDichvukcb.TenDichvukcb = Utility.sDbnull(txtName.Text, "");
            objDmucDichvukcb.IdKieukham   = Utility.Int16Dbnull(cboLoaiKham.SelectedValue, -1);
            objDmucDichvukcb.IdKhoaphong  = Utility.Int16Dbnull(cboDepartment1.SelectedValue, -1);
            objDmucDichvukcb.IdBacsy      = Convert.ToInt16(cboBacSy.Items.Count > 0
                                                           ? Utility.Int16Dbnull(cboBacSy.SelectedValue, -1)
                                                           : -1);
            objDmucDichvukcb.MotaThem      = Utility.DoTrim(txtDesc.Text);
            objDmucDichvukcb.SttHthi       = Utility.Int16Dbnull(nmrSTT.Value);
            objDmucDichvukcb.IdDoituongKcb = Utility.Int16Dbnull(cboDoituong.SelectedValue, -1);
            DmucDoituongkcb objectType = DmucDoituongkcb.FetchByID(objDmucDichvukcb.IdDoituongKcb);

            if (objectType != null)
            {
                objDmucDichvukcb.MaDoituongKcb = Utility.sDbnull(objectType.MaDoituongKcb, "");
            }
            else
            {
                objDmucDichvukcb.MaDoituongKcb = "ALL";
            }

            DmucKieukham objKieukham = DmucKieukham.FetchByID(Utility.Int16Dbnull(cboLoaiKham.SelectedValue, -1));

            if (objKieukham != null)
            {
                objDmucDichvukcb.NhomBaocao = Utility.sDbnull(objKieukham.NhomBaocao, "");
            }
            else
            {
                objDmucDichvukcb.NhomBaocao = "-1";
            }

            objDmucDichvukcb.IdPhongkham     = Utility.Int16Dbnull(cboRoomDept.SelectedValue);
            objDmucDichvukcb.PhuthuDungtuyen = Utility.DecimaltoDbnull(txtPTDT.Text, 0);
            objDmucDichvukcb.PhuthuTraituyen = Utility.DecimaltoDbnull(txtPTTT.Text, 0);
            objDmucDichvukcb.DonGia          = Utility.DecimaltoDbnull(txtDongia.Text, 0);
            objDmucDichvukcb.DongiaNgoaigio  = Utility.DecimaltoDbnull(txtGiangoaigio.Text, 0);
            objDmucDichvukcb.PhuthuNgoaigio  = Utility.DecimaltoDbnull(txtPhuthungoaigio.Text, 0);
            objDmucDichvukcb.TuTuc           = Utility.Bool2byte(chkTutuc.Checked);
            objDmucDichvukcb.MaBhyt          = Utility.sDbnull(txtMaBhyt.Text.Trim(), "");
            objDmucDichvukcb.IsNew           = true;
            objDmucDichvukcb.Save();
            DataRow dr = m_dtDataRelation.NewRow();

            dr[DmucDichvukcb.Columns.IdDichvukcb] = Utility.Int32Dbnull(
                _Query.GetMax(DmucDichvukcb.Columns.IdDichvukcb), -1);
            dr[DmucDichvukcb.Columns.IdDoituongKcb] = Utility.DecimaltoDbnull(cboDoituong.SelectedValue);
            dr[DmucDichvukcb.Columns.IdKhoaphong]   = Utility.Int16Dbnull(cboDepartment1.SelectedValue, -1);
            dr[DmucDichvukcb.Columns.IdPhongkham]   = Utility.Int16Dbnull(cboRoomDept.SelectedValue, -1);
            dr[DmucDichvukcb.Columns.IdBacsy]       = cboBacSy.Items.Count > 0
                                                    ? Utility.Int16Dbnull(cboBacSy.SelectedValue, -1)
                                                    : -1;
            dr[DmucDichvukcb.Columns.DonGia]          = Utility.DecimaltoDbnull(txtDongia.Text, 0);
            dr[DmucDichvukcb.Columns.PhuthuDungtuyen] = Utility.DecimaltoDbnull(txtPTDT.Text, 0);
            dr[DmucDichvukcb.Columns.PhuthuTraituyen] = Utility.DecimaltoDbnull(txtPTTT.Text, 0);
            dr[DmucDichvukcb.Columns.DongiaNgoaigio]  = Utility.DecimaltoDbnull(txtGiangoaigio.Text, 0);
            dr[DmucDichvukcb.Columns.PhuthuNgoaigio]  = Utility.DecimaltoDbnull(txtPhuthungoaigio.Text, 0);

            dr[DmucDichvukcb.Columns.MotaThem] = Utility.DoTrim(txtDesc.Text);
            dr[DmucDichvukcb.Columns.SttHthi]  = Utility.Int16Dbnull(nmrSTT.Value, 1);


            dr[DmucDichvukcb.Columns.TuTuc]    = Utility.Bool2byte(chkTutuc.Checked);
            dr[DmucDichvukcb.Columns.HoatDong] = Utility.Bool2byte(chkhoatdong.Checked);
            dr["ten_phong"] = cboRoomDept.Text;
            dr[DmucDichvukcb.Columns.IdKieukham]   = Utility.Int16Dbnull(cboLoaiKham.SelectedValue, -1);
            dr[DmucKieukham.Columns.TenKieukham]   = cboLoaiKham.Text;
            dr[DmucDichvukcb.Columns.MaDichvukcb]  = txtCode.Text.Trim();
            dr[DmucDichvukcb.Columns.MaBhyt]       = txtMaBhyt.Text.Trim();
            dr[DmucDichvukcb.Columns.MaGia]        = txtmagiabhyt.Text.Trim();
            dr[DmucDichvukcb.Columns.TenDichvukcb] = txtName.Text.Trim();
            dr["ten_khoa"]  = cboDepartment1.SelectedIndex <= -1 ? "Tất cả các khoa KCB" : cboDepartment1.Text;
            dr["ten_bacsi"] = cboBacSy.SelectedIndex > 0 ? cboBacSy.Text : "";
            dr[DmucDoituongkcb.Columns.TenDoituongKcb] = objectType != null ? cboDoituong.Text : "Tất cả các đối tượng";

            m_dtDataRelation.Rows.Add(dr);
            //this.Close();
        }