private void ContextMenu_grfscan__print(object sender, System.EventArgs e) { String id = ""; if (grfScan.Col <= 0) { return; } if (grfScan.Row < 0) { return; } if (grfScan.Col == 1) { id = grfScan[grfScan.Row, colPic2].ToString(); } else { id = grfScan[grfScan.Row, colPic4].ToString(); } dsc_id = id; MemoryStream strm = null; foreach (listStream lstrmm in lStream) { if (lstrmm.id.Equals(id)) { strm = lstrmm.stream; streamPrint = lstrmm.stream; break; } } setGrfScanToPrint(false); //MessageBox.Show("row "+ grfScan.Row+"\n"+"col "+grfScan.Col+"\n ", ""); }
private void Grf_DoubleClick(object sender, EventArgs e) { //throw new NotImplementedException(); MessageBox.Show("Row " + ((C1FlexGrid)sender).Row + "\n grf name " + ((C1FlexGrid)sender).Name, "Col " + ((C1FlexGrid)sender).Col + " id " + ((C1FlexGrid)sender)[((C1FlexGrid)sender).Row, colPic2].ToString()); String id = ""; id = ((C1FlexGrid)sender)[((C1FlexGrid)sender).Row, colPic2].ToString(); MemoryStream strm = null; foreach (listStream lstrmm in lStream) { if (lstrmm.id.Equals(id)) { strm = lstrmm.stream; break; } } if (strm != null) { img = Image.FromStream(strm); frmImg = new Form(); FlowLayoutPanel pn = new FlowLayoutPanel(); //vScroller = new VScrollBar(); //vScroller.Height = frmImg.Height; //vScroller.Width = 15; //vScroller.Dock = DockStyle.Right; frmImg.WindowState = FormWindowState.Normal; frmImg.StartPosition = FormStartPosition.CenterScreen; frmImg.Size = new Size(1024, 764); frmImg.AutoScroll = true; pn.Dock = DockStyle.Fill; pn.AutoScroll = true; pic = new C1PictureBox(); pic.Dock = DockStyle.Fill; pic.SizeMode = PictureBoxSizeMode.AutoSize; //int newWidth = 440; int originalWidth = 0; originalHeight = 0; originalWidth = img.Width; originalHeight = img.Height; //resizedImage = img.GetThumbnailImage(newWidth, (newWidth * img.Height) / originalWidth, null, IntPtr.Zero); resizedImage = img.GetThumbnailImage((newHeight * img.Width) / originalHeight, newHeight, null, IntPtr.Zero); pic.Image = resizedImage; frmImg.Controls.Add(pn); pn.Controls.Add(pic); //pn.Controls.Add(vScroller); mouseWheel = 0; pic.MouseWheel += Pic_MouseWheel; //vScroller.Scroll += VScroller_Scroll; //pic.Paint += Pic_Paint; //vScroller.Hide(); frmImg.ShowDialog(this); } }
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"); }
private void initConfig() { fEdit = new Font(bc.iniC.grdViewFontName, bc.grdViewFontSize, FontStyle.Regular); fEditB = new Font(bc.iniC.grdViewFontName, bc.grdViewFontSize, FontStyle.Bold); lStream = new List <listStream>(); lStreamPic = new List <listStream>(); strm = new listStream(); InitComponent(); setGrfLeft(); this.Load += FrmDocGroupFmEdit_Load; btnUpdate.Click += BtnUpdate_Click; btnFmCode.Click += BtnFmCode_Click; txtMlFmCode.Enter += TxtMlFmCode_Enter; txtMlFmCodeNew.Enter += TxtMlFmCodeNew_Enter; txtMlFmCodeNew.EnabledChanged += TxtMlFmCodeNew_EnabledChanged; }
private void ContextMenu_grfscan_print_all(object sender, System.EventArgs e) { //FrmWaiting frmW = new FrmWaiting(); //frmW.StartPosition = FormStartPosition.CenterScreen; //frmW.ShowDialog(this); int i = 0; foreach (Row row in grfScan.Rows) { String id = ""; if (i == 0) { id = row[colPic2] != null ? row[colPic2].ToString() : ""; i = 1; } else { id = row[colPic4] != null ? row[colPic4].ToString() : ""; i = 0; } if (id == "") { continue; } dsc_id = id; MemoryStream strm = null; foreach (listStream lstrmm in lStream) { if (lstrmm.id.Equals(id)) { strm = lstrmm.stream; streamPrint = lstrmm.stream; break; } } setGrfScanToPrint(false); } //frmW.Dispose(); }
private void initConfig() { fEdit = new Font(bc.iniC.grdViewFontName, bc.grdViewFontSize, FontStyle.Regular); fEditB = new Font(bc.iniC.grdViewFontName, bc.grdViewFontSize, FontStyle.Bold); bc.bcDB.dgsDB.setCboDgs(cboDgs, ""); array1 = new ArrayList(); lStream = new List <listStream>(); strm = new listStream(); grfOrder = new C1FlexGrid(); //timer1 = new Timer(); //int chk = 0; //int.TryParse(bc.iniC.timerImgScanNew, out chk); //timer1.Interval = chk; //timer1.Enabled = true; //timer1.Tick += Timer1_Tick; //timer1.Stop(); theme1.SetTheme(sb1, "ExpressionDark"); theme1.SetTheme(groupBox1, "ExpressionDark"); theme1.SetTheme(panel2, "ExpressionDark"); theme1.SetTheme(panel3, "ExpressionDark"); foreach (Control con in groupBox1.Controls) { theme1.SetTheme(con, "ExpressionDark"); } //foreach (Control con in grfScan.Controls) //{ // theme1.SetTheme(con, "ExpressionDark"); //} initGrf(); txtHn.Value = hn; setGrf(); btnHn.Click += BtnHn_Click; btnOpen.Click += BtnOpen_Click; btnRefresh.Click += BtnRefresh_Click; txtHn.KeyUp += TxtHn_KeyUp; tcDtr = new C1DockingTab(); tcDtr.Dock = System.Windows.Forms.DockStyle.Fill; tcDtr.Location = new System.Drawing.Point(0, 266); tcDtr.Name = "c1DockingTab1"; tcDtr.Size = new System.Drawing.Size(669, 200); tcDtr.TabIndex = 0; tcDtr.TabsSpacing = 5; panel3.Controls.Add(tcDtr); tabScan = new C1DockingTabPage(); tabScan.Location = new System.Drawing.Point(1, 24); //tabScan.Name = "c1DockingTabPage1"; tabScan.Size = new System.Drawing.Size(667, 175); tabScan.TabIndex = 0; tabScan.Text = "ใบยา / Staff's Note"; tabScan.Name = "tabPageScan"; tcDtr.Controls.Add(tabScan); tabOrder = new C1DockingTabPage(); tabOrder.Location = new System.Drawing.Point(1, 24); //tabScan.Name = "c1DockingTabPage1"; tabOrder.Size = new System.Drawing.Size(667, 175); tabOrder.TabIndex = 0; tabOrder.Text = "ประวัติการสั่งการ"; tabOrder.Name = "tabOrder"; tcDtr.Controls.Add(tabOrder); grfOrder.Font = fEdit; grfOrder.Dock = System.Windows.Forms.DockStyle.Fill; grfOrder.Location = new System.Drawing.Point(0, 0); grfOrder.Rows[0].Visible = false; grfOrder.Cols[0].Visible = false; grfOrder.Cols[colOrderId].Visible = false; grfOrder.Rows.Count = 1; grfOrder.Cols.Count = 5; grfOrder.Cols[colOrderName].Caption = "ชื่อ"; grfOrder.Cols[colOrderMed].Caption = "-"; grfOrder.Cols[colOrderQty].Caption = "QTY"; grfOrder.Cols[colOrderName].Width = 300; grfOrder.Cols[colOrderMed].Width = 200; grfOrder.Cols[colOrderQty].Width = 60; grfOrder.Name = "grfOrder"; theme1.SetTheme(grfOrder, "Office2016Black"); tabOrder.Controls.Add(grfOrder); setPicStaffNote(); theme1.SetTheme(tcDtr, theme1.Theme); int i = 0; String idOld = ""; if (bc.bcDB.dgssDB.lDgss.Count <= 0) { bc.bcDB.dgssDB.getlBsp(); } foreach (DocGroupSubScan dgss in bc.bcDB.dgssDB.lDgss) { String dgsid = ""; dgsid = bc.bcDB.dgssDB.getDgsIdDgss(dgss.doc_group_sub_name); if (!dgsid.Equals(idOld)) { idOld = dgsid; String name = ""; name = bc.bcDB.dgsDB.getNameDgs(dgss.doc_group_id); C1DockingTabPage tabPage = new C1DockingTabPage(); tabPage.Location = new System.Drawing.Point(1, 24); tabPage.Size = new System.Drawing.Size(667, 175); tabPage.TabIndex = 0; tabPage.Text = " " + name + " "; tabPage.Name = dgsid; tcDtr.Controls.Add(tabPage); i++; C1DockingTab tabDtr1 = new C1DockingTab(); tabDtr1.Dock = System.Windows.Forms.DockStyle.Fill; tabDtr1.Location = new System.Drawing.Point(0, 266); tabDtr1.Name = "c1DockingTab1"; tabDtr1.Size = new System.Drawing.Size(669, 200); tabDtr1.TabIndex = 0; tabDtr1.TabsSpacing = 5; tabPage.Controls.Add(tabDtr1); theme1.SetTheme(tabDtr1, "Office2010Red"); foreach (DocGroupSubScan dgsss in bc.bcDB.dgssDB.lDgss) { if (dgsss.doc_group_id.Equals(dgss.doc_group_id)) { //addDevice.MenuItems.Add(new MenuItem(dgsss.doc_group_sub_name, new EventHandler(ContextMenu_upload))); C1DockingTabPage tabPage2 = new C1DockingTabPage(); tabPage2.Location = new System.Drawing.Point(1, 24); tabPage2.Size = new System.Drawing.Size(667, 175); tabPage2.TabIndex = 0; tabPage2.Text = " " + dgsss.doc_group_sub_name + " "; tabPage2.Name = "tab" + dgsss.doc_group_sub_id; tabDtr1.Controls.Add(tabPage2); C1FlexGrid grf = new C1FlexGrid(); grf.Font = fEdit; grf.Dock = System.Windows.Forms.DockStyle.Fill; grf.Location = new System.Drawing.Point(0, 0); grf.Rows[0].Visible = false; grf.Cols[0].Visible = false; grf.Rows.Count = 1; grf.Name = dgsss.doc_group_sub_id; grf.Cols.Count = 5; Column colpic1 = grf.Cols[colPic1]; colpic1.DataType = typeof(Image); Column colpic2 = grf.Cols[colPic2]; colpic2.DataType = typeof(String); Column colpic3 = grf.Cols[colPic3]; colpic3.DataType = typeof(Image); Column colpic4 = grf.Cols[colPic4]; colpic4.DataType = typeof(Image); grf.Cols[colPic1].Width = 310; grf.Cols[colPic2].Width = 310; grf.Cols[colPic3].Width = 310; grf.Cols[colPic4].Width = 310; grf.ShowCursor = true; grf.Cols[colPic2].Visible = false; grf.Cols[colPic3].Visible = true; grf.Cols[colPic4].Visible = false; grf.Cols[colPic1].AllowEditing = false; grf.Cols[colPic3].AllowEditing = false; grf.DoubleClick += Grf_DoubleClick; tabPage2.Controls.Add(grf); } } } else { } } }
private void GrfVs_AfterRowColChange(object sender, RangeEventArgs e) { //throw new NotImplementedException(); if (e.NewRange.r1 < 0) { return; } if (e.NewRange.Data == null) { return; } if (txtHn.Text.Equals("")) { return; } panel2.Enabled = false; ProgressBar pB1 = new ProgressBar(); pB1.Location = new System.Drawing.Point(113, 36); pB1.Name = "pB1"; pB1.Size = new System.Drawing.Size(862, 23); groupBox1.Controls.Add(pB1); pB1.Left = txtVN.Left; pB1.Show(); txtVN.Hide(); btnVn.Hide(); btnRefresh.Hide(); txt.Hide(); label6.Hide(); txtVisitDate.Hide(); chkIPD.Hide(); //txtPreNo.Hide(); clearGrf(); String statusOPD = "", vsDate = "", vn = "", an = "", anDate = "", hn = "", preno = ""; statusOPD = grfVs[e.NewRange.r1, colVsStatus] != null ? grfVs[e.NewRange.r1, colVsStatus].ToString() : ""; preno = grfVs[e.NewRange.r1, colVsPreno] != null ? grfVs[e.NewRange.r1, colVsPreno].ToString() : ""; vsDate = grfVs[e.NewRange.r1, colVsVsDate] != null ? grfVs[e.NewRange.r1, colVsVsDate].ToString() : ""; txtVisitDate.Value = vsDate; if (statusOPD.Equals("OPD")) { chkIPD.Checked = false; vn = grfVs[e.NewRange.r1, colVsVn] != null ? grfVs[e.NewRange.r1, colVsVn].ToString() : ""; txtVN.Value = vn; label2.Text = "VN :"; } else { chkIPD.Checked = true; an = grfVs[e.NewRange.r1, colVsAn] != null ? grfVs[e.NewRange.r1, colVsAn].ToString() : ""; anDate = grfVs[e.NewRange.r1, colVsAndate] != null ? grfVs[e.NewRange.r1, colVsAndate].ToString() : ""; txtVN.Value = an; label2.Text = "AN :"; txtVisitDate.Value = anDate; } setStaffNote(vsDate, preno); DataTable dtOrder = new DataTable(); vn = grfVs[e.NewRange.r1, colVsVn] != null ? grfVs[e.NewRange.r1, colVsVn].ToString() : ""; if (vn.IndexOf("(") > 0) { vn = vn.Substring(0, vn.IndexOf("(")); } if (vn.IndexOf("/") > 0) { vn = vn.Substring(0, vn.IndexOf("/")); } Application.DoEvents(); dtOrder = bc.bcDB.vsDB.selectDrugOPD(txtHn.Text, vn, preno, bc.datetoDB(vsDate)); grfOrder.Rows.Count = 1; if (dtOrder.Rows.Count > 0) { try { pB1.Value = 0; pB1.Minimum = 0; pB1.Maximum = dtOrder.Rows.Count; foreach (DataRow row in dtOrder.Rows) { Row rowg = grfOrder.Rows.Add(); rowg[colOrderName] = row["MNC_PH_TN"].ToString(); rowg[colOrderMed] = ""; rowg[colOrderQty] = row["qty"].ToString(); pB1.Value++; } } catch (Exception ex) { MessageBox.Show("" + ex.Message, ""); } } GC.Collect(); DataTable dt = new DataTable(); dt = bc.bcDB.dscDB.selectByAn(txtHn.Text, an); if (dt.Rows.Count > 0) { try { pB1.Value = 0; pB1.Minimum = 0; pB1.Maximum = dt.Rows.Count; //MemoryStream stream; //Image loadedImage, resizedImage; C1FlexGrid grf1; FtpClient ftp = new FtpClient(bc.iniC.hostFTP, bc.iniC.userFTP, bc.iniC.passFTP); Boolean findTrue = false; int colcnt = 0; foreach (DataRow row in dt.Rows) { if (findTrue) { break; } colcnt++; if (colcnt >= 2) { colcnt = 0; } String dgssid = "", filename = "", ftphost = "", id = "", folderftp = ""; id = row[bc.bcDB.dscDB.dsc.doc_scan_id].ToString(); dgssid = row[bc.bcDB.dscDB.dsc.doc_group_sub_id].ToString(); filename = row[bc.bcDB.dscDB.dsc.image_path].ToString(); ftphost = row[bc.bcDB.dscDB.dsc.host_ftp].ToString(); folderftp = row[bc.bcDB.dscDB.dsc.folder_ftp].ToString(); foreach (Control con in panel3.Controls) { if (findTrue) { break; } if (con is C1DockingTab) { foreach (Control cond in con.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 (congd1 is C1FlexGrid) { if (congd1.Name.Equals(dgssid)) { new Thread(() => { String err = ""; try { FtpWebRequest ftpRequest = null; FtpWebResponse ftpResponse = null; Stream ftpStream = null; int bufferSize = 2048; err = "00"; grf1 = (C1FlexGrid)congd1; Row rowd; if (colcnt == 1) { err = "001"; //grfPtt.Rows[i].StyleNew.BackColor = color; rowd = grf1.Rows.Add(); } else { err = "002"; if (grf1.Rows.Count == 0) { err = "0021"; rowd = grf1.Rows.Add(); } else { err = "0022"; rowd = grf1.Rows[grf1.Rows.Count - 1]; } } MemoryStream stream; Image loadedImage, resizedImage; stream = new MemoryStream(); //stream = ftp.download(folderftp + "//" + filename); //loadedImage = Image.FromFile(filename); err = "01"; ftpRequest = (FtpWebRequest)FtpWebRequest.Create(ftphost + "/" + folderftp + "/" + filename); ftpRequest.Credentials = new NetworkCredential(bc.iniC.userFTP, bc.iniC.passFTP); ftpRequest.UseBinary = true; ftpRequest.UsePassive = bc.ftpUsePassive; ftpRequest.KeepAlive = true; ftpRequest.Method = WebRequestMethods.Ftp.DownloadFile; ftpResponse = (FtpWebResponse)ftpRequest.GetResponse(); ftpStream = ftpResponse.GetResponseStream(); err = "02"; byte[] byteBuffer = new byte[bufferSize]; int bytesRead = ftpStream.Read(byteBuffer, 0, bufferSize); try { while (bytesRead > 0) { stream.Write(byteBuffer, 0, bytesRead); bytesRead = ftpStream.Read(byteBuffer, 0, bufferSize); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } err = "03"; loadedImage = new Bitmap(stream); err = "04"; int originalWidth = 0; originalWidth = loadedImage.Width; int newWidth = 600; resizedImage = loadedImage.GetThumbnailImage(newWidth, (newWidth * loadedImage.Height) / originalWidth, null, IntPtr.Zero); // err = "05"; if (colcnt == 1) { err = "051"; rowd[colPic1] = resizedImage; err = "06"; rowd[colPic2] = id; err = "07"; } else { err = "052 " + colPic3 + " cnt " + grf1.Cols.Count; rowd[colPic3] = resizedImage; err = "061"; rowd[colPic4] = id; err = "071"; } strm = new listStream(); strm.id = id; err = "08"; strm.stream = stream; err = "09"; lStream.Add(strm); //grf1.AutoSizeRows(); //err = "10"; //grf1.AutoSizeCols(); //err = "11"; //loadedImage.Dispose(); //resizedImage.Dispose(); //stream.Dispose(); //Application.DoEvents(); err = "12"; //findTrue = true; //break; //GC.Collect(); } catch (Exception ex) { String aaa = ex.Message + " " + err; } }).Start(); } } } } } } } } } } } pB1.Value++; } } catch (Exception ex) { MessageBox.Show("" + ex.Message, ""); } } pB1.Dispose(); txtVN.Show(); btnVn.Show(); btnRefresh.Show(); txt.Show(); label6.Show(); chkIPD.Show(); //grf1.AutoSizeRows(); //grf1.AutoSizeRows(); panel2.Enabled = true; }
private void setGrfImg(String fmcode) { showFormWaiting(); DataTable dt = new DataTable(); String limit = ""; if (chkLimit.Checked) { dt = bc.bcDB.dscDB.selectByFmCode(fmcode, "40"); } else { dt = bc.bcDB.dscDB.selectByFmCode(fmcode, ""); } grfImg.Rows.Count = 0; FtpClient ftp = new FtpClient(bc.iniC.hostFTP, bc.iniC.userFTP, bc.iniC.passFTP); Boolean findTrue = false; int colcnt = 0, rowrun = -1; int cnt = 0; cnt = dt.Rows.Count / 2; ContextMenu menuGw = new ContextMenu(); //menuGw.MenuItems.Add("ต้องการ Print ภาพนี้", new EventHandler(ContextMenu_grfscan_print)); menuGw.MenuItems.Add("ต้องการ Download ภาพนี้", new EventHandler(ContextMenu_grfImg_Download)); grfImg.ContextMenu = menuGw; grfImg.Rows.Count = cnt + 1; try { foreach (DataRow row1 in dt.Rows) { if (findTrue) { break; } colcnt++; String dgssid = "", filename = "", ftphost = "", id = "", folderftp = ""; id = row1[bc.bcDB.dscDB.dsc.doc_scan_id].ToString(); dgssid = row1[bc.bcDB.dscDB.dsc.doc_group_sub_id].ToString(); filename = row1[bc.bcDB.dscDB.dsc.image_path].ToString(); ftphost = row1[bc.bcDB.dscDB.dsc.host_ftp].ToString(); folderftp = row1[bc.bcDB.dscDB.dsc.folder_ftp].ToString(); String err = ""; try { FtpWebRequest ftpRequest = null; FtpWebResponse ftpResponse = null; Stream ftpStream = null; int bufferSize = 2048; err = "00"; Row rowd; if ((colcnt % 2) == 0) { rowd = grfImg.Rows[rowrun]; } else { rowrun++; rowd = grfImg.Rows[rowrun]; } MemoryStream stream; Image loadedImage, resizedImage; stream = new MemoryStream(); //stream = ftp.download(folderftp + "//" + filename); //loadedImage = Image.FromFile(filename); err = "01"; Application.DoEvents(); ftpRequest = (FtpWebRequest)FtpWebRequest.Create(ftphost + "/" + folderftp + "/" + filename); ftpRequest.Credentials = new NetworkCredential(bc.iniC.userFTP, bc.iniC.passFTP); ftpRequest.UseBinary = true; ftpRequest.UsePassive = bc.ftpUsePassive; ftpRequest.KeepAlive = true; ftpRequest.Method = WebRequestMethods.Ftp.DownloadFile; ftpResponse = (FtpWebResponse)ftpRequest.GetResponse(); ftpStream = ftpResponse.GetResponseStream(); err = "02"; byte[] byteBuffer = new byte[bufferSize]; int bytesRead = ftpStream.Read(byteBuffer, 0, bufferSize); try { while (bytesRead > 0) { stream.Write(byteBuffer, 0, bytesRead); bytesRead = ftpStream.Read(byteBuffer, 0, bufferSize); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); new LogWriter("e", "FrmScanView1 SetGrfScan try int bytesRead = ftpStream.Read(byteBuffer, 0, bufferSize); ex " + ex.Message + " " + err); } err = "03"; loadedImage = new Bitmap(stream); err = "04"; int originalWidth = 0; originalWidth = loadedImage.Width; int newWidth = bc.imgScanWidth; resizedImage = loadedImage.GetThumbnailImage(newWidth, (newWidth * loadedImage.Height) / originalWidth, null, IntPtr.Zero); // err = "05"; if ((colcnt % 2) == 0) { rowd[colPic3] = resizedImage; // + 0001 err = "061"; // + 0001 rowd[colPic4] = id; // + 0001 err = "071"; // + 0001 } else { err = "051"; // + 0001 rowd[colPic1] = resizedImage; // + 0001 err = "06"; // + 0001 rowd[colPic2] = id; // + 0001 err = "07"; // + 0001 } strm = new listStream(); strm.id = id; err = "08"; strm.stream = stream; err = "09"; lStream.Add(strm); Application.DoEvents(); err = "12"; if (colcnt == 50) { GC.Collect(); } if (colcnt == 100) { GC.Collect(); } } catch (Exception ex) { String aaa = ex.Message + " " + err; new LogWriter("e", "FrmDocGroupFmEdit setGrfImg ex " + ex.Message + " " + err + " colcnt " + colcnt); } } } catch (Exception ex) { } frmFlash.Dispose(); grfImg.AutoSizeRows(); }
private void initConfig() { this.FormBorderStyle = FormBorderStyle.None; fEdit = new Font(ic.iniC.grdViewFontName, ic.grdViewFontSize, FontStyle.Regular); fEditB = new Font(ic.iniC.grdViewFontName, ic.grdViewFontSize, FontStyle.Bold); ic.ivfDB.dgsDB.setCboBsp(cboDgs, ""); array1 = new ArrayList(); lStream = new List <listStream>(); strm = new listStream(); grfOrder = new C1FlexGrid(); ptt = new Patient(); //timer1 = new Timer(); //int chk = 0; //int.TryParse(bc.iniC.timerImgScanNew, out chk); //timer1.Interval = chk; //timer1.Enabled = true; //timer1.Tick += Timer1_Tick; //timer1.Stop(); theme1.SetTheme(sb1, ic.iniC.themeApp); theme1.SetTheme(groupBox1, ic.iniC.themeApp); theme1.SetTheme(panel2, ic.iniC.themeApp); theme1.SetTheme(panel3, ic.iniC.themeApp); theme1.SetTheme(sC1, ic.iniC.themeApp); foreach (Control con in groupBox1.Controls) { theme1.SetTheme(con, ic.iniC.themeApp); } //foreach (Control con in grfScan.Controls) //{ // theme1.SetTheme(con, "ExpressionDark"); //} initGrf(); txtHn.Value = hn; ptt = ic.ivfDB.pttDB.selectByHn(txtHn.Text.Trim()); txtName.Value = ptt.Name; setGrfVs(); btnHn.Click += BtnHn_Click; btnOpen.Click += BtnOpen_Click; //btnRefresh.Click += BtnRefresh_Click; txtHn.KeyUp += TxtHn_KeyUp; //tcDtr.SelectedTabChanged += TcDtr_SelectedTabChanged; //sC1.TabIndexChanged += SC1_TabIndexChanged; //tcDtr.TabClick += TcDtr_TabClick; tcDtr = new C1DockingTab(); tcDtr.Dock = System.Windows.Forms.DockStyle.Fill; tcDtr.Location = new System.Drawing.Point(0, 266); tcDtr.Name = "c1DockingTab1"; tcDtr.Size = new System.Drawing.Size(669, 200); tcDtr.TabIndex = 0; tcDtr.TabsSpacing = 5; panel3.Controls.Add(tcDtr); theme1.SetTheme(tcDtr, ic.iniC.themeApplication); //tabStfNote = new C1DockingTabPage(); //tabStfNote.Location = new System.Drawing.Point(1, 24); ////tabScan.Name = "c1DockingTabPage1"; //tabStfNote.Size = new System.Drawing.Size(667, 175); //tabStfNote.TabIndex = 0; //tabStfNote.Text = "ใบยา / Staff's Note"; //tabStfNote.Name = "tabPageScan"; //tcDtr.Controls.Add(tabStfNote); tcDtr.TabClick += TcDtr_TabClick; tabOrder = new C1DockingTabPage(); tabOrder.Location = new System.Drawing.Point(1, 24); //tabScan.Name = "c1DockingTabPage1"; tabOrder.Size = new System.Drawing.Size(667, 175); tabOrder.TabIndex = 0; tabOrder.Text = "ประวัติการสั่งการ"; tabOrder.Name = "tabOrder"; tcDtr.Controls.Add(tabOrder); tabScan = new C1DockingTabPage(); tabScan.Location = new System.Drawing.Point(1, 24); //tabScan.Name = "c1DockingTabPage1"; tabScan.Size = new System.Drawing.Size(667, 175); tabScan.TabIndex = 0; tabScan.Text = "เวชระเบียน Scan"; tabScan.Name = "tabPageScan"; tcDtr.Controls.Add(tabScan); grfOrder.Font = fEdit; grfOrder.Dock = System.Windows.Forms.DockStyle.Fill; grfOrder.Location = new System.Drawing.Point(0, 0); grfOrder.Rows[0].Visible = false; grfOrder.Cols[0].Visible = false; grfOrder.Cols[colOrderId].Visible = false; grfOrder.Rows.Count = 1; grfOrder.Cols.Count = 5; grfOrder.Cols[colOrderName].Caption = "ชื่อ"; grfOrder.Cols[colOrderMed].Caption = "-"; grfOrder.Cols[colOrderQty].Caption = "QTY"; grfOrder.Cols[colOrderName].Width = 300; grfOrder.Cols[colOrderMed].Width = 200; grfOrder.Cols[colOrderQty].Width = 60; grfOrder.Name = "grfOrder"; grfScan = new C1FlexGrid(); grfScan.Font = fEdit; grfScan.Dock = System.Windows.Forms.DockStyle.Fill; grfScan.Location = new System.Drawing.Point(0, 0); grfScan.Rows[0].Visible = false; grfScan.Cols[0].Visible = false; grfScan.Rows.Count = 1; grfScan.Name = "grfScan"; grfScan.Cols.Count = 5; Column colpic1 = grfScan.Cols[colPic1]; colpic1.DataType = typeof(Image); Column colpic2 = grfScan.Cols[colPic2]; colpic2.DataType = typeof(String); Column colpic3 = grfScan.Cols[colPic3]; colpic3.DataType = typeof(Image); Column colpic4 = grfScan.Cols[colPic4]; colpic4.DataType = typeof(String); grfScan.Cols[colPic1].Width = 310; grfScan.Cols[colPic2].Width = 310; grfScan.Cols[colPic3].Width = 310; grfScan.Cols[colPic4].Width = 310; grfScan.ShowCursor = true; grfScan.Cols[colPic2].Visible = false; grfScan.Cols[colPic3].Visible = true; grfScan.Cols[colPic4].Visible = false; grfScan.Cols[colPic1].AllowEditing = false; grfScan.Cols[colPic3].AllowEditing = false; grfScan.DoubleClick += Grf_DoubleClick; //grfScan.AutoSizeRows(); //grfScan.AutoSizeCols(); //tabScan.Controls.Add(grfScan); theme1.SetTheme(grfOrder, "Office2016Black"); tabOrder.Controls.Add(grfOrder); tabScan.Controls.Add(grfScan); //setPicStaffNote(); theme1.SetTheme(tcDtr, theme1.Theme); }
private void setGrfScan(int row) { panel2.Enabled = false; ProgressBar pB1 = new ProgressBar(); pB1.Location = new System.Drawing.Point(20, 16); pB1.Name = "pB1"; pB1.Size = new System.Drawing.Size(862, 23); groupBox1.Controls.Add(pB1); pB1.Left = txtHn.Left; pB1.Show(); txtVN.Hide(); txtHn.Hide(); txtName.Hide(); label1.Hide(); cboDgs.Hide(); btnOpen.Hide(); btnHn.Hide(); txt.Hide(); //label6.Hide(); //txtVisitDate.Hide(); chkIPD.Hide(); //txtPreNo.Hide(); //clearGrf(); String statusOPD = "", vsDate = "", vn = "", an = "", anDate = "", hn = "", preno = ""; statusOPD = grfVs[row, colVsStatus] != null ? grfVs[row, colVsStatus].ToString() : ""; preno = grfVs[row, colVsPreno] != null ? grfVs[row, colVsPreno].ToString() : ""; vsDate = grfVs[row, colVsVsDate] != null ? grfVs[row, colVsVsDate].ToString() : ""; //txtVisitDate.Value = vsDate; //if (statusOPD.Equals("OPD")) //{ chkIPD.Checked = false; vn = grfVs[row, colVsVn] != null ? grfVs[row, colVsVn].ToString() : ""; txtVN.Value = vn; label2.Text = "VN :"; //} //else //{ // chkIPD.Checked = true; // an = grfVs[row, colVsAn] != null ? grfVs[row, colVsAn].ToString() : ""; // anDate = grfVs[row, colVsAndate] != null ? grfVs[row, colVsAndate].ToString() : ""; // txtVN.Value = an; // label2.Text = "AN :"; // //txtVisitDate.Value = anDate; //} //setStaffNote(vsDate, preno); DataTable dtOrder = new DataTable(); vn = grfVs[row, colVsVn] != null ? grfVs[row, colVsVn].ToString() : ""; if (vn.IndexOf("(") > 0) { vn = vn.Substring(0, vn.IndexOf("(")); } if (vn.IndexOf("/") > 0) { vn = vn.Substring(0, vn.IndexOf("/")); } Application.DoEvents(); /* ดึง order * เดียวค่อยกลับมาเขียนต่อ */ //dtOrder = ic.ivfDB.vsDB.selectDrug(txtHn.Text, vn, preno); //grfOrder.Rows.Count = 1; //if (dtOrder.Rows.Count > 0) //{ // try // { // pB1.Value = 0; // pB1.Minimum = 0; // pB1.Maximum = dtOrder.Rows.Count; // foreach (DataRow row1 in dtOrder.Rows) // { // Row rowg = grfOrder.Rows.Add(); // rowg[colOrderName] = row1["MNC_PH_TN"].ToString(); // rowg[colOrderMed] = ""; // rowg[colOrderQty] = row1["qty"].ToString(); // pB1.Value++; // } // } // catch (Exception ex) // { // MessageBox.Show("" + ex.Message, ""); // } //} GC.Collect(); /* ดึง scan * เดียวค่อยกลับมาเขียนต่อ */ ContextMenu menuGw = new ContextMenu(); menuGw.MenuItems.Add("ต้องการ Print ภาพนี้", new EventHandler(ContextMenu_grfscan__print)); menuGw.MenuItems.Add("ต้องการ Print ภาพทั้งหมด", new EventHandler(ContextMenu_grfscan_print_all)); menuGw.MenuItems.Add("ต้องการ ยกเลิก ภาพนี้", new EventHandler(ContextMenu_Gw_Cancel)); grfScan.ContextMenu = menuGw; DataTable dt = new DataTable(); //dt = ic.ivfDB.dscDB.selectByVn(txtHn.Text, vn); dt = ic.ivfDB.dscDB.selectByVn(ptt.patient_hn, vn); grfScan.Rows.Count = 0; if (dt.Rows.Count > 0) { try { int cnt = 0; cnt = dt.Rows.Count / 2; grfScan.Rows.Count = cnt + 1; foreach (Row row1 in grfScan.Rows) { row1.Height = 100; } pB1.Value = 0; pB1.Minimum = 0; pB1.Maximum = dt.Rows.Count; //MemoryStream stream; //Image loadedImage, resizedImage; FtpClient ftp = new FtpClient(ic.iniC.hostFTP, ic.iniC.userFTP, ic.iniC.passFTP, ic.ftpUsePassive, ic.iniC.pathChar); Boolean findTrue = false; int colcnt = 0, rowrun = -1; foreach (DataRow row1 in dt.Rows) { if (findTrue) { break; } colcnt++; String dgssid = "", filename = "", ftphost = "", id = "", folderftp = ""; id = row1[ic.ivfDB.dscDB.dsc.doc_scan_id].ToString(); dgssid = row1[ic.ivfDB.dscDB.dsc.doc_group_sub_id].ToString(); filename = row1[ic.ivfDB.dscDB.dsc.image_path].ToString(); ftphost = row1[ic.ivfDB.dscDB.dsc.host_ftp].ToString(); folderftp = row1[ic.ivfDB.dscDB.dsc.folder_ftp].ToString(); //new Thread(() => //{ String err = ""; try { FtpWebRequest ftpRequest = null; FtpWebResponse ftpResponse = null; Stream ftpStream = null; int bufferSize = 2048; err = "00"; Row rowd; if ((colcnt % 2) == 0) { rowd = grfScan.Rows[rowrun]; } else { rowrun++; rowd = grfScan.Rows[rowrun]; } MemoryStream stream; Image loadedImage, resizedImage; stream = new MemoryStream(); //stream = ftp.download(folderftp + "//" + filename); //loadedImage = Image.FromFile(filename); err = "01"; ftpRequest = (FtpWebRequest)FtpWebRequest.Create(ftphost + "/" + folderftp + "/" + filename); ftpRequest.Credentials = new NetworkCredential(ic.iniC.userFTP, ic.iniC.passFTP); ftpRequest.UseBinary = true; ftpRequest.UsePassive = ic.ftpUsePassive; ftpRequest.KeepAlive = true; ftpRequest.Method = WebRequestMethods.Ftp.DownloadFile; ftpResponse = (FtpWebResponse)ftpRequest.GetResponse(); ftpStream = ftpResponse.GetResponseStream(); err = "02"; byte[] byteBuffer = new byte[bufferSize]; int bytesRead = ftpStream.Read(byteBuffer, 0, bufferSize); try { while (bytesRead > 0) { stream.Write(byteBuffer, 0, bytesRead); bytesRead = ftpStream.Read(byteBuffer, 0, bufferSize); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } err = "03"; loadedImage = new Bitmap(stream); err = "04"; int originalWidth = 0; originalWidth = loadedImage.Width; int newWidth = 640; resizedImage = loadedImage.GetThumbnailImage(newWidth, (newWidth * loadedImage.Height) / originalWidth, null, IntPtr.Zero); // err = "05"; if ((colcnt % 2) == 0) { err = "052 " + colPic3 + " cnt " + grfScan.Cols.Count; rowd[colPic3] = resizedImage; err = "061"; rowd[colPic4] = id; //grfScan[grfScan.Row, colPic4] = id; err = "071"; } else { err = "051"; rowd[colPic1] = resizedImage; err = "06"; rowd[colPic2] = id; err = "07"; } strm = new listStream(); strm.id = id; err = "08"; strm.stream = stream; err = "09"; lStream.Add(strm); //grf1.AutoSizeRows(); //err = "10"; //grf1.AutoSizeCols(); //err = "11"; //loadedImage.Dispose(); //resizedImage.Dispose(); //stream.Dispose(); Application.DoEvents(); err = "12"; //findTrue = true; //break; //GC.Collect(); } catch (Exception ex) { String aaa = ex.Message + " " + err; } //}).Start(); pB1.Value++; } } catch (Exception ex) { MessageBox.Show("" + ex.Message, ""); } } pB1.Dispose(); txtVN.Show(); txtHn.Show(); txtName.Show(); label1.Show(); cboDgs.Show(); btnOpen.Show(); btnHn.Show(); txt.Show(); //label6.Show(); chkIPD.Show(); //grf1.AutoSizeRows(); //grf1.AutoSizeRows(); panel2.Enabled = true; }
private void GrfVs_AfterRowColChange(object sender, RangeEventArgs e) { //throw new NotImplementedException(); if (e.NewRange.r1 < 0) { return; } if (e.NewRange.Data == null) { return; } if (txtHn.Text.Equals("")) { return; } panel2.Enabled = false; ProgressBar pB1 = new ProgressBar(); pB1.Location = new System.Drawing.Point(113, 36); pB1.Name = "pB1"; pB1.Size = new System.Drawing.Size(862, 23); groupBox1.Controls.Add(pB1); pB1.Left = txtVN.Left; pB1.Show(); txtVN.Hide(); btnVn.Hide(); btnRefresh.Hide(); txt.Hide(); label6.Hide(); txtVisitDate.Hide(); chkIPD.Hide(); //txtPreNo.Hide(); clearGrf(); String statusOPD = "", vsDate = "", vn = "", an = "", anDate = "", hn = "", preno = ""; //statusOPD = grfVs[e.NewRange.r1, colVsStatus] != null ? grfVs[e.NewRange.r1, colVsStatus].ToString() : ""; //preno = grfVs[e.NewRange.r1, colVsPreno] != null ? grfVs[e.NewRange.r1, colVsPreno].ToString() : ""; vsDate = grfVs[e.NewRange.r1, colVsVsDate] != null ? grfVs[e.NewRange.r1, colVsVsDate].ToString() : ""; txtVisitDate.Value = vsDate; statusOPD = "OPD"; if (statusOPD.Equals("OPD")) { chkIPD.Checked = false; vn = grfVs[e.NewRange.r1, colVsVn] != null ? grfVs[e.NewRange.r1, colVsVn].ToString() : ""; txtVN.Value = vn; label2.Text = "VN :"; } else { chkIPD.Checked = true; an = grfVs[e.NewRange.r1, colVsAn] != null ? grfVs[e.NewRange.r1, colVsAn].ToString() : ""; anDate = grfVs[e.NewRange.r1, colVsAndate] != null ? grfVs[e.NewRange.r1, colVsAndate].ToString() : ""; txtVN.Value = an; label2.Text = "AN :"; txtVisitDate.Value = anDate; } String file = "", dd = "", mm = "", yy = ""; Image stffnoteL, stffnoteR; if (vsDate.Length > 8) { //String preno1 = preno; //dd = vsDate.Substring(0, 2); //mm = vsDate.Substring(3,2); //yy = vsDate.Substring(vsDate.Length - 4); //file = "\\\\172.25.10.5\\image\\OPD\\"+ yy+"\\"+mm+"\\"+dd+"\\"; //preno1 = "000000"+ preno1; //preno1 = preno1.Substring(preno1.Length- 6); //stffnoteL = Image.FromFile(file+ preno1+"R.JPG"); //stffnoteR = Image.FromFile(file+ preno1+ "S.JPG"); //picL.Image = stffnoteL; //picR.Image = stffnoteR; } DataTable dtOrder = new DataTable(); vn = grfVs[e.NewRange.r1, colVsVn] != null ? grfVs[e.NewRange.r1, colVsVn].ToString() : ""; if (vn.IndexOf("(") > 0) { vn = vn.Substring(0, vn.IndexOf("(")); } if (vn.IndexOf("/") > 0) { vn = vn.Substring(0, vn.IndexOf("/")); } Application.DoEvents(); //dtOrder = ic.ivfDB.vsDB.selectDrug(txtHn.Text, vn, preno); grfOrder.Rows.Count = 1; if (dtOrder.Rows.Count > 0) { try { pB1.Value = 0; pB1.Minimum = 0; pB1.Maximum = dtOrder.Rows.Count; foreach (DataRow row in dtOrder.Rows) { Row rowg = grfOrder.Rows.Add(); rowg[colOrderName] = row["MNC_PH_TN"].ToString(); rowg[colOrderMed] = ""; rowg[colOrderQty] = row["qty"].ToString(); pB1.Value++; } } catch (Exception ex) { MessageBox.Show("" + ex.Message, ""); } } GC.Collect(); DataTable dt = new DataTable(); dt = ic.ivfDB.dscDB.selectByVn(txtHn.Text, vn); if (dt.Rows.Count > 0) { try { pB1.Value = 0; pB1.Minimum = 0; pB1.Maximum = dt.Rows.Count; //MemoryStream stream; //Image loadedImage, resizedImage; C1FlexGrid grf1; FtpClient ftp = new FtpClient(ic.iniC.hostFTP, ic.iniC.userFTP, ic.iniC.passFTP, ic.ftpUsePassive, ic.iniC.pathChar); Boolean findTrue = false; foreach (DataRow row in dt.Rows) { if (findTrue) { break; } String dgssid = "", filename = "", ftphost = "", id = "", folder = ""; id = row[ic.ivfDB.dscDB.dsc.doc_scan_id].ToString(); dgssid = row[ic.ivfDB.dscDB.dsc.doc_group_sub_id].ToString(); filename = row[ic.ivfDB.dscDB.dsc.image_path].ToString(); ftphost = row[ic.ivfDB.dscDB.dsc.host_ftp].ToString(); folder = row[ic.ivfDB.dscDB.dsc.folder_ftp].ToString(); foreach (Control con in panel3.Controls) { if (findTrue) { break; } if (con is C1DockingTab) { foreach (Control cond in con.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 (congd1 is C1FlexGrid) { if (congd1.Name.Equals(dgssid)) { grf1 = (C1FlexGrid)congd1; Row rowd = grf1.Rows.Add(); MemoryStream stream; Image loadedImage, resizedImage; stream = new MemoryStream(); stream = ftp.download(ftphost, folder + "//" + filename); //loadedImage = Image.FromFile(filename); loadedImage = new Bitmap(stream); int originalWidth = 0; originalWidth = loadedImage.Width; int newWidth = 280; resizedImage = loadedImage.GetThumbnailImage(newWidth, (newWidth * loadedImage.Height) / originalWidth, null, IntPtr.Zero); // rowd[colPic1] = resizedImage; rowd[colPic2] = id; strm = new listStream(); strm.id = id; strm.stream = stream; lStream.Add(strm); grf1.AutoSizeRows(); //loadedImage.Dispose(); //resizedImage.Dispose(); //stream.Dispose(); Application.DoEvents(); findTrue = true; break; //GC.Collect(); } } } } } } } } } } } pB1.Value++; } } catch (Exception ex) { MessageBox.Show("" + ex.Message, ""); } } pB1.Dispose(); txtVN.Show(); btnVn.Show(); btnRefresh.Show(); txt.Show(); label6.Show(); chkIPD.Show(); //grf1.AutoSizeRows(); panel2.Enabled = true; }