/// <summary>
        /// Thực hiện nghiệp vụ Update dữ liệu
        /// </summary>
        private void PerformUpdateAction()
        {
            Utility.SetMsg(lblMsg, "", true);

            //Gọi Business cập nhật dữ liệu
            int v_shtIdLoaithuoc = Convert.ToInt32(txtID.Text);
            //Kiểm tra trùng tên đối tượng và cảnh báo
            DmucLoaithuocCollection v_arrSameObject = new DmucLoaithuocController().FetchByQuery(m_Query.AddWhere("ma_loaithuoc", txtDrug_Code.Text.Trim().ToUpper()).AND("Id_Loaithuoc", Comparison.NotEquals, v_shtIdLoaithuoc));

            if (v_arrSameObject.Count > 0)
            {
                if (!Utility.AcceptQuestion("Đã có nhóm có mã:" + txtDrug_Code.Text.Trim() + ". Bạn có muốn tiếp tục ghi hay không?", "Cảnh báo", true))
                {
                    //Create Again to ignore Where Clause
                    m_Query = DmucDoituongkcb.CreateQuery();
                    return;
                }
            }
            v_arrSameObject = new DmucLoaithuocController().FetchByQuery(m_Query.AddWhere("ten_loaithuoc", txtName.Text.Trim().ToUpper()).AND("Id_Loaithuoc", Comparison.NotEquals, v_shtIdLoaithuoc));
            if (v_arrSameObject.Count > 0)
            {
                if (!Utility.AcceptQuestion("Đã có nhóm có tên:" + txtName.Text.Trim() + ". Bạn có muốn tiếp tục ghi hay không?", "Cảnh báo", true))
                {
                    //Create Again to ignore Where Clause
                    m_Query = DmucDoituongkcb.CreateQuery();
                    return;
                }
            }
            //Create Again to ignore Where Clause
            m_Query = DmucLoaithuoc.CreateQuery();
            DmucLoaithuoc v_NewObjectChangePos = null;

            DmucLoaithuoc objDrugType = DmucLoaithuoc.FetchByID(Convert.ToInt16(txtID.Text));

            if (objDrugType != null)
            {
                objDrugType.MaLoaithuoc    = Utility.sDbnull(txtDrug_Code.Text);
                objDrugType.TenLoaithuoc   = Utility.sDbnull(txtName.Text);
                objDrugType.MotaThem       = Utility.sDbnull(txtDesc.Text);
                objDrugType.MaNhomthuoc    = Utility.sDbnull(txtNhom.myCode, "");
                objDrugType.SttHthi        = Convert.ToInt16(txtPos.Text);
                objDrugType.InRieng        = Convert.ToInt16(chkInrieng.Checked ? 1 : 0);
                objDrugType.KieuThuocvattu = txtKieuthuocVT.myCode;
                objDrugType.IsNew          = false;
                objDrugType.MarkOld();
                objDrugType.Save();
            }
            DataRow[] arrDr = m_dtLoaithuoc.Select(DmucLoaithuoc.Columns.IdLoaithuoc + "=" + txtID.Text);
            if (arrDr.Length > 0)
            {
                arrDr[0][DmucLoaithuoc.Columns.MaLoaithuoc]    = Utility.sDbnull(txtDrug_Code.Text);
                arrDr[0][DmucLoaithuoc.Columns.TenLoaithuoc]   = Utility.sDbnull(txtName.Text);
                arrDr[0][DmucLoaithuoc.Columns.MotaThem]       = Utility.sDbnull(txtDesc.Text);
                arrDr[0][DmucLoaithuoc.Columns.MaNhomthuoc]    = Utility.sDbnull(txtNhom.myCode, "");
                arrDr[0][DmucLoaithuoc.Columns.SttHthi]        = Convert.ToInt16(txtPos.Text);
                arrDr[0][DmucLoaithuoc.Columns.InRieng]        = Convert.ToInt16(chkInrieng.Checked ? 1 : 0);
                arrDr[0][DmucLoaithuoc.Columns.KieuThuocvattu] = txtKieuthuocVT.myCode;
                arrDr[0]["ten_nhomthuoc"] = txtNhom.Text;
            }
            //Return to the InitialStatus
            m_enAction = action.FirstOrFinished;
            //Nhảy đến bản ghi vừa cập nhật trên lưới. Do txtID chưa bị reset nên dùng luôn
            Utility.GotoNewRowJanus(grdList, "Id_Loaithuoc", txtID.Text.Trim());
            SetControlStatus();
            Utility.SetMsg(lblMsg, "Cập nhật dữ liệu thành công.", false);
        }
        /// <summary>
        /// Thực hiện nghiệp vụ Insert dữ liệu
        /// </summary>
        private void PerformInsertAction()
        {
            Utility.SetMsg(lblMsg, "", true);
            //Kiểm tra trùng tên đối tượng và cảnh báo
            DmucLoaithuocCollection v_arrSameObject = new DmucLoaithuocController().FetchByQuery(m_Query.AddWhere("ma_loaithuoc", txtDrug_Code.Text.Trim().ToUpper()));

            if (v_arrSameObject.Count > 0)
            {
                if (!Utility.AcceptQuestion("Đã có nhóm thuốc có mã:" + txtDrug_Code.Text.Trim() + ". Bạn có muốn tiếp tục ghi hay không?", "Cảnh báo", true))
                {
                    //Create Again to ignore Where Clause
                    m_Query = DmucLoaithuoc.CreateQuery();
                    txtDrug_Code.Focus();
                    return;
                }
            }
            v_arrSameObject = new DmucLoaithuocController().FetchByQuery(m_Query.AddWhere("ten_loaithuoc", txtName.Text.Trim().ToUpper()));
            if (v_arrSameObject.Count > 0)
            {
                if (!Utility.AcceptQuestion("Đã có nhóm có tên:" + txtName.Text.Trim() + ". Bạn có muốn tiếp tục ghi hay không?", "Cảnh báo", true))
                {
                    //Create Again to ignore Where Clause
                    m_Query = DmucLoaithuoc.CreateQuery();
                    txtName.Focus();
                    return;
                }
            }
            //Create Again to ignore Where Clause
            m_Query = DmucLoaithuoc.CreateQuery();
            //Gọi nghiệp vụ Insert dữ liệu

            DmucLoaithuoc objDrugType = new DmucLoaithuoc();

            objDrugType.MaLoaithuoc    = Utility.sDbnull(txtDrug_Code.Text);
            objDrugType.TenLoaithuoc   = Utility.sDbnull(txtName.Text);
            objDrugType.MotaThem       = Utility.sDbnull(txtDesc.Text);
            objDrugType.MaNhomthuoc    = Utility.sDbnull(txtNhom.myCode, "");
            objDrugType.SttHthi        = Convert.ToInt16(txtPos.Text);
            objDrugType.InRieng        = Convert.ToInt16(chkInrieng.Checked ? 1 : 0);
            objDrugType.KieuThuocvattu = txtNhom.myCode;;
            objDrugType.IsNew          = true;
            objDrugType.Save();
            //Lấy về MaxID vừa được thêm vào CSDL
            int v_shtIdLoaithuoc = objDrugType.IdLoaithuoc;
            //Lấy về Object vừa tạo
            DmucLoaithuocCollection v_arrNewObject = new DmucLoaithuocController().FetchByID(v_shtIdLoaithuoc);

            if (v_arrNewObject.Count > 0)//-->Thêm mới thành công
            {
                DataRow newitem = m_dtLoaithuoc.NewRow();
                Utility.FromObjectToDatarow(v_arrNewObject[0], ref newitem);
                newitem["ten_nhomthuoc"] = txtNhom.Text;
                m_dtLoaithuoc.Rows.Add(newitem);
                //Return to the InitialStatus
                m_enAction = action.FirstOrFinished;
                //Nhảy đến bản ghi vừa thêm mới trên lưới. Do txtID chưa bị reset nên dùng luôn
                Utility.GotoNewRowJanus(grdList, "Id_Loaithuoc", v_shtIdLoaithuoc.ToString());
                Utility.SetMsg(lblMsg, "Thêm mới dữ liệu thành công!", false);
                SetControlStatus();
                this.Activate();
            }
            else//Có lỗi xảy ra
            {
                Utility.SetMsg(lblMsg, "Thêm mới không thành công. Mời bạn xem lại", false);
            }
        }