public static void DeleteDepartment(int pId)
 {
     if (LDepartment.FetchByID(pId) != null)
     {
         LDepartment.Delete(pId);
     }
 }
        public static string InsertDepartment(LDepartment pitems)
        {
            int   i        = 0;
            Query _QueryRS = LDepartment.CreateQuery();

            try
            {
                if (!LDepartment.FetchByParameter(LDepartment.Columns.Id, Comparison.Equals, pitems.Id).Read())
                {
                    pitems.IsNew = true;
                    pitems.Save(i);
                    return(_QueryRS.GetMax(LDepartment.Columns.Id).ToString());
                    //var dt =
                    //    new Select(LDepartment.Columns.Id).From(LDepartment.Schema.Name).Where(LDepartment.Columns.IPAddress).IsEqualTo
                    //        (pitems.IPAddress).ExecuteDataSet().Tables[0];
                    //return dt.Rows [0][0].ToString();
                    //.ExecuteDataSet().Tables[0].Rows[0][0].ToString();
                }
                else
                {
                    return("-1");
                    //throw new Exception(string.Format("Name:{0} Đã tồn tại", pitems.IPAddress));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="v_Staff_Id"></param>
        /// <returns></returns>
        public static string GetDepartmentName(int v_Department_Id)
        {
            LDepartment objDepartment = LDepartment.FetchByID(v_Department_Id);

            if (objDepartment != null)
            {
                return(objDepartment.DepartmentName);
            }
            else
            {
                return("");
            }
        }
 public static void UpdateDepartment(LDepartment pitems)
 {
     try
     {
         if (LDepartment.FetchByID(pitems.Id) != null)
         {
             pitems.IsNew = false;
             pitems.Save();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                txtID.Text = txtID.Text.ToUpper();
                if (ValidData())
                {
                    switch (vAction)
                    {
                    case action.Insert:
                        var obj = new LDepartment();
                        obj.SName = Utility.sDbnull(txtName.Text);
                        obj.SDesc = Utility.sDbnull(txtDesc.Text);
                        obj.IsNew = true;
                        obj.Save();

                        drList = dtList.NewRow();
                        drList[LDepartment.Columns.Id] = LDepartment.CreateQuery().GetMax(LDepartment.Columns.Id);
                        ApplyData2Datarow();
                        dtList.Rows.InsertAt(drList, 0);
                        dtList.AcceptChanges();

                        txtID.Text = Utility.sDbnull(drList[LDepartment.Columns.Id]);
                        vAction    = action.Update;
                        break;

                    case action.Update:
                        new Update(LDepartment.Schema.Name).Set(LDepartment.Columns.SName).EqualTo(txtName.Text).
                        Set(LDepartment.Columns.SDesc).EqualTo(txtDesc.Text).
                        Where(LDepartment.Columns.Id).IsEqualTo(Utility.Int32Dbnull(txtID.Text)).
                        Execute();
                        ApplyData2Datarow();
                        drList.AcceptChanges();
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
示例#6
0
        //Update and Insert data in LDepartment
        public void UpdateDepartment()
        {
            LDepartment pitems;
            string      Name      = "";
            var         dataTable = grdAll.DataSource as DataTable;

            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                DataRow dr = dataTable.Rows[i];
                object  c  = dr[LDepartment.Columns.SName];
                //Kiểm tra trạng thái của dòng:
                if ((dr.RowState == DataRowState.Modified) || (dr.RowState == DataRowState.Added))
                {
                    Name = dr[LDepartment.Columns.SName].ToString();

                    if ((Name == ""))
                    {
                        SetTextForWarning(MsgEror);
                        continue;
                    }
                }
                if (dr.RowState == DataRowState.Modified)
                {
                    pitems       = new LDepartment(dr[LDepartment.Columns.Id]);
                    pitems.SName = Name;
                    pitems.SDesc = dr[LDepartment.Columns.SDesc].ToString();
                    DepartmentBusiness.UpdateDepartment(pitems);
                    SetTextForWarning(MsgUpdate);
                }
                else if (dr.RowState == DataRowState.Added)
                {
                    pitems       = new LDepartment();
                    pitems.SName = Name;
                    pitems.SDesc = dr[LDepartment.Columns.SDesc].ToString();
                    dr[LDepartment.Columns.Id] = DepartmentBusiness.InsertDepartment(pitems);
                    SetTextForWarning(MsgNew);
                }
            }
            dataTable.AcceptChanges();
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                txtID.Text = txtID.Text.ToUpper();
                if (ValidData())
                    switch (vAction)
                    {
                        case action.Insert:
                            var obj = new LDepartment();
                            obj.SName = Utility.sDbnull(txtName.Text);
                            obj.SDesc = Utility.sDbnull(txtDesc.Text);
                            obj.IsNew = true;
                            obj.Save();

                            drList = dtList.NewRow();
                            drList[LDepartment.Columns.Id] =LDepartment.CreateQuery().GetMax(LDepartment.Columns.Id);
                            ApplyData2Datarow();
                            dtList.Rows.InsertAt(drList, 0);
                            dtList.AcceptChanges();

                            txtID.Text = Utility.sDbnull(drList[LDepartment.Columns.Id]);
                            vAction = action.Update;
                            break;
                        case action.Update:
                            new Update(LDepartment.Schema.Name).Set(LDepartment.Columns.SName).EqualTo(txtName.Text).
                                Set(LDepartment.Columns.SDesc).EqualTo(txtDesc.Text).
                                Where(LDepartment.Columns.Id).IsEqualTo(Utility.Int32Dbnull(txtID.Text)).
                                Execute();
                            ApplyData2Datarow();
                            drList.AcceptChanges();
                            break;
                    }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
示例#8
0
        private void cmdXemBaoCao_Click(object sender, EventArgs e)
        {
            try
            {
                string sTenKhoa = cboDepartment.Text;
                dt = new DataTable();
                dt.Columns.Add("Barcode");
                dt.Columns.Add("Patient_ID");
                dt.Columns.Add("Patient_Name");
                dt.Columns.Add("AGE");
                dt.Columns.Add("Sex");
                dt.Columns.Add("Department");
                dt.Columns.Add("Insurance_Num");
                dt.Columns.Add("ObjectType");
                dt.Columns.Add("Diagnostic");
                dt.Columns.Add("AllResult");
                dt.Columns.Add("AllResult2");
                dt.Columns.Add("Test_Date");

                LDepartment objDepartment = LDepartment.FetchByID(Utility.Int32Dbnull(cboDepartment.SelectedValue));
                if (objDepartment != null)
                {
                    sTenKhoa = Utility.sDbnull(objDepartment.SName, "");
                }


                dtRawResult =
                    SpRptBaoCaoLuu(dtpFromDate.Value,
                                   dtpToDate.Value,
                                   Utility.Int32Dbnull(cboDepartment.SelectedValue), Utility.Int32Dbnull(cboObjectType.SelectedValue), chkPrintAll.Checked).
                    GetDataSet().Tables[0];
                if (dtRawResult.Rows.Count == 0)
                {
                    dtRawResult = null;
                }

                if (dtRawResult == null || dtRawResult.Rows.Count <= 0)
                {
                    Utility.ShowMsg("Không tồn tại dữ liệu");
                    cmdINPHIEU.Enabled    = false;
                    gridResult.DataSource = dt;
                    return;
                }
                bool forVd = SysPara.BarcodeType.ToUpper() == "VIETDUC";
                //Xử lý các giá trị bình thường
                //Utilities.ProcessNormalResult(ref dtRawResult, "Test_Result", "Normal_Level", "+",
                //                                            "+", "-", "flag", forVd);

                //lablinkhelper.Utilities.ProcessNormalResult(ref dtRawResult, "Test_Result", "Normal_Level", "",
                //                                            "", "", "flag", forVd);
                var patientResult  = new StringBuilder();
                var patientResult2 = new StringBuilder();

                dtRawResult.Rows.InsertAt(dtRawResult.NewRow(), 0);
                dtRawResult.Rows[0]["Patient_ID"] = dtRawResult.Rows[1]["Patient_ID"];
                dtRawResult.Rows.Add(dtRawResult.NewRow());
                for (int i = 1; i <= dtRawResult.Rows.Count - 1; i++)
                {
                    if (Utility.sDbnull(dtRawResult.Rows[i]["Patient_ID"]) !=
                        Utility.sDbnull(dtRawResult.Rows[i - 1]["Patient_ID"]))
                    {
                        //patientResult.Remove(patientResult.Length - 2, 1);
                        var newdr = dt.NewRow();
                        newdr["Patient_ID"]   = dtRawResult.Rows[i - 1]["Patient_ID"];
                        newdr["Barcode"]      = dtRawResult.Rows[i - 1]["Barcode"];
                        newdr["Patient_Name"] = dtRawResult.Rows[i - 1]["Patient_Name"];
                        newdr["AGE"]          = dtRawResult.Rows[i - 1]["AGE"];
                        newdr["Sex"]          = dtRawResult.Rows[i - 1]["Sex"];
                        //newdr["Insurance_Num"] = dtRawResult.Rows[i - 1]["Insurance_Num"];
                        newdr["Department"] = dtRawResult.Rows[i - 1]["Department"];
                        newdr["Diagnostic"] = dtRawResult.Rows[i - 1]["Diagnostic"];
                        //newdr["ObjectType"] = dtRawResult.Rows[i - 1]["ObjectType"];
                        if (dtRawResult.Rows[i - 1]["Test_Date"] != null)
                        {
                            newdr["Test_Date"] =
                                ((DateTime)dtRawResult.Rows[i - 1]["Test_Date"]).ToString("dd/MM/yyyy");
                        }
                        //newdr["Test_Date"] = DateTime.Parse(dtRawResult.Rows[i - 1]["Test_Date"].ToString()).ToString("dd/MM/yyyy");
                        newdr["AllResult2"] = patientResult2.ToString();
                        newdr["AllResult"]  = patientResult.ToString();
                        dt.Rows.Add(newdr);
                        patientResult2 = new StringBuilder();
                        patientResult  = new StringBuilder();
                    }
                    if ((Utility.sDbnull(dtRawResult.Rows[i]["TestType_Name"]) !=
                         Utility.sDbnull(dtRawResult.Rows[i - 1]["TestType_Name"])) |
                        (Utility.sDbnull(dtRawResult.Rows[i]["Patient_ID"]) !=
                         Utility.sDbnull(dtRawResult.Rows[i - 1]["Patient_ID"])))
                    {
                        patientResult2.Append(dtRawResult.Rows[i]["TestType_Name"] + ":");
                        patientResult.Append("</p>");
                        patientResult.Append(string.Format("<b>{0}</b>: ",
                                                           Utility.sDbnull(dtRawResult.Rows[i]["TestType_Name"]).ToUpper
                                                               ()));
                    }
                    string value, value2;
                    //if (Utility.sDbnull(dtRawResult.Rows[i]["flag"]).Trim() == "+")
                    //{
                    //    value2 = string.Format("{0} ,{1} , {2}; ",
                    //                          Utility.sDbnull(dtRawResult.Rows[i]["Test_Name"]),
                    //                          Utility.sDbnull(dtRawResult.Rows[i]["flag"]),
                    //                          dtRawResult.Rows[i]["Test_result"]);
                    //    value = string.Format("<font color=\"red\"><b>{0}({1}) {2};</b></font> ",
                    //  Utility.sDbnull(dtRawResult.Rows[i]["Test_Name"]),
                    //  Utility.sDbnull(dtRawResult.Rows[i]["flag"]),
                    //  dtRawResult.Rows[i]["Test_result"]);
                    //}
                    //else if (Utility.sDbnull(dtRawResult.Rows[i]["flag"]).Trim() == "-")
                    //{
                    //    value2 = string.Format("{0}, {1}, {2}; ",
                    //                          Utility.sDbnull(dtRawResult.Rows[i]["Test_Name"]),
                    //                          Utility.sDbnull(dtRawResult.Rows[i]["flag"]),
                    //                          dtRawResult.Rows[i]["Test_result"]);
                    //    value = string.Format("{0}({1}) {2}; ",
                    //                         Utility.sDbnull(dtRawResult.Rows[i]["Test_Name"]),
                    //                         Utility.sDbnull(dtRawResult.Rows[i]["flag"]),
                    //                         dtRawResult.Rows[i]["Test_result"]);
                    //}
                    //else
                    {
                        value2 = string.Format(
                            Utility.sDbnull(dtRawResult.Rows[i]["Test_result"]).Trim() != ""
                                ? "{0} {1};"
                                : "{0}&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp ", Utility.sDbnull(dtRawResult.Rows[i]["Test_Name"]),
                            dtRawResult.Rows[i]["Test_result"]);
                        value = string.Format(
                            Utility.sDbnull(dtRawResult.Rows[i]["Test_result"]).Trim() != ""
                               ? "{0} {1};"
                               : "<i>{0}&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</i> ",
                            Utility.sDbnull(dtRawResult.Rows[i]["Test_Name"]),
                            dtRawResult.Rows[i]["Test_result"]);
                    }


                    patientResult.Append(value);
                    patientResult2.Append(value2);
                }

                gridResult.DataSource = dt;
                cmdINPHIEU.Enabled    = true;
                gridResult.AutoSizeColumns();
                dt.AcceptChanges();
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
示例#9
0
        public void Insert(string SName,string SDesc,string HisDepartmentCode,short? IntOrder)
        {
            LDepartment item = new LDepartment();

            item.SName = SName;

            item.SDesc = SDesc;

            item.HisDepartmentCode = HisDepartmentCode;

            item.IntOrder = IntOrder;

            item.Save(UserName);
        }
示例#10
0
        public void Update(short Id,string SName,string SDesc,string HisDepartmentCode,short? IntOrder)
        {
            LDepartment item = new LDepartment();
            item.MarkOld();
            item.IsLoaded = true;

            item.Id = Id;

            item.SName = SName;

            item.SDesc = SDesc;

            item.HisDepartmentCode = HisDepartmentCode;

            item.IntOrder = IntOrder;

            item.Save(UserName);
        }
示例#11
0
        private void getData()
        {
            TPhieuCapphatNoitru objPhieuCapphat = TPhieuCapphatNoitru.FetchByID(Utility.Int32Dbnull(txtID_CAPPHAT.Text));

            if (objPhieuCapphat != null)
            {
                txtID_CAPPHAT.Text   = Utility.sDbnull(objPhieuCapphat.IdCapphat);
                dtNgayCapPhat.Value  = dtNgayCapPhat.Value;
                txtID_KHOA_LINH.Text = Utility.sDbnull(objPhieuCapphat.IdKhoaLinh);
                idKhoaLinh           = Utility.Int32Dbnull(objPhieuCapphat.IdKhoaLinh);
                DmucKhoaphong objLDepartment = DmucKhoaphong.FetchByID(objPhieuCapphat.IdKhoaLinh);
                if (objLDepartment != null)
                {
                    txtTen_KHOA_LINH.Text = Utility.sDbnull(objLDepartment.TenKhoaphong);
                }
                //chkIsBoSung.Checked = Convert.ToBoolean(objPhieuCapphat.LinhBSung);

                IsPhieuBoSung         = Utility.Byte2Bool(objPhieuCapphat.LoaiPhieu);
                radLinhBoSung.Checked = IsPhieuBoSung;
                loaiphieu             = Utility.sDbnull(objPhieuCapphat.LoaiPhieu);
                radThuoc.Checked      = loaiphieu == "THUOC";
                radLinhVTYT.Checked   = loaiphieu == "VT";
                txtID_NVIEN.Text      = Utility.sDbnull(objPhieuCapphat.IdNhanviencapphat);
                DmucNhanvien objStaff = DmucNhanvien.FetchByID(objPhieuCapphat.IdNhanviencapphat);
                if (objStaff != null)
                {
                    txtTen_NVIEN.Text = Utility.sDbnull(objStaff.TenNhanvien);
                }
                txtId_KhoXuat.Text = Utility.sDbnull(objPhieuCapphat.IdKhoXuat);
                id_khoXuat         = Utility.Int32Dbnull(objPhieuCapphat.IdKhoXuat);
                DKho objKho = DKho.FetchByID(objPhieuCapphat.IdKhoXuat);
                if (objKho != null)
                {
                    txtTenKho.Text = Utility.sDbnull(objKho.TenKho);
                }
                madoituong         = Utility.sDbnull(objPhieuCapphat.MaDoiTuong);
                txtMaDoiTuong.Text = Utility.sDbnull(madoituong);
                SqlQuery    sqlQuery   = new Select().From <LObjectType>().Where(LObjectType.Columns.ObjectTypeCode).IsEqualTo(madoituong);
                LObjectType objectType = sqlQuery.ExecuteSingle <LObjectType>();
                if (objectType != null)
                {
                    txtObjectType_Name.Text = Utility.sDbnull(objectType.ObjectTypeName);
                }
                txtMOTA_THEM.Text = Utility.sDbnull(objPhieuCapphat.MotaThem);
            }
            else
            {
                dtNgayCapPhat.Value  = BusinessHelper.GetSysDateTime();
                txtID_KHOA_LINH.Text = Utility.sDbnull(idKhoaLinh);
                LDepartment objLDepartment = LDepartment.FetchByID(idKhoaLinh);
                if (objLDepartment != null)
                {
                    txtTen_KHOA_LINH.Text = Utility.sDbnull(objLDepartment.DepartmentName);
                }
                txtID_NVIEN.Text = Utility.sDbnull(globalVariables.gv_StaffID);
                LStaff objStaff = LStaff.FetchByID(globalVariables.gv_StaffID);
                if (objStaff != null)
                {
                    txtTen_NVIEN.Text = Utility.sDbnull(objStaff.StaffName);
                }

                txtId_KhoXuat.Text = Utility.sDbnull(id_khoXuat);
                DKho objKho = DKho.FetchByID(id_khoXuat);
                if (objKho != null)
                {
                    txtTenKho.Text = Utility.sDbnull(objKho.TenKho);
                }
                //loaiphieu = Utility.sDbnull(objPhieuCapphat.LoaiPhieu);
                radThuoc.Checked      = loaiphieu == "THUOC";
                radLinhVTYT.Checked   = loaiphieu == "VT";
                radLinhBoSung.Checked = IsPhieuBoSung;
                // IsPhieuBoSung = Convert.ToBoolean(objPhieuCapphat.LinhBSung);
                txtMaDoiTuong.Text = Utility.sDbnull(madoituong);
                SqlQuery    sqlQuery   = new Select().From <LObjectType>().Where(LObjectType.Columns.ObjectTypeCode).IsEqualTo(madoituong);
                LObjectType objectType = sqlQuery.ExecuteSingle <LObjectType>();
                if (objectType != null)
                {
                    txtObjectType_Name.Text = Utility.sDbnull(objectType.ObjectTypeName);
                }
            }
            LoadPhieuDonThuoc();
        }
示例#12
0
        private void getData()
        {
            TPhieuCapphatNoitru objPhieuCapphat = TPhieuCapphatNoitru.FetchByID(Utility.Int32Dbnull(txtID_CAPPHAT.Text));

            if (objPhieuCapphat != null)
            {
                txtID_CAPPHAT.Text = Utility.sDbnull(objPhieuCapphat.IdCapphat);
                if (!string.IsNullOrEmpty(Utility.sDbnull(objPhieuCapphat.NgayNhap)))
                {
                    dtNgayCapPhat.Value = Convert.ToDateTime(objPhieuCapphat.NgayNhap);
                }
                else
                {
                    dtNgayCapPhat.Value = DateTime.Now;
                }
                txtID_KHOA_LINH.Text = Utility.sDbnull(objPhieuCapphat.IdKhoaLinh);
                idKhoaLinh           = Utility.Int32Dbnull(objPhieuCapphat.IdKhoaLinh);
                DmucKhoaphong objLDepartment = DmucKhoaphong.FetchByID(objPhieuCapphat.IdKhoaLinh);
                if (objLDepartment != null)
                {
                    txtTen_KHOA_LINH.Text = Utility.sDbnull(objLDepartment.DepartmentName);
                }
                //chkIsBoSung.Checked = Convert.ToBoolean(objPhieuCapphat.LinhBSung);

                IsPhieuBoSung         = Convert.ToBoolean(objPhieuCapphat.loaiPhieu);
                radLinhBoSung.Checked = IsPhieuBoSung;
                loaiphieu             = Utility.sDbnull(objPhieuCapphat.LoaiPhieu);
                radThuoc.Checked      = loaiphieu == "THUOC";
                radLinhVTYT.Checked   = loaiphieu == "VT";
                txtID_NVIEN.Text      = Utility.sDbnull(objPhieuCapphat.idn);
                DmucNhanvien objStaff = DmucNhanvien.FetchByID(objPhieuCapphat.IdNvien);
                if (objStaff != null)
                {
                    txtTen_NVIEN.Text = Utility.sDbnull(objStaff.StaffName);
                }
                txtId_KhoXuat.Text = Utility.sDbnull(objPhieuCapphat.IdKhoXuat);
                id_khoXuat         = Utility.Int32Dbnull(objPhieuCapphat.IdKhoXuat);
                DKho objKho = DKho.FetchByID(objPhieuCapphat.IdKhoXuat);
                if (objKho != null)
                {
                    txtTenKho.Text = Utility.sDbnull(objKho.TenKho);
                }
                madoituong         = Utility.sDbnull(objPhieuCapphat.MaDoiTuong);
                txtMaDoiTuong.Text = Utility.sDbnull(madoituong);
                if (globalVariables.gv_TongHopDonThuocMaDoiTuong)
                {
                    SqlQuery sqlQuery =
                        new Select().From <LObjectType>().Where(LObjectType.Columns.ObjectTypeCode).IsEqualTo(madoituong);
                    var objectType = sqlQuery.ExecuteSingle <LObjectType>();
                    if (objectType != null)
                    {
                        txtObjectType_Name.Text = Utility.sDbnull(objectType.ObjectTypeName);
                    }
                }
                else
                {
                    txtObjectType_Name.Text = "Tất cả";
                }
                txtMOTA_THEM.Text = Utility.sDbnull(objPhieuCapphat.MotaThem);
                me_Action         = action.Update;
            }
            else
            {
                dtNgayCapPhat.Value  = globalVariables.SysDate;
                txtID_KHOA_LINH.Text = Utility.sDbnull(idKhoaLinh);
                LDepartment objLDepartment = LDepartment.FetchByID(idKhoaLinh);
                if (objLDepartment != null)
                {
                    txtTen_KHOA_LINH.Text = Utility.sDbnull(objLDepartment.DepartmentName);
                }
                txtID_NVIEN.Text = Utility.sDbnull(globalVariables.gv_StaffID);
                LStaff objStaff = LStaff.FetchByID(globalVariables.gv_StaffID);
                if (objStaff != null)
                {
                    txtTen_NVIEN.Text = Utility.sDbnull(objStaff.StaffName);
                }

                txtId_KhoXuat.Text = Utility.sDbnull(id_khoXuat);
                DKho objKho = DKho.FetchByID(id_khoXuat);
                if (objKho != null)
                {
                    txtTenKho.Text = Utility.sDbnull(objKho.TenKho);
                }
                //loaiphieu = Utility.sDbnull(objPhieuCapphat.LoaiPhieu);
                radThuoc.Checked      = loaiphieu == "THUOC";
                radLinhVTYT.Checked   = loaiphieu == "VT";
                radLinhBoSung.Checked = IsPhieuBoSung;
                // IsPhieuBoSung = Convert.ToBoolean(objPhieuCapphat.LinhBSung);
                txtMaDoiTuong.Text = Utility.sDbnull(madoituong);
                if (globalVariables.gv_TongHopDonThuocMaDoiTuong)
                {
                    SqlQuery sqlQuery =
                        new Select().From <LObjectType>().Where(LObjectType.Columns.ObjectTypeCode).IsEqualTo(madoituong);
                    var objectType = sqlQuery.ExecuteSingle <LObjectType>();
                    if (objectType != null)
                    {
                        txtObjectType_Name.Text = Utility.sDbnull(objectType.ObjectTypeName);
                    }
                }
                else
                {
                    txtObjectType_Name.Text = "Tất cả";
                }
            }
            LoadDonThuoc();
        }
        private void cboRegExam_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                txtSoLanKham.Text = Utility.sDbnull(cboRegExam.SelectedValue, -1);
                TRegExam objRegExam = TRegExam.FetchByID(Utility.Int32Dbnull(txtSoLanKham.Text));
                if (objRegExam != null)
                {
                    DataTable m_dtThongTin =
                        SPs.LaokhoaLaythongtinBenhnhanNgoaitruLankham(ObjPatientExam.PatientCode,
                                                                      Utility.Int32Dbnull(ObjPatientExam.PatientId, -1),
                                                                      Utility.Int32Dbnull(txtSoLanKham.Text)).GetDataSet
                            ().Tables[0];
                    if (m_dtThongTin.Rows.Count > 0)
                    {
                        DataRow dr = m_dtThongTin.Rows[0];
                        if (dr != null)
                        {
                            dtInput_Date.Value = Convert.ToDateTime(dr[TPatientExam.Columns.InputDate]);

                            txtExam_ID.Text       = Utility.sDbnull(objRegExam.RegId);
                            dtpCreatedDate.Value  = Convert.ToDateTime(objRegExam.RegDate);
                            txtDepartment_ID.Text = Utility.sDbnull(objRegExam.DepartmentId);
                            LDepartment objDepartment = LDepartment.FetchByID(Utility.Int32Dbnull(txtDepartment_ID.Text));
                            if (objDepartment != null)
                            {
                                txtDepartment_Name.Text = Utility.sDbnull(objDepartment.DepartmentName);
                            }
                            txtTenKham.Text = Utility.sDbnull(objRegExam.KieuKhambenh);
                            if (objRegExam.UserId == "ADMIN")
                            {
                                txtNguoiTiepNhan.Text = objRegExam.UserId;
                            }
                            else
                            {
                                LStaff lStaff = BusinessHelper.GetStaffByUserName(objRegExam.UserId);
                                if (lStaff != null)
                                {
                                    txtNguoiTiepNhan.Text = Utility.sDbnull(lStaff.StaffName);
                                }
                                else
                                {
                                    txtNguoiTiepNhan.Text = objRegExam.UserId;
                                }
                            }
                            if (Utility.Int32Dbnull(objRegExam.IdBsyThien, -1) <= 0)
                            {
                                cboDoctorAssign.SelectedValue = Utility.Int32Dbnull(objRegExam.IdBsyThien, -1);
                            }
                            else
                            {
                                cboDoctorAssign.SelectedIndex = 0;
                            }
                            //TExamInfo objExam = TExamInfo.FetchByID(Utility.Int32Dbnull(txtExam_ID.Text));
                            //if (objExam != null)
                            //{
                            //    txtKet_Luan.Text = Utility.sDbnull(objExam.KetLuan);
                            //    txtHuongdieutri.Text = objExam.HuongDieuTri;
                            //    nmrSongayDT.Value = Utility.DecimaltoDbnull(objExam.SoNgay, 0);
                            //    var objDiagInfo = new Select().From(TDiagInfo.Schema)
                            //        .Where(TDiagInfo.Columns.ExamId).IsEqualTo(objExam.ExamId).ExecuteSingle<TDiagInfo>();
                            //    if (objDiagInfo != null)
                            //    {
                            //        txtChanDoan.Text = Utility.sDbnull(objDiagInfo.DiagInfo);
                            //        txtMaBenhChinh.Text = Utility.sDbnull(objDiagInfo.MainDiseaseId);
                            //        string dataString = Utility.sDbnull(objDiagInfo.AuxiDiseaseId, "");
                            //        if (!string.IsNullOrEmpty(dataString))
                            //        {
                            //            dt_ICD_PHU.Clear();
                            //            string[] rows = dataString.Split(',');
                            //            foreach (string row in rows)
                            //            {
                            //                if (!string.IsNullOrEmpty(row))
                            //                {
                            //                    DataRow newDr = dt_ICD_PHU.NewRow();
                            //                    newDr["MA_ICD"] = row;
                            //                    newDr["TEN_ICD"] = GetTenBenh(row);
                            //                    dt_ICD_PHU.Rows.Add(newDr);
                            //                    dt_ICD_PHU.AcceptChanges();
                            //                }
                            //            }
                            //            grd_ICD.DataSource = dt_ICD_PHU;
                            //        }
                            //        else
                            //        {
                            //            dt_ICD_PHU.Clear();
                            //        }
                            //    }
                            //}
                            GetDataChiDinh();
                        }
                    }
                }
            }
            catch (Exception)
            {
                Utility.ShowMsg("Có lỗi trong quá trình lấy thông tin khám chữa bệnh");
            }
        }