Exemplo n.º 1
0
        private void initConfig()
        {
            pageLoad = true;
            dgss     = new DocGroupSubScan();
            dfm      = new DocGroupFM();

            fEdit  = new Font(bc.iniC.grdViewFontName, bc.grdViewFontSize, FontStyle.Regular);
            fEditB = new Font(bc.iniC.grdViewFontName, bc.grdViewFontSize, FontStyle.Bold);

            C1ThemeController.ApplicationTheme = bc.iniC.themeApplication;
            theme1.Theme = C1ThemeController.ApplicationTheme;
            theme1.SetTheme(sB, "BeigeOne");
            bg = txtFmCode.BackColor;
            fc = txtFmCode.ForeColor;
            ff = txtFmCode.Font;
            bc.bcDB.dgssDB.setCboDGSS(cboDocGroupSubName, "");
            bc.bcDB.dgsDB.setCboDgs(cboDocGroupName, "");

            sB.Text = "";
            btnVoid.Hide();
            txtPasswordVoid.Hide();
            stt                    = new C1SuperTooltip();
            sep                    = new C1SuperErrorProvider();
            btnNew.Click          += BtnNew_Click;
            btnEdit.Click         += BtnEdit_Click;
            btnSave.Click         += BtnSave_Click;
            txtPasswordVoid.KeyUp += TxtPasswordVoid_KeyUp;
            cboDocGroupName.SelectedIndexChanged += CboDocGroupName_SelectedIndexChanged;

            initGrfFMCode();
            setGrfFMCode();
            setControlEnable(false);
            setFocusColor();
            pageLoad = false;
        }
Exemplo n.º 2
0
        private void initConfig()
        {
            dgss   = new DocGroupSubScan();
            fEdit  = new Font(ic.iniC.grdViewFontName, ic.grdViewFontSize, FontStyle.Regular);
            fEditB = new Font(ic.iniC.grdViewFontName, ic.grdViewFontSize, FontStyle.Bold);

            C1ThemeController.ApplicationTheme = ic.iniC.themeApplication;
            theme1.Theme = C1ThemeController.ApplicationTheme;
            theme1.SetTheme(sB, "BeigeOne");
            foreach (Control c in panel3.Controls)
            {
                theme1.SetTheme(c, "Office2013Red");
            }

            bg = txtDocGroupSubName.BackColor;
            fc = txtDocGroupSubName.ForeColor;
            ff = txtDocGroupSubName.Font;
            ic.ivfDB.dgsDB.setCboBsp(cboDocGroupName, "");

            txtPasswordVoid.KeyUp += TxtPasswordVoid_KeyUp;
            btnNew.Click          += BtnNew_Click;
            btnEdit.Click         += BtnEdit_Click;
            btnSave.Click         += BtnSave_Click;

            initGrfPosi();
            setGrfPosi();
            setControlEnable(false);
            setFocusColor();
            sB1.Text = "";
            btnVoid.Hide();
            txtPasswordVoid.Hide();
            stt = new C1SuperTooltip();
            sep = new C1SuperErrorProvider();
        }
Exemplo n.º 3
0
 private void setControl(String posiId)
 {
     dgss = ic.ivfDB.dgssDB.selectByPk(posiId);
     ic.setC1Combo(cboDocGroupName, dgss.doc_group_id);
     txtID.Value = dgss.doc_group_sub_id;
     txtDocGroupSubName.Value = dgss.doc_group_sub_name;
 }
Exemplo n.º 4
0
 public DocGroupSubScan setDocGroupSubScan(DocGroupSubScan dgs1)
 {
     dgs1.active             = "";
     dgs1.remark             = "";
     dgs1.doc_group_sub_name = "";
     dgs1.doc_group_id       = "";
     dgs1.doc_group_sub_id   = "";
     return(dgs1);
 }
        public DataTable selectByPk1(String id)
        {
            DocGroupSubScan cop1 = new DocGroupSubScan();
            DataTable       dt   = new DataTable();
            String          sql  = "select * " +
                                   "From " + dgss.table + " dgss " +
                                   //"Left Join f_patient_prefix pfx On stf.prefix_id = pfx.f_patient_prefix_id " +
                                   "Where dgss." + dgss.pkField + " ='" + id + "' " +
                                   "Order By doc_group_id ";

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

            return(dt);
        }
Exemplo n.º 6
0
        private void initConfig()
        {
            dgss  = new DocGroupSubScan();
            lDgss = new List <DocGroupSubScan>();

            dgss.doc_group_sub_id   = "doc_group_sub_id";
            dgss.active             = "active";
            dgss.doc_group_sub_name = "doc_group_sub_name";
            dgss.doc_group_id       = "doc_group_id";
            dgss.remark             = "remark";

            dgss.table   = "b_doc_group_sub_scan";
            dgss.pkField = "doc_group_sub_id";
        }
        public String insertDocGroupSubScan(DocGroupSubScan p, String userId)
        {
            String re = "";

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

            return(re);
        }
Exemplo n.º 8
0
        public DocGroupSubScan setDocGroupSubScan(DataTable dt)
        {
            DocGroupSubScan dgs1 = new DocGroupSubScan();

            if (dt.Rows.Count > 0)
            {
                dgs1.doc_group_sub_id   = dt.Rows[0][dgss.doc_group_sub_id].ToString();
                dgs1.doc_group_id       = dt.Rows[0][dgss.doc_group_id].ToString();
                dgs1.doc_group_sub_name = dt.Rows[0][dgss.doc_group_sub_name].ToString();
                dgs1.remark             = dt.Rows[0][dgss.remark].ToString();
                dgs1.active             = dt.Rows[0][dgss.active].ToString();
            }
            else
            {
                setDocGroupSubScan(dgs1);
            }
            return(dgs1);
        }
        public void getlBsp()
        {
            //lDept = new List<Position>();

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

            dt = selectAll();
            foreach (DataRow row in dt.Rows)
            {
                DocGroupSubScan itm1 = new DocGroupSubScan();
                itm1.active             = row[dgss.active].ToString();
                itm1.doc_group_sub_name = row[dgss.doc_group_sub_name].ToString();
                itm1.doc_group_id       = row[dgss.doc_group_id].ToString();
                itm1.remark             = row[dgss.remark].ToString();

                itm1.doc_group_sub_id = row[dgss.doc_group_sub_id].ToString();
                lDgss.Add(itm1);
            }
        }
Exemplo n.º 10
0
        public String update(DocGroupSubScan p, String userId)
        {
            String re  = "";
            String sql = "";
            int    chk = 0;

            sql = "Update " + dgss.table + " Set " +
                  " " + dgss.doc_group_sub_name + " = '" + p.doc_group_sub_name.Replace("'", "''") + "'" +

                  "Where " + dgss.pkField + "='" + p.doc_group_sub_id + "'"
            ;

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

            return(re);
        }
Exemplo n.º 11
0
        public String insert(DocGroupSubScan p, String userId)
        {
            String re  = "";
            String sql = "";

            p.active = "1";
            //p.ssdata_id = "";
            int chk = 0;

            sql = "Insert Into " + dgss.table + " (" + dgss.doc_group_sub_name + "," + dgss.active + "," + dgss.doc_group_id + "," + dgss.dept_us +
                  ") " +
                  "Values ('" + p.doc_group_sub_name.Replace("'", "''") + "','1','" + p.doc_group_id + "','" + p.dept_us + "' " +
                  ")";
            try
            {
                re = conn.ExecuteNonQuery(conn.conn, sql);
            }
            catch (Exception ex)
            {
                sql = ex.Message + " " + ex.InnerException;
            }

            return(re);
        }
Exemplo n.º 12
0
        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)
            {
            }
        }
Exemplo n.º 13
0
        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 รูป เวชระเบียน เรียบร้อย", "");
                }
            }
        }
        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();
            }
        }
Exemplo n.º 15
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();
        }
Exemplo n.º 16
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();
        }