コード例 #1
0
        private void BtnRotate_Click(object sender, EventArgs e)
        {
            //throw new NotImplementedException();
            String dgs = "", id = "";

            try
            {
                filename = filename.Substring(filename.IndexOf('*') + 1);
                //Image img=null;
                //img.Save(stream, ImageFormat.Jpeg);
                //resizedImage = bc.RotateImage(img);
                img1 = bc.RotateImage(img1);
                //img.Dispose();
                //if (File.Exists(filename))
                //{
                //    File.Delete(filename);
                //}
                //img1.Save(filename);
                //Bitmap bmp;
                //bmp = (Bitmap)img1;
                //bmp.Save(filename, System.Drawing.Imaging.ImageFormat.Jpeg);
                //Image img2 = Image.FromFile(filename);
                pic1.Image = img1;
                //pnImg.Width = img1.
            }
            catch (Exception ex)
            {
                dgs = ex.Message;
            }
        }
コード例 #2
0
        private void BtnSaveRotate_Click(object sender, EventArgs e)
        {
            //throw new NotImplementedException();
            Stream stream = new MemoryStream();

            pic1.Image.Save(stream, ImageFormat.Jpeg);

            DocScan dsc = new DocScan();

            dsc             = bc.bcDB.dscDB.castDocScan(dgs);
            dsc.doc_scan_id = "";
            string ext = Path.GetExtension(dgs.image_path);

            String re = bc.bcDB.dscDB.insertDocScan(dsc, "");

            dsc.image_path = txtHn.Text.Replace("/", "-") + "//" + txtHn.Text.Replace("/", "-") + "-" + vn.Replace("/", "_").Replace("(", "_").Replace(")", "") + "//" + txtHn.Text.Replace("/", "-") + "-" + vn.Replace("/", "_").Replace("(", "_").Replace(")", "") + "-" + re + ext;         //+1
            int chk = 0;

            if (int.TryParse(re, out chk))
            {
                String    re1 = bc.bcDB.dscDB.updateImagepath(dsc.image_path, re);
                FtpClient ftp = new FtpClient(bc.iniC.hostFTP, bc.iniC.userFTP, bc.iniC.passFTP, bc.ftpUsePassive);
                stream.Seek(0, SeekOrigin.Begin);
                //MessageBox.Show(bc.iniC.folderFTP + "//" + dsc.image_path, "");
                Boolean chk1 = ftp.upload(bc.iniC.folderFTP + "//" + dsc.image_path, stream);

                bc.bcDB.dscDB.voidDocScan(dgs.doc_scan_id, "");
                MessageBox.Show("save file Rotate to seerver success", "");
            }
        }
コード例 #3
0
ファイル: DocScanDB.cs プロジェクト: eploentham/clinic_ivf
        private void chkNull(DocScan p)
        {
            long chk = 0;

            p.date_modi   = p.date_modi == null ? "" : p.date_modi;
            p.date_cancel = p.date_cancel == null ? "" : p.date_cancel;
            p.user_create = p.user_create == null ? "" : p.user_create;
            p.user_modi   = p.user_modi == null ? "" : p.user_modi;
            p.user_cancel = p.user_cancel == null ? "" : p.user_cancel;

            p.host_ftp      = p.host_ftp == null ? "" : p.host_ftp;
            p.image_path    = p.image_path == null ? "" : p.image_path;
            p.hn            = p.hn == null ? "" : p.hn;
            p.vn            = p.vn == null ? "" : p.vn;
            p.visit_date    = p.visit_date == null ? "" : p.visit_date;
            p.remark        = p.remark == null ? "" : p.remark;
            p.an            = p.an == null ? "" : p.an;
            p.pre_no        = p.pre_no == null ? "" : p.pre_no;
            p.an_date       = p.an_date == null ? "" : p.an_date;
            p.status_ipd    = p.status_ipd == null ? "" : p.status_ipd;
            p.an_cnt        = p.an_cnt == null ? "" : p.an_cnt;
            p.folder_ftp    = p.folder_ftp == null ? "" : p.folder_ftp;
            p.status_record = p.status_record == null ? "0" : p.status_record;

            p.doc_group_id     = long.TryParse(p.doc_group_id, out chk) ? chk.ToString() : "0";
            p.row_no           = long.TryParse(p.row_no, out chk) ? chk.ToString() : "0";
            p.doc_group_sub_id = long.TryParse(p.doc_group_sub_id, out chk) ? chk.ToString() : "0";
            //p.pre_no = int.TryParse(p.pre_no, out chk) ? chk.ToString() : "0";
            //p.doctor_id = int.TryParse(p.doctor_id, out chk) ? chk.ToString() : "0";
        }
コード例 #4
0
ファイル: DocScanDB.cs プロジェクト: eploentham/clinic_ivf
        private void initConfig()
        {
            dsc  = new DocScan();
            lDgs = new List <DocScan>();

            dsc.doc_scan_id      = "doc_scan_id";
            dsc.doc_group_id     = "doc_group_id";
            dsc.row_no           = "row_no";
            dsc.host_ftp         = "host_ftp";
            dsc.image_path       = "image_path";
            dsc.hn               = "hn";
            dsc.vn               = "vn";
            dsc.visit_date       = "visit_date";
            dsc.active           = "active";
            dsc.remark           = "remark";
            dsc.date_create      = "date_create";
            dsc.date_modi        = "date_modi";
            dsc.date_cancel      = "date_cancel";
            dsc.user_create      = "user_create";
            dsc.user_modi        = "user_modi";
            dsc.user_cancel      = "user_cancel";
            dsc.an               = "an";
            dsc.doc_group_sub_id = "doc_group_sub_id";
            dsc.pre_no           = "pre_no";
            dsc.an_date          = "an_date";
            dsc.status_ipd       = "status_ipd";
            dsc.an_cnt           = "an_cnt";
            dsc.folder_ftp       = "folder_ftp";
            dsc.status_record    = "status_record";

            dsc.table   = "t_doc_scan";
            dsc.pkField = "doc_scan_id";
        }
コード例 #5
0
        private void BtnGenSort_Click(object sender, EventArgs e)
        {
            //throw new NotImplementedException();
            DataTable dataTable1 = new DataTable();
            DataTable dataTable2 = this.bc.bcDB.dscDB.selectByAnSortID(((Control)this.txtHn).Text, ((Control)this.txtAn).Text);

            if (dataTable2.Rows.Count <= 0)
            {
                return;
            }
            long result1 = 0;

            if (long.TryParse(dataTable2.Rows[0][this.bc.bcDB.dscDB.dsc.sort1].ToString(), out result1))
            {
                int num = 0;
                foreach (DataRow row in (InternalDataCollectionBase)dataTable2.Rows)
                {
                    ++num;
                    int result2 = 0;
                    if (!int.TryParse(this.bc.bcDB.dscDB.updateSort(row[this.bc.bcDB.dscDB.dsc.doc_scan_id].ToString(), num.ToString()), out result2))
                    {
                        ;
                    }
                }
                DocScan docScan1 = new DocScan();
                DocScan docScan2 = this.bc.bcDB.dscDB.selectByPk(((Control)this.txtID).Text);
                txtSort.Value = docScan2.sort1;
                txtSort.Value = docScan2.sort1;
            }
        }
コード例 #6
0
ファイル: DocScanDB.cs プロジェクト: eploentham/clinic_ivf
 public DocScan setDocGroupScan(DocScan dgs1)
 {
     dgs1.doc_scan_id      = "";
     dgs1.doc_group_id     = "";
     dgs1.row_no           = "";
     dgs1.host_ftp         = "";
     dgs1.image_path       = "";
     dgs1.hn               = "";
     dgs1.vn               = "";
     dgs1.visit_date       = "";
     dgs1.active           = "";
     dgs1.remark           = "";
     dgs1.date_create      = "";
     dgs1.date_modi        = "";
     dgs1.date_cancel      = "";
     dgs1.user_create      = "";
     dgs1.user_modi        = "";
     dgs1.user_cancel      = "";
     dgs1.an               = "";
     dgs1.doc_group_sub_id = "";
     dgs1.pre_no           = "";
     dgs1.an_date          = "";
     dgs1.status_ipd       = "";
     dgs1.an_cnt           = "";
     dgs1.folder_ftp       = "";
     dgs1.status_record    = "";
     return(dgs1);
 }
コード例 #7
0
        private static void RecognizeWithFCProcessor(string pathFolderWork, string pathFlderTmplates, string[] manyImages, bool loadInproc = true)
        {
            var outProcRecognizing = new DocScan();

            try
            {
                if (loadInproc)
                {
                    outProcRecognizing.SetInprocLoading();
                }

                if (!outProcRecognizing.LoadEngine())
                {
                    PrintConsole(outProcRecognizing.GetErrorText());
                }

                // отображение версий шаблонов
                outProcRecognizing.SetTemplatesDirectory(pathFlderTmplates);

                // установить режим предобработки изображений
                outProcRecognizing.SetImagePreproccesingMode(_modePreprocessingImage);

                Console.WriteLine("Версия компоненты распознавания:");
                Console.WriteLine(outProcRecognizing.GetComponentVersion());

                Console.WriteLine("Версии шаблонов распознавания: ");
                string nameTmplte = outProcRecognizing.GetTemplateVersion();
                Console.WriteLine(nameTmplte);
                while (!String.IsNullOrEmpty(nameTmplte))
                {
                    nameTmplte = outProcRecognizing.GetTemplateVersion();
                    Console.WriteLine(nameTmplte);
                }

                foreach (string image in manyImages)
                {
                    outProcRecognizing.AddImage(image);
                }
                try
                {
                    Console.WriteLine("Идет распознавание...");
                    outProcRecognizing.RecognizeFiles(pathFolderWork, pathFlderTmplates);
                } catch (Exception ex)
                {
                    string tt = ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine + outProcRecognizing.GetErrorText();
                    PrintConsole(tt);
                }

                outProcRecognizing.UnloadEngine();
            }
            catch (Exception ex)
            {
                _errorText  = "Сбой распознавания: " + ex.Message;
                _errorText += Environment.NewLine + outProcRecognizing.GetErrorText();
                _errorText += Environment.NewLine + ex.StackTrace;
                _errorText += Environment.NewLine + "Images:" + String.Join(" ", manyImages);
                PrintConsole(_errorText);
            }
        }
コード例 #8
0
ファイル: DocScanDB.cs プロジェクト: eploentham/clinic_ivf
        public DataTable selectByVn(String hn, String an)
        {
            DocScan   cop1 = new DocScan();
            DataTable dt   = new DataTable();
            String    sql  = "select * " +
                             "From " + dsc.table + " dsc " +
                             //"Left Join f_patient_prefix pfx On stf.prefix_id = pfx.f_patient_prefix_id " +
                             "Where dsc." + dsc.hn + " ='" + hn + "' and dsc." + dsc.vn + "='" + an + "' and dsc." + dsc.active + "='1'" +
                             "Order By doc_group_id ";

            dt = conn.selectData(conn.conn, sql);

            return(dt);
        }
コード例 #9
0
ファイル: DocScanDB.cs プロジェクト: eploentham/clinic_ivf
        public DataTable selectByPk1(String id)
        {
            DocScan   cop1 = new DocScan();
            DataTable dt   = new DataTable();
            String    sql  = "select * " +
                             "From " + dsc.table + " dsc " +
                             //"Left Join f_patient_prefix pfx On stf.prefix_id = pfx.f_patient_prefix_id " +
                             "Where dsc." + dsc.pkField + " ='" + id + "' " +
                             "Order By doc_group_id ";

            dt = conn.selectData(conn.conn, sql);

            return(dt);
        }
コード例 #10
0
ファイル: DocScanDB.cs プロジェクト: eploentham/clinic_ivf
        public String insertDocScan(DocScan p, String userId)
        {
            String re = "";

            if (p.doc_scan_id.Equals(""))
            {
                re = insert(p, userId);
            }
            else
            {
                re = update(p, userId);
            }

            return(re);
        }
コード例 #11
0
        private void ContextMenu_grfImg_Download(object sender, System.EventArgs e)
        {
            String id = "", datetick = "", dsc_id = "";

            if (grfImg.Col <= 0)
            {
                return;
            }
            if (grfImg.Row < 0)
            {
                return;
            }
            if (grfImg.Col == 1)
            {
                id = grfImg[grfImg.Row, colPic2].ToString();
            }
            else
            {
                id = grfImg[grfImg.Row, colPic4].ToString();
            }
            dsc_id = id;
            DocScan dsc = new DocScan();

            dsc = bc.bcDB.dscDB.selectByPk(dsc_id);
            Stream       streamDownload = null;
            MemoryStream strm           = null;

            foreach (listStream lstrmm in lStream)
            {
                if (lstrmm.id.Equals(id))
                {
                    strm           = lstrmm.stream;
                    streamDownload = lstrmm.stream;
                    break;
                }
            }
            if (!Directory.Exists(bc.iniC.pathDownloadFile))
            {
                Directory.CreateDirectory(bc.iniC.pathDownloadFile);
            }
            datetick = DateTime.Now.Ticks.ToString();
            Image img = Image.FromStream(streamDownload);

            img.Save(bc.iniC.pathDownloadFile + "\\" + dsc.hn + "_" + datetick + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
            bc.ExploreFile(bc.iniC.pathDownloadFile + "\\" + dsc.hn + "_" + datetick + ".jpg");
        }
コード例 #12
0
        private void setControl()
        {
            string str = "";

            try
            {
                str = "00";
                dgs = bc.bcDB.dscDB.selectByPk(dscid);
                bc.bcDB.dgssDB.setCboDGSS(cboDgss, "");
                bc.bcDB.dgsDB.setCboDgs(cboDgs, "");
                str                = "01";
                txtID.Value        = dgs.doc_scan_id;
                txtHn.Value        = hn;
                txtVN.Value        = dgs.vn;
                txtAn.Value        = dgs.an;
                txtPttName.Value   = name;
                txtVisitDate.Value = visitDate;
                txtSort.Value      = dgs.sort1;
                txtFmCode.Value    = dgs.ml_fm;
                //bc.setC1Combo(cboDgs, dgs);
                txtSortMax.Value = dgs.row_cnt;
                //txtSortMax.Value = dgs.row_cnt;
                DocGroupFM docGroupFm1 = new DocGroupFM();
                DocGroupFM docGroupFm2 = bc.bcDB.dfmDB.selectByFMCode(this.dgs.ml_fm);
                if (docGroupFm2.fm_id.Length > 0)
                {
                    bc.setC1Combo(cboDgs, docGroupFm2.doc_group_id);
                    bc.bcDB.dgssDB.setCboDGSS(cboDgs, docGroupFm2.doc_group_id, "");
                    bc.setC1Combo(cboDgss, docGroupFm2.doc_group_sub_id);
                }
                str        = "02";
                pic1.Image = img1;
                btnSaveFmCode.Hide();
                btnVoid.Hide();
            }
            catch (Exception ex)
            {
                LogWriter logWriter = new LogWriter("e", "FrmScanViewEdit setControl err " + str + " " + ex.Message);
            }
        }
コード例 #13
0
ファイル: DocScanDB.cs プロジェクト: eploentham/clinic_ivf
        public String update(DocScan p, String userId)
        {
            String re  = "";
            String sql = "";
            int    chk = 0;

            chkNull(p);
            sql = "Update " + dsc.table + " Set " +
                  " " + dsc.doc_group_id + " = '" + p.doc_group_id + "'" +
                  "," + dsc.row_no + " = '" + p.row_no + "'" +
                  "," + dsc.host_ftp + " = '" + p.host_ftp + "'" +
                  "," + dsc.image_path + " = '" + p.image_path + "'" +
                  "," + dsc.hn + " = '" + p.hn + "'" +
                  "," + dsc.vn + " = '" + p.vn + "'" +
                  "," + dsc.visit_date + " = '" + p.visit_date + "'" +
                  "," + dsc.remark + " = '" + p.remark + "'" +
                  "," + dsc.date_modi + " = now()" +
                  "," + dsc.user_modi + " = '" + userId + "'" +
                  "," + dsc.an + " = '" + p.an + "'" +
                  "," + dsc.doc_group_sub_id + " = '" + p.doc_group_sub_id + "'" +
                  "," + dsc.pre_no + " = '" + p.pre_no + "'" +
                  "," + dsc.an_date + " = '" + p.an_date + "'" +
                  "," + dsc.status_ipd + " = '" + p.status_ipd + "'" +
                  "," + dsc.an_cnt + " = '" + p.an_cnt + "'" +
                  "," + dsc.folder_ftp + " = '" + p.folder_ftp + "'" +
                  "Where " + dsc.pkField + "='" + p.doc_scan_id + "'"
            ;

            try
            {
                re = conn.ExecuteNonQuery(conn.conn, sql);
            }
            catch (Exception ex)
            {
                sql = ex.Message + " " + ex.InnerException;
            }

            return(re);
        }
コード例 #14
0
ファイル: DocScanDB.cs プロジェクト: eploentham/clinic_ivf
        public String selectRowNoByHnVn(String hn, String vn, String docgid)
        {
            String    re = "0", re1 = "";
            int       chk  = 0;
            DocScan   cop1 = new DocScan();
            DataTable dt   = new DataTable();
            String    sql  = "select max(" + dsc.row_no + ") as " + dsc.row_no + " " +
                             "From " + dsc.table + " dsc " +
                             //"Left Join f_patient_prefix pfx On stf.prefix_id = pfx.f_patient_prefix_id " +
                             "Where dsc." + dsc.hn + " ='" + hn + "' and dsc." + dsc.doc_group_id + "='" + docgid + "' and dsc." + dsc.vn + "='" + vn + "' " +
                             "  ";

            dt = conn.selectData(conn.conn, sql);
            if (dt.Rows.Count > 0)
            {
                re1 = dt.Rows[0][dsc.row_no].ToString();
                int.TryParse(re1, out chk);
                chk++;
                re = chk.ToString();
            }
            return(re);
        }
コード例 #15
0
ファイル: DocScanDB.cs プロジェクト: eploentham/clinic_ivf
        public void getlBsp()
        {
            //lDept = new List<Position>();

            lDgs.Clear();
            DataTable dt = new DataTable();

            dt = selectAll();
            foreach (DataRow row in dt.Rows)
            {
                DocScan itm1 = new DocScan();
                itm1.doc_scan_id      = row[dsc.doc_scan_id].ToString();
                itm1.doc_group_id     = row[dsc.doc_group_id].ToString();
                itm1.row_no           = row[dsc.row_no].ToString();
                itm1.host_ftp         = row[dsc.host_ftp].ToString();
                itm1.image_path       = row[dsc.image_path].ToString();
                itm1.hn               = row[dsc.hn].ToString();
                itm1.vn               = row[dsc.vn].ToString();
                itm1.visit_date       = row[dsc.visit_date].ToString();
                itm1.active           = row[dsc.active].ToString();
                itm1.remark           = row[dsc.remark].ToString();
                itm1.date_create      = row[dsc.date_create].ToString();
                itm1.date_modi        = row[dsc.date_modi].ToString();
                itm1.date_cancel      = row[dsc.date_cancel].ToString();
                itm1.user_create      = row[dsc.user_create].ToString();
                itm1.user_modi        = row[dsc.user_modi].ToString();
                itm1.user_cancel      = row[dsc.user_cancel].ToString();
                itm1.an               = row[dsc.an].ToString();
                itm1.doc_group_sub_id = row[dsc.doc_group_sub_id].ToString();
                itm1.pre_no           = row[dsc.pre_no].ToString();
                itm1.an_date          = row[dsc.an_date].ToString();
                itm1.status_ipd       = row[dsc.status_ipd].ToString();
                itm1.an_cnt           = row[dsc.an_cnt].ToString();
                itm1.folder_ftp       = row[dsc.folder_ftp].ToString();
                itm1.status_record    = row[dsc.status_record].ToString();
                lDgs.Add(itm1);
            }
        }
コード例 #16
0
        private void loadDoctorDiag()
        {
            String  mlfm  = "";
            DocScan docCC = new DocScan();

            //DocScan docME = new DocScan();
            //DocScan docDiag = new DocScan();
            if (status.Equals("cc"))
            {
                mlfm = "FM-MED-900";
            }
            else if (title.Equals("me"))
            {
                mlfm = "FM-MED-901";
            }
            else if (title.Equals("diag"))
            {
                mlfm = "FM-MED-902";
            }
            docCC = bc.bcDB.dscDB.selectByStatusMedicalExamination(hn, mlfm, bc.vsdate, bc.preno);
            //docME = bc.bcDB.dscDB.selectByStatusMedicalExamination(hn, "FM-MED-901", vsdate, preno);
            //docDiag = bc.bcDB.dscDB.selectByStatusMedicalExamination(hn, "FM-MED-902", vsdate, preno);
            MemoryStream streamCC, streamME, streamDiag;
            FtpClient    ftp = new FtpClient(bc.iniC.hostFTP, bc.iniC.userFTP, bc.iniC.passFTP, bc.ftpUsePassive);

            streamCC = ftp.download(bc.iniC.folderFTP + "//" + docCC.image_path);
            Thread.Sleep(200);
            //streamME = ftp.download(bc.iniC.folderFTP + "//" + docME.image_path);
            //Thread.Sleep(200);
            //streamDiag = ftp.download(bc.iniC.folderFTP + "//" + docDiag.image_path);
            //Thread.Sleep(200);
            richTextBox1.Text = "";
            streamCC.Position = 0;
            if (streamCC.Length > 0)
            {
                richTextBox1.LoadFile(streamCC, RichTextBoxStreamType.RichText);
            }
        }
コード例 #17
0
ファイル: DocScanDB.cs プロジェクト: eploentham/clinic_ivf
        public DocScan setDocScan(DataTable dt)
        {
            DocScan dgs1 = new DocScan();

            if (dt.Rows.Count > 0)
            {
                dgs1.doc_scan_id      = dt.Rows[0][dsc.doc_scan_id].ToString();
                dgs1.doc_group_id     = dt.Rows[0][dsc.doc_group_id].ToString();
                dgs1.row_no           = dt.Rows[0][dsc.row_no].ToString();
                dgs1.host_ftp         = dt.Rows[0][dsc.host_ftp].ToString();
                dgs1.image_path       = dt.Rows[0][dsc.image_path].ToString();
                dgs1.hn               = dt.Rows[0][dsc.hn].ToString();
                dgs1.vn               = dt.Rows[0][dsc.vn].ToString();
                dgs1.visit_date       = dt.Rows[0][dsc.visit_date].ToString();
                dgs1.active           = dt.Rows[0][dsc.active].ToString();
                dgs1.remark           = dt.Rows[0][dsc.remark].ToString();
                dgs1.date_create      = dt.Rows[0][dsc.date_create].ToString();
                dgs1.date_modi        = dt.Rows[0][dsc.date_modi].ToString();
                dgs1.date_cancel      = dt.Rows[0][dsc.date_cancel].ToString();
                dgs1.user_create      = dt.Rows[0][dsc.user_create].ToString();
                dgs1.user_modi        = dt.Rows[0][dsc.user_modi].ToString();
                dgs1.user_cancel      = dt.Rows[0][dsc.user_cancel].ToString();
                dgs1.an               = dt.Rows[0][dsc.an].ToString();
                dgs1.doc_group_sub_id = dt.Rows[0][dsc.doc_group_sub_id].ToString();
                dgs1.pre_no           = dt.Rows[0][dsc.pre_no].ToString();
                dgs1.an_date          = dt.Rows[0][dsc.an_date].ToString();
                dgs1.status_ipd       = dt.Rows[0][dsc.status_ipd].ToString();
                dgs1.an_cnt           = dt.Rows[0][dsc.an_cnt].ToString();
                dgs1.folder_ftp       = dt.Rows[0][dsc.an_cnt].ToString();
                dgs1.status_record    = dt.Rows[0][dsc.status_record].ToString();
            }
            else
            {
                setDocGroupScan(dgs1);
            }
            return(dgs1);
        }
コード例 #18
0
ファイル: DocScanDB.cs プロジェクト: eploentham/clinic_ivf
        public String insert(DocScan p, String userId)
        {
            String re  = "";
            String sql = "";

            //DataTable dt = new DataTable();
            p.active = "1";
            //p.ssdata_id = "";
            int chk = 0;

            chkNull(p);
            sql = "Insert Into " + dsc.table + " set " +
                  "" + dsc.doc_group_id + "= '" + p.doc_group_id + "'" +
                  "," + dsc.active + "= '" + p.active + "'" +
                  "," + dsc.row_no + "= '" + p.row_no + "'" +
                  "," + dsc.host_ftp + "= '" + p.host_ftp + "'" +
                  "," + dsc.image_path + "= '" + p.image_path + "'" +
                  "," + dsc.hn + "= '" + p.hn + "'" +
                  "," + dsc.vn + "= '" + p.vn + "'" +
                  "," + dsc.visit_date + "= '" + p.visit_date + "'" +
                  "," + dsc.remark + "= '" + p.remark + "'" +
                  "," + dsc.date_create + "= now()" +
                  "," + dsc.date_modi + "= ''" +
                  "," + dsc.date_cancel + "= ''" +
                  "," + dsc.user_create + "= '" + userId + "@" + conn._IPAddress + "'" +
                  "," + dsc.user_modi + "= ''" +
                  "," + dsc.user_cancel + "= ''" +
                  "," + dsc.an + "= '" + p.an + "'" +
                  "," + dsc.doc_group_sub_id + "= '" + p.doc_group_sub_id + "'" +
                  "," + dsc.pre_no + "= '" + p.pre_no + "'" +
                  "," + dsc.an_date + "= '" + p.an_date + "'" +
                  "," + dsc.status_ipd + "= '" + p.status_ipd + "'" +
                  "," + dsc.an_cnt + " " + "= '" + p.an_cnt + "'" +
                  "," + dsc.folder_ftp + " " + "= '" + p.folder_ftp + "'" +
                  "," + dsc.status_record + " " + "= '" + p.status_record + "'" +
                  "";
            try
            {
                //    conn.comStore = new System.Data.SqlClient.SqlCommand();
                //    conn.comStore.Connection = conn.conn;
                //    conn.comStore.CommandText = "insert_doc_scan";
                //    conn.comStore.CommandType = CommandType.StoredProcedure;
                //    conn.comStore.Parameters.AddWithValue("doc_group_id", p.doc_group_id);
                //    conn.comStore.Parameters.AddWithValue("host_ftp", p.host_ftp);
                //    conn.comStore.Parameters.AddWithValue("hn", p.hn);
                //    conn.comStore.Parameters.AddWithValue("vn", p.vn);
                //    conn.comStore.Parameters.AddWithValue("remark", p.remark);
                //    conn.comStore.Parameters.AddWithValue("user_create", userId);
                //    conn.comStore.Parameters.AddWithValue("an", p.an);
                //    conn.comStore.Parameters.AddWithValue("doc_group_sub_id", p.doc_group_sub_id);
                //    conn.comStore.Parameters.AddWithValue("pre_no", p.pre_no);
                //    conn.comStore.Parameters.AddWithValue("an_date", p.an_date);
                //    conn.comStore.Parameters.AddWithValue("status_ipd", p.status_ipd);
                //    conn.comStore.Parameters.AddWithValue("ext", p.image_path);
                //    conn.comStore.Parameters.AddWithValue("visit_date", p.visit_date);
                //    SqlParameter retval =  conn.comStore.Parameters.Add("row_no1", SqlDbType.VarChar, 50);
                //    retval.Value = "";
                //    retval.Direction = ParameterDirection.Output;

                re = conn.ExecuteNonQuery(conn.conn, sql);
                //conn.Open();
                //    conn.comStore.ExecuteNonQuery();
                //    re = (String)conn.comStore.Parameters["row_no1"].Value;
                //    //string retunvalue = (string)sqlcomm.Parameters["@b"].Value;
            }
            catch (Exception ex)
            {
                sql = ex.Message + " " + ex.InnerException;
            }
            finally
            {
                conn.conn.Close();
                //conn.comStore.Dispose();
            }
            return(re);
        }
コード例 #19
0
        private void BtnUpload_Click(object sender, EventArgs e)
        {
            //throw new NotImplementedException();
            //name = filename.Replace("*", "");
            String dgssid = cboDgs.SelectedItem == null ? "" : ((ComboBoxItem)cboDgs.SelectedItem).Value;

            if (dgssid.Length <= 0)
            {
                MessageBox.Show("ไม่ได้เลือก กลุ่มเอกสาร", "");
                return;
            }
            picWait.Show();
            string ext = Path.GetExtension(filename);
            String dgssname = "", vn = "", an = "";
            //dgssid = bc.bcDB.dgssDB.getIdDgss("Document Other");
            DocGroupSubScan dgss = new DocGroupSubScan();

            dgss = bc.bcDB.dgssDB.selectByPk(dgssid);
            DocScan dsc = new DocScan();

            //new LogWriter("d", "BtnUpload_Click dsc.vn " + dsc.vn + " dsc.an " + dsc.an);
            dsc.active       = "1";
            dsc.doc_scan_id  = "";
            dsc.doc_group_id = cboDgs.SelectedItem == null ? "" : ((ComboBoxItem)cboDgs.SelectedItem).Value;
            dsc.hn           = txtHn.Text;
            if (lbVn.Text.Trim().Equals("VN :"))
            {
                dsc.an = "";
                dsc.vn = txtVn.Text.Trim();
            }
            else
            {
                dsc.vn = "";
                dsc.an = txtVn.Text.Trim();
            }
            dsc.visit_date = "";
            dsc.host_ftp   = bc.iniC.hostFTP;
            //dsc.image_path = txtHn.Text + "//" + txtHn.Text + "_" + dgssid + "_" + dsc.row_no + "." + ext[ext.Length - 1];
            dsc.image_path       = "";
            dsc.doc_group_sub_id = dgssid;
            dsc.pre_no           = "";
            dsc.an_date          = "";
            dsc.folder_ftp       = bc.iniC.folderFTP;
            dsc.status_ipd       = "O";
            dsc.row_no           = "1";
            dsc.row_cnt          = "1";
            dsc.status_ml        = "2";
            dsc.ml_fm            = txtFM.Text.Trim();
            String re = bc.bcDB.dscDB.insertScreenCapture(dsc, bc.userId);

            sB11.Text = " filename " + filename + " bc.iniC.folderFTP " + bc.iniC.folderFTP + "//" + dsc.image_path;
            long chk = 0;

            if (long.TryParse(re, out chk))
            {
                //dsc.image_path = txtHn.Text.Replace("/", "-") + "//" + txtHn.Text.Replace("/", "-") + "-" + vn + "//" + txtHn.Text.Replace("/", "-") + "-" + vn + "-" + re + ext;         //+1
                dsc.image_path = txtHn.Text.Replace("/", "-") + "//" + txtHn.Text.Replace("/", "-") + "-" + re + ext;
                String re1 = bc.bcDB.dscDB.updateImagepath(dsc.image_path, re);
                //MessageBox.Show("filename" + filename + "\n bc.iniC.folderFTP " + bc.iniC.folderFTP + "//" + dsc.image_path, "");
                //FtpClient ftp = new FtpClient(bc.iniC.hostFTP, bc.iniC.userFTP, bc.iniC.passFTP);
                FtpClient ftp = new FtpClient(bc.iniC.hostFTP, bc.iniC.userFTP, bc.iniC.passFTP, bc.ftpUsePassive, bc.iniC.ProxyProxyType, bc.iniC.ProxyHost, bc.iniC.ProxyPort);
                //MessageBox.Show("HN "+ txtHn.Text.Replace("/", "-"), "");
                //ftp.createDirectory(txtHn.Text);
                ftp.createDirectory(bc.iniC.folderFTP + "//" + txtHn.Text.Replace("/", "-"));
                //MessageBox.Show("222", "");
                ftp.delete(bc.iniC.folderFTP + "//" + dsc.image_path);
                //MessageBox.Show("333", "");

                ftp.upload(bc.iniC.folderFTP + "//" + dsc.image_path, filename);
                File.Delete(filename);
                System.Threading.Thread.Sleep(1000);
                this.Dispose();
            }
        }
コード例 #20
0
ファイル: FrmScanAdd.cs プロジェクト: eploentham/clinic_ivf
        private void BtnDel_Click(object sender, EventArgs e)
        {
            //throw new NotImplementedException();

            if (Directory.Exists(ic.iniC.pathImageScan))
            {
                if (MessageBox.Show("ต้องการ Upload ข้อมูล รูป scan ", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                {
                    //DirectoryInfo dir = new DirectoryInfo(ic.iniC.pathImageScan);
                    //foreach (FileInfo fi in dir.GetFiles())
                    //{
                    //    fi.Delete();
                    //}
                    int     i = 0;
                    String  dgs = "", name = "";
                    Boolean chk = false;
                    txtVN.Hide();
                    btnVn.Hide();
                    //label3.Hide();
                    //txtAN.Hide();
                    //txtAnCnt.Hide();
                    //chkIPD.Hide();
                    label6.Hide();
                    txtVisitDate.Hide();
                    //txtAnDate.Hide();
                    //txtPreNo.Hide();
                    setVisible(false);
                    ProgressBar pB1 = new ProgressBar();
                    pB1.Location = new System.Drawing.Point(15, 15);
                    pB1.Name     = "pB1";
                    pB1.Size     = new System.Drawing.Size(862, 23);
                    //pB1.Left = txtVN.Left;
                    pB1.Show();
                    pB1.Value   = 0;
                    pB1.Minimum = 0;
                    pB1.Maximum = array1.Count;
                    groupBox1.Controls.Add(pB1);
                    Application.DoEvents();
                    foreach (String aa in array1)
                    {
                        i++;
                        pB1.Value++;
                        String[] aaa = aa.Split(',');
                        if (aaa.Length == 3)
                        {
                            name = aaa[2].Replace("*", "");
                            string ext = Path.GetExtension(name);
                            String dgssname = "", dgssid = "", vn = "", an = "";
                            dgssid = ic.ivfDB.dgssDB.getIdDgss("Document Other");
                            DocGroupSubScan dgss = new DocGroupSubScan();
                            dgss = ic.ivfDB.dgssDB.selectByPk(dgssid);
                            DocScan dsc = new DocScan();
                            dsc.active       = "1";
                            dsc.doc_scan_id  = "";
                            dsc.doc_group_id = dgss.doc_group_id;
                            //dsc.hn = txtHn.Text;          //-0021
                            //dsc.hn = txtHn.Text.Trim().Replace(ic.hnspareyear, "").Replace(txtPttYear.Text.Trim(), "");            //+0021
                            int index = txtHn.Text.IndexOf(ic.hnspareyear);
                            if (index >= 6)
                            {
                                dsc.hn = txtHn.Text.Substring(0, index);
                            }

                            dsc.vn         = txtVN.Text;
                            dsc.an         = "";
                            dsc.visit_date = ic.datetoDB(txtVisitDate.Text);
                            dsc.host_ftp   = ic.iniC.hostFTP;
                            //dsc.image_path = txtHn.Text + "//" + txtHn.Text + "_" + dgssid + "_" + dsc.row_no + "." + ext[ext.Length - 1];
                            dsc.image_path       = "";
                            dsc.doc_group_sub_id = dgssid;
                            dsc.pre_no           = "";
                            dsc.an = "";
                            DateTime dt = new DateTime();

                            //dsc.an_date = (DateTime.TryParse(txtAnDate.Text, out dt)) ? ic.datetoDB(txtAnDate.Text) : "";
                            //if (dsc.an_date.Equals("1-01-01"))
                            //{
                            dsc.an_date = "";
                            //}
                            dsc.folder_ftp = ic.iniC.folderFTP;
                            dsc.status_ipd = "O";
                            String re = ic.ivfDB.dscDB.insertDocScan(dsc, ic.userId);
                            //dsc.image_path = txtHn.Text + "//" + txtHn.Text + "_" + re + ext;
                            //if (chkIPD.Checked)
                            //{
                            //    vn = txtAN.Text.Replace("/", "_").Replace("(", "_").Replace(")", "");
                            //}
                            //else
                            //{
                            vn = txtVN.Text.Replace("/", "_").Replace("(", "_").Replace(")", "");
                            //}
                            dsc.image_path = txtHn.Text.Replace("-", "").Replace("/", "") + "_" + vn + "//" + txtHn.Text.Replace("-", "").Replace("/", "") + "_" + vn + "_" + re + ext;
                            String    re1 = ic.ivfDB.dscDB.updateImagepath(dsc.image_path, re);
                            FtpClient ftp = new FtpClient(ic.iniC.hostFTP, ic.iniC.userFTP, ic.iniC.passFTP, ic.ftpUsePassive, ic.iniC.pathChar);
                            //MessageBox.Show("111", "");
                            //ftp.createDirectory(txtHn.Text);
                            ftp.createDirectory(ic.iniC.folderFTP + "//" + txtHn.Text.Replace("-", "").Replace("/", "") + "_" + vn);
                            //MessageBox.Show("222", "");
                            ftp.delete(ic.iniC.folderFTP + "//" + dsc.image_path);
                            //MessageBox.Show("333", "");
                            ftp.upload(ic.iniC.folderFTP + "//" + dsc.image_path, name);
                            //break;
                            //Application.DoEvents();
                        }
                    }
                    pB1.Dispose();
                    txtVN.Show();
                    btnVn.Show();
                    //label3.Show();
                    //txtAN.Show();
                    //txtAnCnt.Show();
                    //chkIPD.Show();
                    label6.Show();
                    delFile();
                    grf.Dispose();
                    initGrf();
                    setGrf();
                    setImage1(true);
                    setVisible(true);
                    MessageBox.Show("Upload รูป เวชระเบียน เรียบร้อย", "");
                }
            }
        }
コード例 #21
0
        private void uploadFiletoServerRIA()
        {
            timer.Stop();
            listBox2.Items.Clear();     //listBox3
            Application.DoEvents();
            Thread.Sleep(1000);
            if (!Directory.Exists(bc.iniC.pathLabOutBackupRIAZipExtract))
            {
                Directory.CreateDirectory(bc.iniC.pathLabOutBackupRIAZipExtract);
            }
            if (!Directory.Exists(bc.iniC.pathLabOutBackupRIA))
            {
                Directory.CreateDirectory(bc.iniC.pathLabOutBackupRIA);
            }
            FtpClient ftp = new FtpClient(bc.iniC.hostFTP, bc.iniC.userFTP, bc.iniC.passFTP, bc.ftpUsePassive);
            //String[] filePaths = Directory.GetFiles(bc.iniC.pathLabOutReceive, "*.*", SearchOption.TopDirectoryOnly);
            List <String> filePaths = new List <String>();
            DirectoryInfo dir       = new DirectoryInfo(bc.iniC.pathLabOutReceiveRIA);

            FileInfo[] Files = dir.GetFiles("*.zip"); //Getting Text files
            foreach (FileInfo file in Files)
            {
                //Console.WriteLine("The number of files in {0} is {1}", diNext, diNext.GetFiles().Length);
                string str = "";
                filePaths.Add(file.FullName);
            }
            String dgssid = "";

            dgssid = bc.bcDB.dgssDB.getIdDgss("Document Other");
            DocGroupSubScan dgss = new DocGroupSubScan();

            dgss = bc.bcDB.dgssDB.selectByPk(dgssid);
            foreach (String zipFilename in filePaths)
            {
                listBox2.Items.Add("พบ file " + zipFilename);
                Application.DoEvents();
                int    year2 = 0;
                String yy = "", mm = "", dd = "", reqid = "", vn = "", datetick1 = "", pathbackup = "", year1 = "", ext = "", pathname = "", tmp = "", filename2 = "", hn = "", filenamePDF = "";
                var    fileStreamJson = new MemoryStream();
                var    fileStreamPDF  = new MemoryStream();
                //Json

                datetick1  = DateTime.Now.Ticks.ToString();
                pathbackup = bc.iniC.pathLabOutBackupRIA + "\\" + datetick1;
                if (!Directory.Exists(pathbackup))
                {
                    Directory.CreateDirectory(pathbackup);
                }
                //using (var zip = ZipFile.Read(filename))
                //{
                //    foreach (var entry in zip)
                //    {
                //        ext = Path.GetExtension(entry.FileName);
                //        if (ext.ToLower().Equals(".json"))
                //        {
                //            entry.Extract(fileStreamJson);
                //            fileStreamJson.Seek(0, SeekOrigin.Begin);
                //            StreamReader reader = new StreamReader(fileStreamJson, System.Text.Encoding.UTF8, true);
                //            using (JsonTextReader readerJson = new JsonTextReader(reader))
                //            {
                //                //JObject o2 = (JObject)JToken.ReadFrom(readerJson);
                //                //RIA_Patient account = JsonConvert.DeserializeObject<RIA_Patient>(readerJson);
                //                string jsonData1 = @"{'idcard': '', 'hn': '', title:'', fname:'', lname:'', sex:'', dob:''}";
                //                JsonSerializer serializer = new JsonSerializer();
                //                var movie2 = serializer.Deserialize(readerJson);
                //                JObject o2 = (JObject)JToken.ReadFrom(readerJson);
                //                dynamic obj = o2["patient"];
                //                //dynamic obj = JsonConvert.DeserializeObject(movie2.ToString());
                //                //var jsonData = JObject.Parse(movie2.ToString());
                //                //RIA_Patient account = (RIA_Patient)jsonData[0]["hn"].ToString();
                //                //RIA_Patient rptt = new RIA_Patient();
                //                //rptt = (RIA_Patient)movie2[0];
                //            }
                //        }
                //        else if (ext.ToLower().Equals(".pdf"))
                //        {
                //            entry.Extract(fileStreamPDF);
                //            fileStreamPDF.Seek(0, SeekOrigin.Begin);

                //        }
                //    }
                //}
                RIA_Patient aaa = new RIA_Patient();
                ZipFile     zf  = new ZipFile(zipFilename);
                zf.ExtractAll(pathbackup);
                DirectoryInfo dZip     = new DirectoryInfo(pathbackup);
                FileInfo[]    filesZip = dZip.GetFiles("*.*");
                foreach (FileInfo file in filesZip)
                {
                    ext = Path.GetExtension(file.FullName);
                    if (ext.ToLower().Equals(".json"))
                    {
                        using (StreamReader file1 = File.OpenText(file.FullName))
                            using (JsonTextReader reader = new JsonTextReader(file1))
                            {
                                JObject o2 = (JObject)JToken.ReadFrom(reader);

                                dynamic objPtt = o2["patient"];
                                dynamic objOrd = o2["orderdetail"];
                                aaa.hn              = objPtt.hn;
                                aaa.idcard          = objPtt.idcard;
                                aaa.fname           = objPtt.fname;
                                aaa.lname           = objPtt.lname;
                                aaa.ref_no          = objOrd.ref_no;
                                aaa.order_number    = objOrd.order_number;
                                aaa.ln              = objOrd.ln;
                                aaa.hn_customer     = objOrd.hn_customer;
                                aaa.status          = objOrd.status;
                                aaa.comment_order   = objOrd.comment_order;
                                aaa.comment_patient = objOrd.comment_patient;
                                aaa.ward_customer   = objOrd.ward_customer;
                                aaa.doctor          = objOrd.doctor;
                                aaa.time_register   = objOrd.time_register;
                                aaa.ward_customer   = objOrd.ward_customer;
                                filename2           = aaa.ref_no;
                                //aaa = (RIA_Patient)o2["patient"];
                                //IList<JToken> results = o2["patient"]["fname"].Children().ToList();
                            }
                    }
                    else if (ext.ToLower().Equals(".pdf"))
                    {
                        filenamePDF = file.FullName;
                    }
                }
                filesZip = null;
                if (filename2.Length <= 0)
                {
                    MessageBox.Show("aaaaaa", "");
                    return;
                }
                dZip = null;
                zf.Dispose();
                reqid = filename2.Substring(filename2.Length - 3);
                yy    = filename2.Substring(filename2.Length - 5, 2);
                mm    = filename2.Substring(filename2.Length - 7, 2);
                dd    = filename2.Substring(filename2.Length - 9, 2);
                year1 = "20" + yy;
                DataTable dt = new DataTable();
                dt = bc.bcDB.vsDB.SelectHnLabOut(reqid, year1 + "-" + mm + "-" + dd);
                if (dt.Rows.Count <= 0)
                {
                    listBox2.Items.Add("Filename ไม่พบข้อมูล HIS " + zipFilename);
                    Application.DoEvents();
                    String datetick = "";
                    new LogWriter("e", "Filename ไม่พบข้อมูล HIS");
                    //MessageBox.Show("Filename ไม่พบข้อมูล HIS", "");
                    datetick = DateTime.Now.Ticks.ToString();
                    if (!Directory.Exists(bc.iniC.pathLabOutBackupRIA))
                    {
                        Directory.CreateDirectory(bc.iniC.pathLabOutBackupRIA);
                    }
                    if (pathname.Length > 0)
                    {
                        if (!Directory.Exists(bc.iniC.pathLabOutBackupRIA + "\\" + pathname))
                        {
                            Directory.CreateDirectory(bc.iniC.pathLabOutBackupRIA + "\\" + pathname);
                        }
                    }
                    Thread.Sleep(200);
                    if (pathname.Length > 0)
                    {
                        File.Move(zipFilename, bc.iniC.pathLabOutBackupRIA + "\\" + pathname + "\\err_" + filename2 + "_" + datetick + ext);
                    }
                    else
                    {
                        File.Move(zipFilename, bc.iniC.pathLabOutBackupRIA + "\\err_" + filename2 + "_" + datetick + ext);
                    }
                    Thread.Sleep(1000);
                    continue;
                }
                listBox2.Items.Add("พบข้อมูล HIS " + dt.Rows[0]["mnc_hn_no"].ToString());
                Application.DoEvents();
                if (!dt.Rows[0]["mnc_hn_no"].ToString().Equals(aaa.hn_customer))
                {
                    MessageBox.Show("aaaaaa", "");
                }
                DocScan dsc = new DocScan();
                dsc.active       = "1";
                dsc.doc_scan_id  = "";
                dsc.doc_group_id = dgss.doc_group_id;
                dsc.hn           = dt.Rows[0]["mnc_hn_no"].ToString();
                dsc.vn           = dt.Rows[0]["MNC_VN_NO"].ToString() + "/" + dt.Rows[0]["MNC_VN_SEQ"].ToString() + "(" + dt.Rows[0]["MNC_VN_SUM"].ToString() + ")";
                dsc.an           = dt.Rows[0]["MNC_AN_NO"].ToString() + "/" + dt.Rows[0]["MNC_AN_YR"].ToString();
                if (dsc.an.Equals("/"))
                {
                    dsc.an = "";
                }
                dsc.visit_date = "";
                dsc.host_ftp   = bc.iniC.hostFTP;
                //dsc.image_path = txtHn.Text + "//" + txtHn.Text + "_" + dgssid + "_" + dsc.row_no + "." + ext[ext.Length - 1];
                dsc.image_path       = "";
                dsc.doc_group_sub_id = dgssid;
                dsc.pre_no           = dt.Rows[0]["mnc_pre_no"].ToString();
                //dsc.an = "";
                //DateTime dt = new DateTime();

                //    dsc.an_date = (DateTime.TryParse(txtAnDate.Text, out dt)) ? bc.datetoDB(txtAnDate.Text) : "";
                //    if (dsc.an_date.Equals("1-01-01"))
                //    {
                //        dsc.an_date = "";
                //    }
                dsc.folder_ftp = bc.iniC.folderFTP;
                //    dsc.status_ipd = chkIPD.Checked ? "I" : "O";
                dsc.row_no         = "1";
                dsc.row_cnt        = "1";
                dsc.status_version = "2";
                dsc.req_id         = dt.Rows[0]["mnc_req_no"].ToString();
                DateTime dtt = new DateTime();
                if (DateTime.TryParse(dt.Rows[0]["mnc_req_dat"].ToString(), out dtt))
                {
                    dsc.date_req = dtt.Year.ToString() + "-" + dtt.ToString("MM-dd");
                }
                else
                {
                    dsc.date_req = "";
                }
                if (dsc.an.Length > 0)
                {
                    dsc.status_ipd = "1";
                }
                else
                {
                    dsc.status_ipd = "0";
                }
                //dsc.ml_fm = "FM-LAB-999";

                dsc.ml_fm = "FM-LAB-996";       //RIA

                dsc.patient_fullname = dt.Rows[0]["mnc_patname"].ToString();
                dsc.status_record    = "2";
                String re = bc.bcDB.dscDB.insertLabOut(dsc, bc.userId);
                if (re.Length <= 0)
                {
                    listBox2.Items.Add("ไม่ได้เลขที่ " + zipFilename);
                    Application.DoEvents();
                    String datetick = "";
                    new LogWriter("e", "ไม่ได้เลขที่ " + zipFilename);
                    //MessageBox.Show("Filename ไม่พบข้อมูล HIS", "");
                    datetick = DateTime.Now.Ticks.ToString();

                    Thread.Sleep(200);
                    if (pathname.Length > 0)
                    {
                        File.Move(zipFilename, pathbackup + "\\err_" + filename2 + "_" + datetick + ext);
                    }
                    else
                    {
                        File.Move(zipFilename, pathbackup + "\\err_" + filename2 + "_" + datetick + ext);
                    }
                    Thread.Sleep(1000);
                    continue;
                }
                listBox2.Items.Add("ได้เลขที่ " + re);
                Application.DoEvents();
                dsc.image_path = dt.Rows[0]["mnc_hn_no"].ToString() + "//" + dt.Rows[0]["mnc_hn_no"].ToString() + "_" + re + ext;
                //    if (chkIPD.Checked)
                //    {
                //        vn = txtAN.Text.Replace("/", "_").Replace("(", "_").Replace(")", "");
                //    }
                //    else
                //    {
                vn = dsc.vn.Replace("/", "_").Replace("(", "_").Replace(")", "");

                dsc.ml_fm = "FM-LAB-996";       //RIA

                //    }
                //    //dsc.image_path = txtHn.Text.Replace("/", "-") + "-" + vn + "//" + txtHn.Text.Replace("/", "-") + "-" + vn + "-" + re + ext;       //-1
                dsc.image_path = dt.Rows[0]["mnc_hn_no"].ToString().Replace("/", "-") + "//" + dt.Rows[0]["mnc_hn_no"].ToString().Replace("/", "-") + "-" + vn + "-" + re + ext;         //+1

                String re1 = bc.bcDB.dscDB.updateImagepath(dsc.image_path, re);
                listBox2.Items.Add("updateImagepath " + dsc.image_path);
                Application.DoEvents();
                //    //MessageBox.Show("111", "");

                ftp.createDirectory(bc.iniC.folderFTP + "//" + dt.Rows[0]["mnc_hn_no"].ToString().Replace("/", "-"));       // สร้าง Folder HN
                //    ftp.createDirectory(bc.iniC.folderFTP + "//" + txtHn.Text.Replace("/", "-") + "//" + txtHn.Text.Replace("/", "-") + "-" + vn);
                //    //MessageBox.Show("222", "");
                Thread.Sleep(200);
                ftp.delete(bc.iniC.folderFTP + "//" + dsc.image_path);
                //    //MessageBox.Show("333", "");
                Thread.Sleep(200);
                if (ftp.upload(bc.iniC.folderFTP + "//" + dsc.image_path, zipFilename))
                {
                    Thread.Sleep(200);
                    if (ftp.upload(bc.iniC.folderFTP + "//" + dsc.image_path, filenamePDF))
                    {
                        listBox2.Items.Add("FTP upload success ");
                        Application.DoEvents();
                        Thread.Sleep(1000);
                        String datetick = "";
                        datetick = DateTime.Now.Ticks.ToString();
                        //if (!Directory.Exists(bc.iniC.pathLabOutBackupRIA))
                        //{
                        //    Directory.CreateDirectory(bc.iniC.pathLabOutBackupRIA);
                        //}
                        //if (pathname.Length > 0)
                        //{
                        //    if (!Directory.Exists(bc.iniC.pathLabOutBackupRIA + "\\" + pathname))
                        //    {
                        //        Directory.CreateDirectory(bc.iniC.pathLabOutBackupRIA + "\\" + pathname);
                        //    }
                        //}
                        Thread.Sleep(1000);
                        if (File.Exists(zipFilename))
                        {
                            //dZip.MoveTo("");
                            try
                            {
                                File.Move(zipFilename, pathbackup + "\\" + filename2 + "_" + datetick + ".zip");
                            }
                            catch (Exception ex)
                            {
                                String aaaa = "";
                            }
                        }
                    }
                    //else
                    //{
                    //    File.Move(zipFilename, pathbackup + "\\" + filename2 + "_" + datetick + ".zip");
                    //}
                    listBox1.BeginUpdate();                                                                                        //listBox2
                    listBox1.Items.Add(zipFilename + " -> " + bc.iniC.hostFTP + "//" + bc.iniC.folderFTP + "//" + dsc.image_path); //listBox2
                    listBox1.EndUpdate();                                                                                          //listBox2
                    Application.DoEvents();
                    Thread.Sleep(1000 * 60);
                }
                else
                {
                    listBox2.Items.Add("FTP upload success ");
                    Application.DoEvents();
                    new LogWriter("e", "FTP upload no success");
                }
            }
            timer.Start();
        }
コード例 #22
0
ファイル: FrmScanAdd.cs プロジェクト: eploentham/clinic_ivf
        private void ContextMenu_upload(object sender, System.EventArgs e)
        {
            String dgs = "", filename = "", id = "";

            filename = searchInArray();
            if (txtHn.Text.Equals(""))
            {
                MessageBox.Show("กรุณาป้อน HN", "");
                return;
            }
            try
            {
                filename = filename.Substring(filename.IndexOf('*') + 1);
                //String[] ext = filename.Split('.');
                string ext = Path.GetExtension(filename);
                String dgssname = "", dgssid = "";
                dgssname = ((MenuItem)sender).Text;
                dgssid   = ic.ivfDB.dgssDB.getIdDgss(dgssname);
                DocGroupSubScan dgss = new DocGroupSubScan();
                dgss = ic.ivfDB.dgssDB.selectByPk(dgssid);
                if (!dgss.doc_group_sub_id.Equals(""))
                {
                    //dgs = cboDgs.SelectedItem == null ? "" : ((ComboBoxItem)cboDgs.SelectedItem).Value;
                    int row = 0, col = 0;
                    row = grf.Row;
                    col = grf.Col;
                    DocScan dsc = new DocScan();
                    dsc.active       = "1";
                    dsc.doc_scan_id  = "";
                    dsc.doc_group_id = dgss.doc_group_id;
                    dsc.hn           = txtHn.Text;
                    dsc.vn           = txtVN.Text;
                    dsc.an           = "";
                    dsc.visit_date   = ic.datetoDB(txtVisitDate.Text);
                    //if (!txtVN.Text.Equals(""))
                    //{
                    //    dsc.row_no = bc.ivfDB.dscDB.selectRowNoByHnVn(txtHn.Text, txtVN.Text, dgs);
                    //}
                    //else
                    //{
                    //    dsc.row_no = bc.ivfDB.dscDB.selectRowNoByHn(txtHn.Text, dgs);
                    //}
                    dsc.host_ftp = ic.iniC.hostFTP;
                    //dsc.image_path = txtHn.Text + "//" + txtHn.Text + "_" + dgssid + "_" + dsc.row_no + "." + ext[ext.Length - 1];
                    dsc.image_path       = "";
                    dsc.doc_group_sub_id = dgssid;
                    dsc.pre_no           = "";
                    dsc.an = "";
                    DateTime dt = new DateTime();

                    dsc.an_date = "";
                    //if (dsc.an_date.Equals("1-01-01"))
                    //{
                    //    dsc.an_date = "";
                    //}
                    dsc.status_ipd = "O";
                    dsc.folder_ftp = ic.iniC.folderFTP;
                    String re = ic.ivfDB.dscDB.insertDocScan(dsc, ic.userId);
                    dsc.image_path = txtVN.Text + "//" + txtHn.Text.Replace("/", "-") + "_" + txtVN.Text + "_" + re + ext;
                    String    re1 = ic.ivfDB.dscDB.updateImagepath(dsc.image_path, re);
                    FtpClient ftp = new FtpClient(ic.iniC.hostFTP, ic.iniC.userFTP, ic.iniC.passFTP, ic.ftpUsePassive, ic.iniC.pathChar);
                    //MessageBox.Show("111", "");
                    ftp.createDirectory(ic.iniC.folderFTP + "//" + txtVN.Text);
                    //MessageBox.Show("222", "");
                    ftp.delete(dsc.image_path);
                    //MessageBox.Show("333", "");
                    ftp.upload(ic.iniC.folderFTP + "//" + dsc.image_path, filename);
                    Boolean findTrue = false;
                    foreach (Control con in this.Controls)
                    {
                        if (findTrue)
                        {
                            break;
                        }
                        if (con is Panel)
                        {
                            foreach (Control conp in con.Controls)
                            {
                                if (findTrue)
                                {
                                    break;
                                }
                                if (conp is C1DockingTab)
                                {
                                    foreach (Control cond in conp.Controls)
                                    {
                                        if (findTrue)
                                        {
                                            break;
                                        }
                                        if (cond is C1DockingTabPage)
                                        {
                                            foreach (Control cong in cond.Controls)
                                            {
                                                if (findTrue)
                                                {
                                                    break;
                                                }
                                                if (cong is C1DockingTab)
                                                {
                                                    foreach (Control congd in cong.Controls)
                                                    {
                                                        if (findTrue)
                                                        {
                                                            break;
                                                        }
                                                        if (congd is C1DockingTabPage)
                                                        {
                                                            foreach (Control congd1 in congd.Controls)
                                                            {
                                                                if (findTrue)
                                                                {
                                                                    break;
                                                                }
                                                                if (congd1 is C1FlexGrid)
                                                                {
                                                                    if (congd1.Name.Equals(dsc.doc_group_sub_id))
                                                                    {
                                                                        String     aa = "";
                                                                        C1FlexGrid grf1;
                                                                        grf1 = (C1FlexGrid)congd1;
                                                                        Row   rowg = grf1.Rows.Add();
                                                                        Image loadedImage, resizedImage;
                                                                        loadedImage = Image.FromFile(filename);
                                                                        int originalWidth = 0;
                                                                        originalWidth = loadedImage.Width;
                                                                        int newWidth = 280;
                                                                        resizedImage = loadedImage.GetThumbnailImage(newWidth, (newWidth * loadedImage.Height) / originalWidth, null, IntPtr.Zero);
                                                                        //
                                                                        rowg[colPic1] = resizedImage;
                                                                        rowg[colPic2] = filename;
                                                                        //grf[grf.Row, grf.Col] = dsc.doc_group_sub_id;
                                                                        grf1.AutoSizeRows();
                                                                        Application.DoEvents();
                                                                        addInArrayImg(filename, dsc.doc_group_sub_id);

                                                                        grf.SetData(grf.Row, grf.Col, dgssname);
                                                                        grf.AutoSizeRows(grf.Row, grf.Col, grf.Row, grf.Col, 20, AutoSizeFlags.SameSize);

                                                                        findTrue = true;
                                                                        break;
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    //grf.AutoSizeRows();
                    //grf.AutoSizeCols();
                    //CellRange cr = grf.GetCellRange(grf.Row, grf.Col);
                    CellStyle cs = grf.Styles.Add("CellNeWStyle");
                    cs.BackColor    = Color.Green;
                    cs.Border.Color = Color.FromArgb(196, 228, 223);
                    cs.Border.Color = Color.Black;
                    //cr.Style = cs;
                    grf.SetCellStyle(grf.Row, grf.Col, cs);
                    grf.Styles.Normal.ImageAlign = C1.Win.C1FlexGrid.ImageAlignEnum.CenterTop;
                    grf.Styles.Normal.TextAlign  = C1.Win.C1FlexGrid.TextAlignEnum.CenterBottom;
                    grf.SetData(grf.Row, grf.Col, dgssname);
                }
            }
            catch (Exception ex)
            {
            }
        }
コード例 #23
0
        private void RbnSave_Click(object sender, EventArgs e)
        {
            //throw new NotImplementedException();
            bc.cStf.staff_id = "";
            FrmPasswordConfirm frm = new FrmPasswordConfirm(bc);

            frm.ShowDialog(this);
            if (!bc.cStf.staff_id.Equals(""))
            {
                String filename = "", ext = "";
                if (!Directory.Exists("medical"))
                {
                    Directory.CreateDirectory("medical");
                }
                filename = "medical\\" + hn + "_" + bc.vsdate + "_" + bc.preno + "_" + status + ".rtf";
                SaveDocumentMedicalExamination(filename);
                Application.DoEvents();
                Thread.Sleep(200);
                if (File.Exists(filename))
                {
                    ext = Path.GetExtension(filename);
                    FtpClient ftp = new FtpClient(bc.iniC.hostFTP, bc.iniC.userFTP, bc.iniC.passFTP, bc.ftpUsePassive);
                    DocScan   dsc = new DocScan();
                    dsc.active       = "1";
                    dsc.doc_scan_id  = "";
                    dsc.doc_group_id = "";
                    dsc.hn           = bc.hn;
                    //dsc.vn = dt.Rows[0]["MNC_VN_NO"].ToString() + "/" + dt.Rows[0]["MNC_VN_SEQ"].ToString() + "(" + dt.Rows[0]["MNC_VN_SUM"].ToString() + ")";
                    dsc.an = "";

                    dsc.visit_date = bc.vsdate;
                    dsc.host_ftp   = bc.iniC.hostFTP;
                    //dsc.image_path = txtHn.Text + "//" + txtHn.Text + "_" + dgssid + "_" + dsc.row_no + "." + ext[ext.Length - 1];
                    dsc.image_path       = "";
                    dsc.doc_group_sub_id = "";
                    dsc.pre_no           = bc.preno;

                    dsc.folder_ftp = bc.iniC.folderFTP;
                    //    dsc.status_ipd = chkIPD.Checked ? "I" : "O";
                    dsc.row_no         = "1";
                    dsc.row_cnt        = "1";
                    dsc.status_version = "2";
                    dsc.req_id         = "";
                    dsc.date_req       = "";
                    dsc.status_ipd     = "0";
                    //dsc.ml_fm = "FM-LAB-999";
                    if (status.Equals("cc"))
                    {
                        dsc.ml_fm = "FM-MED-900";       //
                    }
                    else if (status.Equals("me"))
                    {
                        dsc.ml_fm = "FM-MED-901";       //
                    }
                    else if (status.Equals("diag"))
                    {
                        dsc.ml_fm = "FM-MED-902";       //
                    }
                    bc.bcDB.dscDB.voidDocScanByStatusMedicalExamination(hn, dsc.ml_fm, bc.vsdate, bc.preno, bc.cStf.staff_id);
                    dsc.patient_fullname = ptt.Name;
                    dsc.status_record    = "5";     // status medical diagnose
                    dsc.comp_labout_id   = "";
                    String re = bc.bcDB.dscDB.insertMedicalExamination(dsc, bc.userId);
                    dsc.image_path = hn + "//" + status + "_" + bc.hn + "_" + bc.vsdate + "_" + bc.preno + "_" + re + ext;
                    String re1 = bc.bcDB.dscDB.updateImagepath(dsc.image_path, re);
                    ftp.createDirectory(bc.iniC.folderFTP + "//" + hn.Replace("/", "-"));       // สร้าง Folder HN
                    ftp.delete(bc.iniC.folderFTP + "//" + dsc.image_path);
                    Thread.Sleep(200);
                    if (ftp.upload(bc.iniC.folderFTP + "//" + dsc.image_path, filename))
                    {
                    }
                }
            }
        }
コード例 #24
0
        private void GrfHn_DoubleClick(object sender, EventArgs e)
        {
            //throw new NotImplementedException();
            String dscid = "";

            if (grfHn.Row <= 0)
            {
                return;
            }
            if (grfHn.Col <= 0)
            {
                return;
            }

            dscid = grfHn[grfHn.Row, colId].ToString();
            DocScan dsc = new DocScan();

            dsc = bc.bcDB.dscDB.selectByPk(dscid);
            if (!dsc.doc_scan_id.Equals(""))
            {
                if (!Directory.Exists("report"))
                {
                    Directory.CreateDirectory("report");
                }
                MemoryStream stream;
                int          bufferSize = 2048;
                Stream       ftpStream = null;
                String       dgssid = "", filename = "", ftphost = "", id = "", folderftp = "", datetick = "";
                datetick = DateTime.Now.Ticks.ToString();
                stream   = new MemoryStream();
                FtpWebRequest  ftpRequest  = null;
                FtpWebResponse ftpResponse = null;
                FtpClient      ftpc        = new FtpClient(dsc.host_ftp, bc.iniC.userFTP, bc.iniC.passFTP, bc.ftpUsePassive);

                stream = ftpc.download(dsc.folder_ftp + "/" + dsc.image_path);
                if (stream == null)
                {
                    return;
                }
                if (stream.Length == 0)
                {
                    return;
                }
                stream.Seek(0, SeekOrigin.Begin);
                var fileStream = new FileStream("report\\" + datetick + ".pdf", FileMode.Create, FileAccess.Write);
                stream.CopyTo(fileStream);
                fileStream.Flush();
                fileStream.Dispose();
                Application.DoEvents();
                Thread.Sleep(200);

                Form frm = new Form();
                frm.Size          = new Size(600, 800);
                frm.StartPosition = FormStartPosition.CenterScreen;
                Panel pn = new Panel();
                pn.Dock = DockStyle.Fill;
                frm.Controls.Add(pn);
                string     currentDirectory = Directory.GetCurrentDirectory();
                WebBrowser webb             = new WebBrowser();
                webb.Dock = DockStyle.Fill;
                webb.Name = "webBrowser1";
                pn.Controls.Add(webb);
                webb.Navigate(currentDirectory + "\\report\\" + datetick + ".pdf");

                frm.ShowDialog(this);
            }
        }
コード例 #25
0
        private void uploadFiletoServerInnoTech()
        {
            timer.Stop();
            listBox2.Items.Clear();     //listBox3
            Application.DoEvents();
            Thread.Sleep(1000);

            FtpClient ftp = new FtpClient(bc.iniC.hostFTP, bc.iniC.userFTP, bc.iniC.passFTP, bc.ftpUsePassive);
            //String[] filePaths = Directory.GetFiles(bc.iniC.pathLabOutReceive, "*.*", SearchOption.TopDirectoryOnly);
            List <String> filePaths = new List <String>();
            DirectoryInfo d         = new DirectoryInfo(bc.iniC.pathLabOutReceiveInnoTech);//Assuming Test is your Folder

            DirectoryInfo[] dirs = d.GetDirectories();
            foreach (DirectoryInfo diNext in dirs)
            {
                Console.WriteLine("The number of files in {0} is {1}", diNext, diNext.GetFiles().Length);
                FileInfo[] Files = diNext.GetFiles("*.*"); //Getting Text files
                string     str   = "";
                foreach (FileInfo file in Files)
                {
                    filePaths.Add(file.FullName);
                }
            }
            String dgssid = "";

            dgssid = bc.bcDB.dgssDB.getIdDgss("Document Other");
            DocGroupSubScan dgss = new DocGroupSubScan();

            dgss = bc.bcDB.dgssDB.selectByPk(dgssid);
            foreach (String filename in filePaths)
            {
                listBox2.Items.Add("พบ file " + filename);
                Application.DoEvents();
                int    year2 = 0;
                String yy = "", mm = "", dd = "", reqid = "", vn = "", filename1 = "", filename2 = "", year1 = "", ext = "";
                String pathname = "", tmp = "";
                tmp       = bc.iniC.pathLabOutReceiveInnoTech.Replace("\\\\", "\\");
                filename1 = Path.GetFileName(filename);
                pathname  = filename.Replace(filename1, "").Replace(tmp, "").Replace("\\", "");
                pathname  = pathname.Replace("\\", "");
                String[] txt = filename1.Split('_');
                if (txt.Length > 1)
                {
                    filename2 = txt[0];
                }
                else
                {
                    filename2 = filename1.Replace(".pdf", "");
                }
                ext = Path.GetExtension(filename1);

                if (filename2.Replace(".pdf", "").Length < 10)
                {
                    String datetick = "";
                    new LogWriter("e", "Filename ไม่ถูก FORMAT");
                    listBox2.Items.Add("Filename ไม่ถูก FORMAT " + filename);
                    //MessageBox.Show("Filename ไม่ถูก FORMAT", "");
                    datetick = DateTime.Now.Ticks.ToString();
                    if (!Directory.Exists(bc.iniC.pathLabOutBackupInnoTech))
                    {
                        Directory.CreateDirectory(bc.iniC.pathLabOutBackupInnoTech);
                    }
                    if (pathname.Length > 0)
                    {
                        if (!Directory.Exists(bc.iniC.pathLabOutBackupInnoTech + "\\" + pathname))
                        {
                            Directory.CreateDirectory(bc.iniC.pathLabOutBackupInnoTech + "\\" + pathname);
                        }
                    }
                    Thread.Sleep(200);
                    if (pathname.Length > 0)
                    {
                        File.Move(filename, bc.iniC.pathLabOutBackupInnoTech + "\\" + pathname + "\\err_" + filename2 + "_" + datetick + ext);
                    }
                    else
                    {
                        File.Move(filename, bc.iniC.pathLabOutBackupInnoTech + "\\err_" + filename2 + "_" + datetick + ext);
                    }
                    Thread.Sleep(1000);
                    continue;
                }
                if (filename2.Length <= 10)
                {
                    String datetick = "";
                    new LogWriter("e", "Filename ชื่อ File สั้นไป " + filename);
                    listBox2.Items.Add("Filename ชื่อ File สั้นไป " + filename);
                    //MessageBox.Show("Filename ไม่ถูก FORMAT", "");
                    datetick = DateTime.Now.Ticks.ToString();
                    if (!Directory.Exists(bc.iniC.pathLabOutBackupInnoTech))
                    {
                        Directory.CreateDirectory(bc.iniC.pathLabOutBackupInnoTech);
                    }
                    if (pathname.Length > 0)
                    {
                        if (!Directory.Exists(bc.iniC.pathLabOutBackupInnoTech + "\\" + pathname))
                        {
                            Directory.CreateDirectory(bc.iniC.pathLabOutBackupInnoTech + "\\" + pathname);
                        }
                    }
                    Thread.Sleep(200);
                    if (pathname.Length > 0)
                    {
                        File.Move(filename, bc.iniC.pathLabOutBackupInnoTech + "\\" + pathname + "\\err_" + filename2 + "_" + datetick + ext);
                    }
                    else
                    {
                        File.Move(filename, bc.iniC.pathLabOutBackupInnoTech + "\\err_" + filename2 + "_" + datetick + ext);
                    }
                    Thread.Sleep(1000);
                    continue;
                }
                DateTime dtt1 = new DateTime();
                int.TryParse(year1, out year2);
                yy    = filename2.Substring(filename2.Length - 5, 2);
                mm    = filename2.Substring(filename2.Length - 7, 2);
                dd    = filename2.Substring(filename2.Length - 9, 2);
                year1 = "20" + yy;
                if (!DateTime.TryParse(year1 + "-" + mm + "-" + dd, out dtt1))
                {
                    String datetick = "";
                    new LogWriter("e", "Filename ชื่อ File ไม่สามารถหา date ได้ " + filename);
                    listBox2.Items.Add("Filename ชื่อ File ไม่สามารถหา date ได้ " + filename);
                    //MessageBox.Show("Filename ไม่ถูก FORMAT", "");
                    datetick = DateTime.Now.Ticks.ToString();
                    if (!Directory.Exists(bc.iniC.pathLabOutBackupInnoTech))
                    {
                        Directory.CreateDirectory(bc.iniC.pathLabOutBackupInnoTech);
                    }
                    if (pathname.Length > 0)
                    {
                        if (!Directory.Exists(bc.iniC.pathLabOutBackupInnoTech + "\\" + pathname))
                        {
                            Directory.CreateDirectory(bc.iniC.pathLabOutBackupInnoTech + "\\" + pathname);
                        }
                    }
                    Thread.Sleep(200);
                    if (pathname.Length > 0)
                    {
                        File.Move(filename, bc.iniC.pathLabOutBackupInnoTech + "\\" + pathname + "\\err_" + filename2 + "_" + datetick + ext);
                    }
                    else
                    {
                        File.Move(filename, bc.iniC.pathLabOutBackupInnoTech + "\\err_" + filename2 + "_" + datetick + ext);
                    }
                    Thread.Sleep(1000);
                    continue;
                }
                reqid = filename2.Substring(filename2.Length - 3);

                DataTable dt = new DataTable();
                dt = bc.bcDB.vsDB.SelectHnLabOut(reqid, year1 + "-" + mm + "-" + dd);
                if (dt.Rows.Count <= 0)
                {
                    listBox2.Items.Add("Filename ไม่พบข้อมูล HIS " + filename);
                    Application.DoEvents();
                    String datetick = "";
                    new LogWriter("e", "Filename ไม่พบข้อมูล HIS");
                    //MessageBox.Show("Filename ไม่พบข้อมูล HIS", "");
                    datetick = DateTime.Now.Ticks.ToString();
                    if (!Directory.Exists(bc.iniC.pathLabOutBackupInnoTech))
                    {
                        Directory.CreateDirectory(bc.iniC.pathLabOutBackupInnoTech);
                    }
                    if (pathname.Length > 0)
                    {
                        if (!Directory.Exists(bc.iniC.pathLabOutBackupInnoTech + "\\" + pathname))
                        {
                            Directory.CreateDirectory(bc.iniC.pathLabOutBackupInnoTech + "\\" + pathname);
                        }
                    }
                    Thread.Sleep(200);
                    if (pathname.Length > 0)
                    {
                        File.Move(filename, bc.iniC.pathLabOutBackupInnoTech + "\\" + pathname + "\\err_" + filename2 + "_" + datetick + ext);
                    }
                    else
                    {
                        File.Move(filename, bc.iniC.pathLabOutBackupInnoTech + "\\err_" + filename2 + "_" + datetick + ext);
                    }
                    Thread.Sleep(1000);
                    continue;
                }
                listBox2.Items.Add("พบข้อมูล HIS " + dt.Rows[0]["mnc_hn_no"].ToString());
                Application.DoEvents();
                DocScan dsc = new DocScan();
                dsc.active       = "1";
                dsc.doc_scan_id  = "";
                dsc.doc_group_id = dgss.doc_group_id;
                dsc.hn           = dt.Rows[0]["mnc_hn_no"].ToString();
                dsc.vn           = dt.Rows[0]["MNC_VN_NO"].ToString() + "/" + dt.Rows[0]["MNC_VN_SEQ"].ToString() + "(" + dt.Rows[0]["MNC_VN_SUM"].ToString() + ")";
                dsc.an           = dt.Rows[0]["MNC_AN_NO"].ToString() + "/" + dt.Rows[0]["MNC_AN_YR"].ToString();
                if (dsc.an.Equals("/"))
                {
                    dsc.an = "";
                }
                dsc.visit_date = "";
                dsc.host_ftp   = bc.iniC.hostFTP;
                //dsc.image_path = txtHn.Text + "//" + txtHn.Text + "_" + dgssid + "_" + dsc.row_no + "." + ext[ext.Length - 1];
                dsc.image_path       = "";
                dsc.doc_group_sub_id = dgssid;
                dsc.pre_no           = dt.Rows[0]["mnc_pre_no"].ToString();
                //dsc.an = "";
                //DateTime dt = new DateTime();

                //    dsc.an_date = (DateTime.TryParse(txtAnDate.Text, out dt)) ? bc.datetoDB(txtAnDate.Text) : "";
                //    if (dsc.an_date.Equals("1-01-01"))
                //    {
                //        dsc.an_date = "";
                //    }
                dsc.folder_ftp = bc.iniC.folderFTP;
                //    dsc.status_ipd = chkIPD.Checked ? "I" : "O";
                dsc.row_no         = "1";
                dsc.row_cnt        = "1";
                dsc.status_version = "2";
                dsc.req_id         = dt.Rows[0]["mnc_req_no"].ToString();
                DateTime dtt = new DateTime();
                if (DateTime.TryParse(dt.Rows[0]["mnc_req_dat"].ToString(), out dtt))
                {
                    dsc.date_req = dtt.Year.ToString() + "-" + dtt.ToString("MM-dd");
                }
                else
                {
                    dsc.date_req = "";
                }
                if (dsc.an.Length > 0)
                {
                    dsc.status_ipd = "1";
                }
                else
                {
                    dsc.status_ipd = "0";
                }
                //dsc.ml_fm = "FM-LAB-999";
                if (pathname.Equals("ClinicalReport"))
                {
                    dsc.ml_fm = "FM-LAB-998";
                }
                else
                {
                    dsc.ml_fm = "FM-LAB-997";       //PathoReport
                }
                dsc.patient_fullname = dt.Rows[0]["mnc_patname"].ToString();
                dsc.status_record    = "2";
                String re = bc.bcDB.dscDB.insertLabOut(dsc, bc.userId);
                if (re.Length <= 0)
                {
                    listBox2.Items.Add("ไม่ได้เลขที่ " + filename);
                    Application.DoEvents();
                    String datetick = "";
                    new LogWriter("e", "ไม่ได้เลขที่ " + filename);
                    //MessageBox.Show("Filename ไม่พบข้อมูล HIS", "");
                    datetick = DateTime.Now.Ticks.ToString();
                    if (!Directory.Exists(bc.iniC.pathLabOutBackupInnoTech))
                    {
                        Directory.CreateDirectory(bc.iniC.pathLabOutBackupInnoTech);
                    }
                    if (pathname.Length > 0)
                    {
                        if (!Directory.Exists(bc.iniC.pathLabOutBackupInnoTech + "\\" + pathname))
                        {
                            Directory.CreateDirectory(bc.iniC.pathLabOutBackupInnoTech + "\\" + pathname);
                        }
                    }
                    Thread.Sleep(200);
                    if (pathname.Length > 0)
                    {
                        File.Move(filename, bc.iniC.pathLabOutBackupInnoTech + "\\" + pathname + "\\err_" + filename2 + "_" + datetick + ext);
                    }
                    else
                    {
                        File.Move(filename, bc.iniC.pathLabOutBackupInnoTech + "\\err_" + filename2 + "_" + datetick + ext);
                    }
                    Thread.Sleep(1000);
                    continue;
                }
                listBox2.Items.Add("ได้เลขที่ " + re);
                Application.DoEvents();
                dsc.image_path = dt.Rows[0]["mnc_hn_no"].ToString() + "//" + dt.Rows[0]["mnc_hn_no"].ToString() + "_" + re + ext;
                //    if (chkIPD.Checked)
                //    {
                //        vn = txtAN.Text.Replace("/", "_").Replace("(", "_").Replace(")", "");
                //    }
                //    else
                //    {
                vn = dsc.vn.Replace("/", "_").Replace("(", "_").Replace(")", "");
                if (pathname.Equals("ClinicalReport"))
                {
                    dsc.ml_fm = "FM-LAB-998";
                }
                else
                {
                    dsc.ml_fm = "FM-LAB-997";       //PathoReport
                }
                //    }
                //    //dsc.image_path = txtHn.Text.Replace("/", "-") + "-" + vn + "//" + txtHn.Text.Replace("/", "-") + "-" + vn + "-" + re + ext;       //-1
                dsc.image_path = dt.Rows[0]["mnc_hn_no"].ToString().Replace("/", "-") + "//" + dt.Rows[0]["mnc_hn_no"].ToString().Replace("/", "-") + "-" + vn + "-" + re + ext;         //+1

                String re1 = bc.bcDB.dscDB.updateImagepath(dsc.image_path, re);
                listBox2.Items.Add("updateImagepath " + dsc.image_path);
                Application.DoEvents();
                //    //MessageBox.Show("111", "");

                ftp.createDirectory(bc.iniC.folderFTP + "//" + dt.Rows[0]["mnc_hn_no"].ToString().Replace("/", "-"));       // สร้าง Folder HN
                //    ftp.createDirectory(bc.iniC.folderFTP + "//" + txtHn.Text.Replace("/", "-") + "//" + txtHn.Text.Replace("/", "-") + "-" + vn);
                //    //MessageBox.Show("222", "");
                ftp.delete(bc.iniC.folderFTP + "//" + dsc.image_path);
                //    //MessageBox.Show("333", "");
                Thread.Sleep(200);
                if (ftp.upload(bc.iniC.folderFTP + "//" + dsc.image_path, filename))
                {
                    listBox2.Items.Add("FTP upload success ");
                    Application.DoEvents();
                    Thread.Sleep(1000);
                    String datetick = "";
                    datetick = DateTime.Now.Ticks.ToString();
                    if (!Directory.Exists(bc.iniC.pathLabOutBackupInnoTech))
                    {
                        Directory.CreateDirectory(bc.iniC.pathLabOutBackupInnoTech);
                    }
                    if (pathname.Length > 0)
                    {
                        if (!Directory.Exists(bc.iniC.pathLabOutBackupInnoTech + "\\" + pathname))
                        {
                            Directory.CreateDirectory(bc.iniC.pathLabOutBackupInnoTech + "\\" + pathname);
                        }
                    }
                    Thread.Sleep(1000);
                    if (pathname.Length > 0)
                    {
                        File.Move(filename, bc.iniC.pathLabOutBackupInnoTech + "\\" + pathname + "\\" + filename2 + "_" + datetick + ext);
                    }
                    else
                    {
                        File.Move(filename, bc.iniC.pathLabOutBackupInnoTech + "\\" + filename2 + "_" + datetick + ext);
                    }
                    listBox1.BeginUpdate();                                                                                     //listBox2
                    listBox1.Items.Add(filename + " -> " + bc.iniC.hostFTP + "//" + bc.iniC.folderFTP + "//" + dsc.image_path); //listBox2
                    listBox1.EndUpdate();                                                                                       //listBox2
                    Application.DoEvents();
                    Thread.Sleep(1000 * 60);
                }
                else
                {
                    listBox2.Items.Add("FTP upload success ");
                    Application.DoEvents();
                    new LogWriter("e", "FTP upload no success");
                }
            }
            timer.Start();
        }