Esempio n. 1
0
        private void SetValueforEntity()
        {
            Utility.ResetEntity(ref DataEntity);
            Utility.ResetEntity(ref PatientEntity);
            Utility.ResetEntity(ref RegDetailEntity);
            Utility.ResetEntity(ref RegEntity);
            string StudyInstanceUID = ClearCanvas.Dicom.DicomUid.GenerateUid().UID;
            //Create new Row
            DataRow dr0 = PatientEntity.NewRow();
            if (Act == action.Insert) dr0["Patient_ID"] = -1;
            else dr0["Patient_ID"] = Convert.ToInt16(dr["Patient_ID"]);
            dr0["PATIENT_CODE"] = AutoGenPID ? Utility.GetValue(txtID.Text, false) : Utility.GetValue(txtID.Text, false) + "_" + Utility.GetValue(txtRegID.Text, false);
            dr0["Patient_Name"] = Utility.GetValue(txtPName.Text, false).Replace(txtAge.Text.Trim(), "").Trim();
            dr0["PATIENT_NAME_UNSIGNED"] = Bodau(dr0["Patient_Name"].ToString());
            dr0["PATIENT_NAME_NOSPACE"] = dr0["PATIENT_NAME_UNSIGNED"].ToString().Replace(" ", "");
            dr0["Birth_Date"] = dtpBirthday.Value;
            dr0["Age"] = Utility.Int32Dbnull(txtAge.Text);
            dr0["sBirth_Date"] = dtpBirthday.Value.ToString("dd/MM/yyyy");
            //dr0["Doctor_Name"] = cboPhysician.Text;
            dr0["Sex"] = chkNam.ImageIndex == 0 ? 0 : (chkNu.ImageIndex == 0 ? 1 : 2);
            dr0["EMERGENCY"] = EMERGENCY ? 1 : 0;
            dr0["CREATED_BY"] = "DROC"; 
            PatientEntity.Rows.Add(dr0);
            PatientEntity.AcceptChanges();
          //Tao thong tin dang ky chup
            DataRow dr1 = RegEntity.NewRow();
            if (Act == action.Insert)
            {
                dr1["StudyInstanceUID"] = StudyInstanceUID;
                dr1["REG_ID"] = -1;
            }
            else dr1["REG_ID"] = Convert.ToInt64(dr["REG_ID"]);
            dr1["REG_NUMBER"] = Utility.GetValue(txtRegID.Text, false);
            dr1["PATIENT_ID"] = dr0["Patient_ID"];
            dr1["DESC"] = Utility.GetValue(txtDesc.Text, false);

            dr1["PROCEDURELIST"] = Utility.GetValue(txtProcedure.Text, false);
            dr1["PHYSICIAN"] = cboPhysician.SelectedValue.ToString();
            dr1["CREATED_DATE"] = dtpRegDate.Value;
            
            RegEntity.Rows.Add(dr1);
            RegEntity.AcceptChanges();
            DataTable dtDefaultAP = new ProcedureController().GetEmerencyData().Tables[0];
            //Lọc chỉ các dịch vụ được gửi từ worklistServer
            if (dtAP == null && dtDefaultAP != null && dtDefaultAP.Columns.Count > 0)
                dtAP = dtDefaultAP.Clone();
            if (dtAP != null && dtDefaultAP != null && dtAP.Columns.Count > 0 && dtDefaultAP.Columns.Count > 0)
            {
                try
                {
                    foreach (DataRow drDefaultAP in dtDefaultAP.Rows)
                    {
                        if (dtAP.Select("ANATOMY_CODE='" + drDefaultAP["ANATOMY_CODE"].ToString() + "' AND PROJECTION_CODE='" + drDefaultAP["PROJECTION_CODE"].ToString() + "'").Length <= 0)
                            dtAP.ImportRow(drDefaultAP);
                    }
                }
                catch
                {
                }
            }
            //Tao thong tin dang ky chup chi tiet
            if (dtAP != null)
            {
                int CurrIdx = 1;
                string SeriesInstanceUID = "";
                foreach (DataRow drAP in dtAP.Rows)
                {
                    DataRow dr2 = RegDetailEntity.NewRow();
                    SeriesInstanceUID = StudyInstanceUID + "." + CurrIdx.ToString();
                    CurrIdx++;
                    dr2["DETAIL_ID"] = -1;
                    dr2["UsingGrid"] = 0;
                    dr2["StudyInstanceUID"] = StudyInstanceUID;
                    //SeriesInstanceUID=StudyInstanceUID+Số thứ tự dịch vụ trong lần đăng ký đó
                    dr2["SeriesInstanceUID"] = SeriesInstanceUID;
                    //SOPInstanceUID=SeriesInstanceUID+Số lần chụp của dịch vụ đó
                    dr2["SOPInstanceUID"] = SeriesInstanceUID + ".1";
                    dr2["REG_ID"] = dr1["REG_ID"];
                    dr2["ANATOMY_CODE"] = drAP["ANATOMY_CODE"];
                    dr2["PROJECTION_CODE"] = drAP["PROJECTION_CODE"];
                    dr2["BODYSIZE_CODE"] = this.BODYSIZE_CODE;
                    //dr2["DISPLAY_NAME"] = arrProc[i].ToString().Split('#')[1];
                    //dr2["STANDARD_NAME"] = Convert.ToInt16(cboPhysician.SelectedValue);
                    dr2["STATUS"] = 0;
                    RegDetailEntity.Rows.Add(dr2);
                    RegDetailEntity.AcceptChanges();
                }
            }
            DataEntity.Tables.Add(PatientEntity);
            DataEntity.Tables.Add(RegEntity);
            DataEntity.Tables.Add(RegDetailEntity);
        }
Esempio n. 2
0
        void AddProcSearchedFromMWL(string Patient_Code)
        {
            try
            {
                DataTable APParams_DataSource = new DoctorController().GetAnatomyProjectionParams().Tables[0];
                if (m_dtAcquisitionDataSource == null || m_dtAcquisitionDataSource.Columns.Count <= 0 || m_dtAcquisitionDataSource.Rows.Count <= 0)
                {
                    m_dtAcquisitionDataSource = new RegDetailController().GetAllData(-1).Tables[0];
                }
                DataRow dr;
                m_dtAcquisitionDataSource.Rows.Clear();
                if (m_dtAcquisitionDataSource.Rows.Count > 0)
                {
                    dr = m_dtAcquisitionDataSource.Rows[0];
                    if (dr["reg_id"].ToString() == "-1") dr["REG_ID"] = currREGID;
                }
                else
                {
                    dr = m_dtAcquisitionDataSource.NewRow();

                    dr["STATUS"] = 0;
                    dr["IMGNAME"] = "";
                    dr["PRINTCOUNT"] = 0;
                    dr["EXPOSURECOUNT"] = 0;
                    dr["HOST"] = "127.0.0.1";
                    dr["UsingGrid"] = 0;
                    dr["IMGDATA"] = DBNull.Value;
                    dr["REG_NUMBER"] = txtRegNumber2.Text.Trim();
                    dr["REG_ID"] = currREGID;


                }
                DataTable dtAP = new DoctorController().GetAnatomyProjection(-1).Tables[0];
                DataTable dtDefaultAP = new ProcedureController().GetEmerencyData().Tables[0];
                //Lọc chỉ các dịch vụ được gửi từ worklistServer
                dtAP = GetAPfromMWL(dtAP, Patient_Code);
                if (dtAP != null && dtDefaultAP != null && dtAP.Columns.Count > 0 && dtDefaultAP.Columns.Count > 0)
                {
                    try
                    {
                        foreach (DataRow drDefaultAP in dtDefaultAP.Rows)
                        {
                            if (dtAP.Select("ANATOMY_CODE='" + drDefaultAP["ANATOMY_CODE"].ToString() + "' AND PROJECTION_CODE='" + drDefaultAP["PROJECTION_CODE"].ToString() + "'").Length <= 0)
                                dtAP.ImportRow(drDefaultAP);
                        }
                    }
                    catch
                    {
                    }
                }
                DataRow newdr = m_dtAcquisitionDataSource.NewRow();
                Utility.CopyData(dr, ref newdr);
                if (dtAP != null)
                {
                    string SeriesInstanceUID = "";
                    foreach (DataRow drAP in dtAP.Rows)
                    {
                        RegDetailInfor infor = new RegDetailInfor();

                        int NextSeriesInstanceUID = MaxSeriesInstanceUID + 1;
                        SeriesInstanceUID = CurrStudyInstanceUID + "." + NextSeriesInstanceUID.ToString();
                        MaxSeriesInstanceUID = NextSeriesInstanceUID;
                        newdr["DETAIL_ID"] = -1;
                        //SeriesInstanceUID=StudyInstanceUID+Số thứ tự dịch vụ trong lần đăng ký đó
                        newdr["SeriesInstanceUID"] = SeriesInstanceUID;
                        //SOPInstanceUID=SeriesInstanceUID+Số lần chụp của dịch vụ đó. 
                        //SOPInstanceUID chỉ thay đổi khi dịch vụ này đang có ảnh và lại được chụp lại
                        newdr["SOPInstanceUID"] = SeriesInstanceUID + ".1";
                        newdr["REG_ID"] = dr["REG_ID"];
                        newdr["ANATOMY_CODE"] = drAP["ANATOMY_CODE"];
                        newdr["BODYSIZE_CODE"] = BODYSIZE_CODE;
                        newdr["UsingGrid"] = 0;
                        newdr["PROJECTION_CODE"] = drAP["PROJECTION_CODE"];
                        newdr["DISPLAY_NAME"] = drAP["ANATOMY_CODE"];
                        newdr["STANDARD_NAME"] = drAP["ANATOMY_CODE"];
                        newdr["DirectionCapture"] = 0;
                        newdr["STATUS"] = 0;
                        newdr["STATUS_NAME"] = "";
                        Utility.MapValueFromEntityIntoObjectInfor(infor, newdr);
                        if (new RegDetailController(infor).Insert() == ActionResult.Success)
                        {
                            newdr["DETAIL_ID"] = infor.DETAIL_ID;
                            decimal _kVp = 0M;
                            int _mA = 0;
                            int _mAs = 0;
                            GetAPParams(APParams_DataSource, infor.ANATOMY_CODE, infor.PROJECTION_CODE, infor.BODYSIZE_CODE, ref _kVp, ref _mA, ref _mAs);
                            //Add new Scheduled Control
                            ScheduledControl _Scheduled = new ScheduledControl(txtImgDir.Text.Trim() + @"\" + txtRegNumber2.Text.Trim() + "_" + infor.DETAIL_ID.ToString(), (int)infor.REG_ID, (int)infor.DETAIL_ID, CurrStudyInstanceUID, SeriesInstanceUID, newdr["SOPInstanceUID"].ToString(), infor.ANATOMY_CODE, infor.PROJECTION_CODE, infor.BODYSIZE_CODE, Utility.sDbnull(drAP["VN_ANATOMY_NAME"], ""), Utility.sDbnull(drAP["EN_ANATOMY_NAME"], ""), Utility.sDbnull(drAP["VN_PROJECTION_NAME"], ""), Utility.sDbnull(drAP["EN_PROJECTION_NAME"], ""), BODYSIZE_NAME, BODYSIZE_NAME, _kVp, _mA, _mAs, Utility.Int32Dbnull(drAP["A_STT"], 0), Utility.Int32Dbnull(drAP["P_STT"], 0), Utility.Int32Dbnull(dr["PRINTCOUNT"], 0), 0);
                            _Scheduled._OnClick += new ScheduledControl.OnClick(_ScheduledControl__OnClick);
                            _Scheduled.ContextMenuStrip = ctx;
                            _Scheduled._OnNewScheduleClick += new ScheduledControl.OnNewScheduleClick(_ScheduledControl__OnNewScheduleClick);
                            _Scheduled._OnRejectScheduleClick += new ScheduledControl.OnRejectScheduleClick(_ScheduledControl__OnRejectScheduleClick);
                            _Scheduled._OnDelScheduleClick += new ScheduledControl.OnDelScheduleClick(_ScheduledControl__OnDelScheduleClick);

                            _Scheduled._OnNewScheduleDoubleClick += new ScheduledControl.OnNewScheduleDoubleClick(_ScheduledControl__OnNewScheduleDoubleClick);
                            _Scheduled._OnRejectScheduleDoubleClick += new ScheduledControl.OnRejectScheduleDoubleClick(_ScheduledControl__OnRejectScheduleDoubleClick);
                            _Scheduled._OnDelScheduleDoubleClick += new ScheduledControl.OnDelScheduleDoubleClick(_ScheduledControl__OnDelScheduleDoubleClick);



                            _Scheduled._OnKeyDown += new ScheduledControl.OnKeyDown(_ScheduledControl__OnKeyDown);
                            pnlScheduled.Controls.Add(_Scheduled);
                        }

                        m_dtAcquisitionDataSource.Rows.Add(newdr);
                        m_dtAcquisitionDataSource.AcceptChanges();
                        newdr = m_dtAcquisitionDataSource.NewRow();
                    }
                }


                if (!AcquisitionFromWL)
                {
                    //string[] Img = Utility.sDbnull(currentStudyRow["Img"]).Split('/');
                    //currentStudyRow["Img"] = Img[0] + "/" + (Convert.ToInt64(Img[1]) + _newForm.arrProc.Count).ToString();
                    //currentStudyRow["Img1"] = currentStudyRow["Img"];
                }
                //Update Procedure List to DB and Datasource
                string ProcedureList = GetProcedureList();
                new RegDetailController().UpdateProcedureList(Convert.ToInt64(dr["REG_ID"]), ProcedureList);
                //Update Dataset
                DataRow[] drWL = m_dtWLDataSource.Select("Reg_ID=" + Convert.ToInt64(dr["REG_ID"]));
                DataRow[] drST = m_dtStudyListDataSource.Select("Reg_ID=" + Convert.ToInt64(dr["REG_ID"]));
                if (drWL.Length > 0)
                    drWL[0]["ProcedureList"] = ProcedureList;
                if (drST.Length > 0)
                    drST[0]["ProcedureList"] = ProcedureList;
                m_dtWLDataSource.AcceptChanges();
                m_dtStudyListDataSource.AcceptChanges();

            }
            catch
            {
            }

        }
Esempio n. 3
0
        public void CreateEmerency()
        {
            try
            {
                action Act = action.Insert;
                DataTable dtPhysician = new DoctorController().GetAllData().Tables[0];
                if (dtPhysician == null || dtPhysician.Rows.Count <= 0)
                {
                    new frm_LargeMsgBoxOK(MultiLanguage.GetText(globalVariables.DisplayLanguage, "Thông báo", "Warning"), MultiLanguage.GetText(globalVariables.DisplayLanguage, "Đề nghị tạo danh mục bác sĩ trước khi thêm BN cấp cứu!", "Pls create Doctor list before add Emerency"), MultiLanguage.GetText(globalVariables.DisplayLanguage, "ĐỒNG Ý", "I see"), MultiLanguage.GetText(globalVariables.DisplayLanguage, "HỦY BỎ", "Cancel")).ShowDialog();
                    return;
                }
                DataSet dsEmerencyDataEntity = new DataSet();
                DataTable EmerencyPatientEntity = new PatientEntity.PatientEntityDataTable();
                DataTable EmerencyRegEntity = new RegEntity.RegEntityDataTable();
                DataTable EmerencyRegDetailEntity = new RegDetailEntity.RegDetailEntityDataTable();

                Utility.ResetEntity(ref dsEmerencyDataEntity);
                Utility.ResetEntity(ref EmerencyPatientEntity);
                Utility.ResetEntity(ref EmerencyRegDetailEntity);
                Utility.ResetEntity(ref EmerencyRegEntity);
                //Create new Row
                string PID = Utility.GetYYYYMMDDHHMMSS(DateTime.Now);
                DataRow dr0 = EmerencyPatientEntity.NewRow();
                dr0["Patient_ID"] = -1;
                dr0["Age"] = 20;

                dr0["PATIENT_CODE"] = Utility.GetValue(PID, false);
                dr0["Patient_Name"] = "Bệnh nhân cấp cứu vào lúc " + PID;
                dr0["Birth_Date"] = DateTime.Now.AddYears(-20);
                dr0["sBirth_Date"] = DateTime.Now.AddYears(-20).ToString("dd/MM/yyyy");
                //dr0["Doctor_Name"] = cboPhysician.Text;
                dr0["Sex"] = 0;//Mặc định là Male
                dr0["EMERGENCY"] = 1;//BN cấp cứu

                EmerencyPatientEntity.Rows.Add(dr0);
                EmerencyPatientEntity.AcceptChanges();
                //Tao thong tin dang ky chup
                DataRow dr1 = EmerencyRegEntity.NewRow();
                dr1["REG_ID"] = -1;
                //dr1["REGSTATUS"] = 1;
                dr1["REG_NUMBER"] = dr0["PATIENT_CODE"];
                dr1["PATIENT_ID"] = dr0["Patient_ID"];
                //dr1["DESC"] = Utility.GetValue("Bệnh nhân cấp cứu cần chụp ngay", false);
                DataTable dtAP = new ProcedureController().GetEmerencyData().Tables[0];
                DataSet dsEmerencyDoctor = new DoctorController().GetEmerencyData();
                ArrayList Emerency_arrProc = new ArrayList();
                string ProcList = "";

                int totalProc = 0;
                if (dtAP == null || dtAP.Rows.Count <= 0)
                {
                    frm_Choose_Anotomy_Projection _Choose_Anotomy_Projection = new frm_Choose_Anotomy_Projection(-1);
                    if (_Choose_Anotomy_Projection.ShowDialog() == DialogResult.OK)
                    {
                        dtAP = _Choose_Anotomy_Projection.AP_DataSource.Select("CHON=1").CopyToDataTable();
                        ProcList = GetProcedureEmerency(dtAP);
                        dr1["PROCEDURELIST"] = ProcList;
                    }
                }
                else
                {
                    //Update Procedure List to DB and Datasource
                    ProcList = GetProcedureEmerency(dtAP);
                    dr1["PROCEDURELIST"] = ProcList;
                }
                //Tự động gán bác sĩ cấp cứu
                if (dsEmerencyDoctor != null && dsEmerencyDoctor.Tables.Count > 0 && dsEmerencyDoctor.Tables[0].Rows.Count > 0)
                    dr1["PHYSICIAN"] = dsEmerencyDoctor.Tables[0].Rows[0]["DOCTOR_CODE"].ToString();
                else
                    dr1["PHYSICIAN"] = dtPhysician.Rows[0]["DOCTOR_CODE"].ToString();
                dr1["CREATED_DATE"] = DateTime.Now;

                EmerencyRegEntity.Rows.Add(dr1);
                EmerencyRegEntity.AcceptChanges();

                //Tao thong tin dang ky chup chi tiet
                if (dtAP != null)
                {
                    foreach (DataRow drAP in dtAP.Rows)
                    {
                        DataRow dr2 = EmerencyRegDetailEntity.NewRow();
                        dr2["DETAIL_ID"] = -1;
                        dr2["REG_ID"] = dr1["REG_ID"];
                        dr2["ANATOMY_CODE"] = drAP["ANATOMY_CODE"];
                        dr2["PROJECTION_CODE"] = drAP["PROJECTION_CODE"];
                        dr2["STATUS"] = 0;
                        totalProc += 1;
                        EmerencyRegDetailEntity.Rows.Add(dr2);
                        EmerencyRegDetailEntity.AcceptChanges();
                    }
                }
                dsEmerencyDataEntity.Tables.Add(EmerencyPatientEntity);
                dsEmerencyDataEntity.Tables.Add(EmerencyRegEntity);
                dsEmerencyDataEntity.Tables.Add(EmerencyRegDetailEntity);

                //Now AutoSave Emerency Patient
                WLRules _BusRule = new WLRules();
                //Gọi nghiệp vụ Insert dữ liệu
                PatientInfor _PatientInfor = new PatientInfor();
                RegInfor _RegInfor = new RegInfor();
                ActionResult InsertResult = _BusRule.Insert(dsEmerencyDataEntity, _PatientInfor, _RegInfor);
                if (InsertResult == ActionResult.Success)//Nếu thành công
                {
                    //Thêm mới một dòng vào Datasource để cập nhật lại dữ liệu trên DataGridView
                    //phải đảm bảo Datasource và RoomEntity có cấu trúc giống nhau mới dùng hàm này
                    DataRow newRow = m_dtWLDataSource.NewRow();
                    newRow["Patient_ID"] = _PatientInfor.Patient_ID;
                    newRow["PATIENT_CODE"] = Utility.GetValue(PID, false);
                    newRow["Patient_Name"] = "Bệnh nhân cấp cứu vào lúc " + PID;
                    newRow["Birth_Date"] = DateTime.Now.AddYears(-20);
                    newRow["sBirth_Date"] = DateTime.Now.AddYears(-20).ToShortDateString();
                    newRow["Sex"] = 0;
                    newRow["Age"] = 0;
                    newRow["EMERGENCY"] = 20;
                    newRow["REG_ID"] = _RegInfor.REG_ID;
                    newRow["REG_NUMBER"] = newRow["PATIENT_CODE"];
                    newRow["REGSTATUS"] = 1;
                    newRow["PROCEDURELIST"] = ProcList;
                    if (dsEmerencyDoctor != null && dsEmerencyDoctor.Tables.Count > 0 && dsEmerencyDoctor.Tables[0].Rows.Count > 0)
                    {
                        newRow["PHYSICIAN"] = dsEmerencyDoctor.Tables[0].Rows[0]["DOCTOR_CODE"].ToString();
                        newRow["Doctor_Name"] = dsEmerencyDoctor.Tables[0].Rows[0]["DOCTOR_Name"].ToString();
                    }
                    else
                    {
                        newRow["PHYSICIAN"] = dtPhysician.Rows[0]["DOCTOR_CODE"].ToString();
                        newRow["Doctor_Name"] = dtPhysician.Rows[0]["DOCTOR_Name"].ToString();
                    }

                    newRow["CREATED_DATE"] = DateTime.Now;
                    newRow["sCREATED_DATE"] = DateTime.Now.ToShortDateString();
                    newRow["SEX_NAME"] = "Male";
                    newRow["CanDel"] = 1;
                    newRow["HasProcessed"] = 0;
                    newRow["NoneProcessed"] = 1;
                    newRow["TotalProc"] = totalProc;
                    if (newRow != null)//99.99% là sẽ !=null
                    {
                        m_dtWLDataSource.Rows.Add(newRow);
                        m_dtWLDataSource.AcceptChanges();
                    }
                    //Return to the InitialStatus
                    Act = action.FirstOrFinished;


                    //Tự động Suspending Bệnh nhân đang được chọn ở mục Acquisition
                    SuspendCurrentPatient();

                    //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.GotoNewRow(grdWorkList, "colPatient_ID", _PatientInfor.Patient_ID.ToString());
                    //Tự động chuyển BN cấp cứu vào phần Acquisition
                    BeginExam();
                }
                else//Có lỗi xảy ra
                {
                    switch (InsertResult)
                    {
                        case ActionResult.ExistedRecord:
                            mdlStatic.SetMsg(lblMsg, "Lỗi trong khi tạo Bệnh nhân cấp cứu!\nĐã tồn tại Bệnh nhân có mã: " + _PatientInfor.Patient_Code + ". Đề nghị bạn xem lại", true);
                            //Utility.FocusAndSelectAll(txtID);
                            break;
                        default:
                            mdlStatic.SetMsg(lblMsg, "Lỗi trong quá trình thêm mới Bệnh nhân cấp cứu. Liên hệ với VBIT", true);
                            break;
                    }
                }

            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
Esempio n. 4
0
        private void ExecuteAction()
        {
            //Kiểm tra tính hợp lệ của dữ liệu trước khi thêm mới
            if (!IsValidData())
            {
                return;
            }
            //Gán ProcedureEntity vào DataEntity
            SetValueforEntity();

            //Khởi tạo BusinessRule để xử lý nghiệp vụ
            ProcedureInfor Infor = new ProcedureInfor();
            Utility.MapValueFromEntityIntoObjectInfor(Infor, ProcedureEntity);
            ProcedureController _BusRule = new ProcedureController(Infor);
            switch (Act)
            {
                case action.Insert:
                    //Gọi nghiệp vụ Insert dữ liệu
                    ActionResult InsertResult = _BusRule.Insert();
                    if (InsertResult == ActionResult.Success)//Nếu thành công
                    {
                        //Thêm mới một dòng vào Datasource để cập nhật lại dữ liệu trên DataGridView
                        //phải đảm bảo Datasource và ProcedureEntity có cấu trúc giống nhau mới dùng hàm này
                        DataRow dr = Utility.CopyData(ProcedureEntity.Rows[0], DataSource);
                        dr["Procedure_ID"] = Infor.Procedure_ID;
                        if (dr != null)//99.99% là sẽ !=null
                        {
                            DataSource.Rows.Add(dr);
                            DataSource.AcceptChanges();
                        }
                        //Thêm vào treeView
                         string Code =Infor.Procedure_Code;
                         string newText = "";
                         if (Code.Trim() != "")
                             newText = Code + "-" + Infor.DISPLAY_NAME;
                         else
                             newText = Infor.DISPLAY_NAME;

                         TreeNode newNode = new TreeNode(newText);
                         if (tvwProcedure.SelectedNode.Tag.ToString().Contains("ROOT"))
                         {
                             newNode.Tag = Infor.Procedure_ID.ToString() + "#PARENT";
                             newNode.ForeColor = System.Drawing.Color.DarkBlue;
                         }
                         else
                         {
                             newNode.Tag = Infor.Procedure_ID.ToString() + "#LEAF$" + Infor.Pos.ToString();
                             newNode.ForeColor = System.Drawing.Color.Black;

                         }
                         newNode.NodeFont = new Font("Microsoft Sans Serif", 9, FontStyle.Bold, GraphicsUnit.Point);
                         tvwProcedure.SelectedNode.Nodes.Add(newNode);
                         tvwProcedure.SelectedNode.Expand();
                        //Return to the InitialStatus
                        Act = 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
                       mdlStatic.SetMsg(lblMsg,"Thêm mới dữ liệu thành công!",false);

                        SetControlStatus();
                        SelecttionChanged();
                    }
                    else//Có lỗi xảy ra
                    {
                        switch (InsertResult)
                        {
                            case ActionResult.ExistedRecord:
                                mdlStatic.SetMsg(lblMsg, "Đã tồn tại Vị trí có mã: " + txtCode.Text.Trim() + ". Đề nghị bạn xem lại",true);
                               Utility.FocusAndSelectAll( txtCode);
                                break;
                            default:
                               mdlStatic.SetMsg(lblMsg,"Lỗi trong quá trình thêm mới Vị trí. Liên hệ với VBIT",true);
                                break;
                        }
                    }
                    break;
                case action.Update:
                    //Gọi Business cập nhật dữ liệu
                    ActionResult UpdateResult = _BusRule.Update();
                    if (UpdateResult == ActionResult.Success)//Nếu thành công
                    {
                        //Cập nhật số thứ tự cho bản ghi tráo số thứ tự với bản ghi đang được cập nhật(nếu có)?
                        foreach (DataRow drUpdatePos in DataSource.Rows)
                        {
                            if (Utility.Int16Dbnull(drUpdatePos["Pos"]) == Convert.ToInt16(txtPos.Text))
                            {
                                drUpdatePos["Pos"] = OldPos;
                                break; // TODO: might not be correct. Was : Exit For
                            }
                        }
                        DataSource.AcceptChanges();
                        //Cập nhật dòng hiện thời trong Datasource để cập nhật lại dữ liệu trên DataGridView
                        DataRow dr = Utility.GetDataRow(DataSource, "Procedure_ID", txtID.Text.Trim());
                        if (dr != null)
                        {
                            Utility.CopyData(ProcedureEntity.Rows[0], ref dr);
                            DataSource.AcceptChanges();
                        }
                        string Code = Infor.Procedure_Code;
                        string newText = "";
                        if (Code.Trim() != "")
                            newText = Code + "-" + Infor.DISPLAY_NAME;
                        else
                            newText = Infor.DISPLAY_NAME;

                        tvwProcedure.SelectedNode.Text=newText;
                        if (tvwProcedure.SelectedNode.Tag.ToString().Contains("PARENT"))
                            tvwProcedure.SelectedNode.Tag = Infor.Procedure_ID.ToString() + "#PARENT$" + Infor.Pos.ToString();
                        else
                            tvwProcedure.SelectedNode.Tag = Infor.Procedure_ID.ToString() + "#LEAF$" + Infor.Pos.ToString();
                        //Return to the InitialStatus
                        Act = 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.GotoNewRow(grdList, "colProcedure_ID", txtCode.Text.Trim());
                       mdlStatic.SetMsg(lblMsg,"Cập nhật dữ liệu thành công.",false);
                        SetControlStatus();
                        SelecttionChanged();
                    }
                    else//Có lỗi xảy ra
                    {
                        switch (UpdateResult)
                        {
                            case ActionResult.Error:
                               mdlStatic.SetMsg(lblMsg,"Lỗi khi cập nhật Vị trí. Liên hệ với VBIT",true);
                                break;
                            default:
                               mdlStatic.SetMsg(lblMsg,"Lỗi khi cập nhật Vị trí. Liên hệ với VBIT",true);
                                break;
                        }
                    }
                    break;

                case action.Delete:
                    if (Utility.AcceptQuestion("Bạn có muốn xóa Vị trí đang chọn hay không?", "Xác nhận xóa", true))
                    {
                        string Procedure_ID = txtID.Text.Trim();
                        //Gọi nghiệp vụ xóa dữ liệu
                        ActionResult DeleteResult = _BusRule.Delete();
                        if (DeleteResult == ActionResult.Success)//Nếu xóa thành công trong CSDL
                        {
                            //Xóa dòng dữ liệu vừa chọn trong Datasource để cập nhật lại dữ liệu trên DataGridView
                            DataRow dr = Utility.GetDataRow(DataSource, "Procedure_ID", Procedure_ID);
                            if (dr != null)
                            {
                                DataSource.Rows.Remove(dr);
                                DataSource.AcceptChanges();
                            }
                            //remove khỏi TreeView
                            tvwProcedure.Nodes.Remove(tvwProcedure.SelectedNode);
                            //Return to the InitialStatus
                            Act = action.FirstOrFinished;
                            mdlStatic.SetMsg(lblMsg, "Đã xóa Vị trí có ID: " + Procedure_ID + " ra khỏi hệ thống.", false);
                            SetControlStatus();
                            SelecttionChanged();
                        }
                        else//Có lỗi xảy ra
                        {
                            switch (DeleteResult)
                            {
                                case ActionResult.DataHasUsedinAnotherTable:
                                    mdlStatic.SetMsg(lblMsg, "Vị trí có ID: " + Procedure_ID + " đã được sử dụng trong bảng khác nên bạn không thể xóa!", true);
                                    break;
                                default:
                                   mdlStatic.SetMsg(lblMsg,"Lỗi khi xóa Vị trí. Liên hệ với VBIT",true);
                                    break;
                            }
                        }
                    }
                    break;
                default:
                    break;
            }
        }
Esempio n. 5
0
 public  string GetCode(Int16 ID)
 {
     DataSet ds = new ProcedureController().GetData("Procedure_ID=" + ID);
     ProcedureInfor Infor = new ProcedureInfor();
     if (ds != null)
     {
         if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
         {
             return ds.Tables[0].Rows[0]["Procedure_Code"].ToString();
         }
         else
         {
             return "Undefined";
         }
     }
     else
     {
         return "Undefined";
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Trả về đối tượng Infor dựa vào Primary key của nó
 /// </summary>
 /// <param name="ID"></param>
 /// <returns></returns>
 public static ProcedureInfor GetInfor(Int16 ID)
 {
     DataSet ds = new ProcedureController().GetData("Procedure_ID=" + ID );
     ProcedureInfor Infor = new ProcedureInfor();
     if (ds != null)
     {
         if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
         {
             Infor.Procedure_Code = Utility.sDbnull(ds.Tables[0].Rows[0]["Procedure_Code"]);
             Infor.Procedure_ID = Utility.Int16Dbnull(ds.Tables[0].Rows[0]["Procedure_ID"]);
             Infor.Parent_ID = Utility.Int16Dbnull(ds.Tables[0].Rows[0]["Parent_ID"]);
             Infor.DISPLAY_NAME = Utility.sDbnull(ds.Tables[0].Rows[0]["DISPLAY_NAME"]);
             Infor.STANDARD_NAME = Utility.sDbnull(ds.Tables[0].Rows[0]["STANDARD_NAME"]);
             Infor.MODALITY_ID = Utility.Int16Dbnull(ds.Tables[0].Rows[0]["MODALITY_ID"]);
             Infor.MODALITY_Name = Utility.sDbnull(ds.Tables[0].Rows[0]["MODALITY_Name"]);
             Infor.PRICE = Utility.fDbnull(ds.Tables[0].Rows[0]["PRICE"]);
             Infor.Pos = Utility.Int16Dbnull(ds.Tables[0].Rows[0]["Pos"]);
             Infor.IsEmerency = Utility.Int16Dbnull(ds.Tables[0].Rows[0]["IsEmerency"]);
             Infor.Desc = Utility.sDbnull(ds.Tables[0].Rows[0]["Desc"]);
             Infor.DirectionCapture = Convert.ToByte(ds.Tables[0].Rows[0]["DirectionCapture"]);
             return Infor;
         }
         else
         {
             return null;
         }
     }
     else
     {
         return null;
     }
 }