コード例 #1
0
 private void btnPrint_Click(object sender, EventArgs e)
 {
     if (dataGridView1.CurrentRow != null)
     {
         DataRow currentRow = (dataGridView1.CurrentRow.DataBoundItem as DataRowView).Row;
         if (currentRow != null)
         {
             ts_PrintProcess.PrescriptionPrint p = new ts_PrintProcess.PrescriptionPrint();
             string resultMsg = string.Empty;
             bool   ret       = p.Print(currentRow["卡号门诊号"].ToString(), 207, out resultMsg);
             if (ret)
             {
                 string sql = string.Format("update mz_mzkf set isprint = 1 where id = '{0}'", currentRow["ID"]);
                 PrescriptionPrint.DB.DoCommand(sql);
             }
         }
     }
 }
コード例 #2
0
 //<summary>
 //接收客户端发来的信息
 //</summary>
 //<param name="user"></param>
 //<param name="receiveMessage"></param>
 private void ReceiveMessage(ClientUser user, out string receiveMessage)
 {
     try
     {
         //allDone.Set();
         string[] splitString = null;
         byte[]   buffer      = new byte[1024];
         int      byteCount   = user.Client.Client.Receive(buffer);
         receiveMessage = Encoding.Default.GetString(buffer);
         if (string.IsNullOrEmpty(receiveMessage))
         {
             if (!user.IsNormalExit)
             {
                 RemoveUser(user);
             }
             return;
         }
         splitString = receiveMessage.Split(new string[] { "#" }, StringSplitOptions.RemoveEmptyEntries);
         if (splitString == null || splitString.Length == 0)
         {
             receiveMessage = null;
             return;
         }
         if (!string.IsNullOrEmpty(splitString[0]) && !string.IsNullOrEmpty(splitString[1]) && !string.IsNullOrEmpty(splitString[2]))
         {
             if (this.IsDisposed == false)
             {
                 this.BeginInvoke(new MethodInvoker(delegate()
                 {
                     user.WindowNum               = splitString[2];
                     ListViewItem lstViewItem     = new ListViewItem();
                     lstViewItem.SubItems[0].Text = splitString[0];
                     lstViewItem.SubItems.Add(splitString[1]);
                     if (user.Client != null && user.Client.Client != null)
                     {
                         lstViewItem.SubItems.Add(user.Client.Client.RemoteEndPoint.ToString());
                     }
                     lstViewItem.SubItems.Add(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                     ts_PrintProcess.PrescriptionPrint p = new ts_PrintProcess.PrescriptionPrint();
                     string resultMsg = string.Empty;
                     bool isPrint     = false;
                     try
                     {
                         isPrint = p.Print(splitString[0], Convert.ToInt32(splitString[1]), out resultMsg);
                     }
                     catch
                     { }
                     lstViewItem.SubItems.Add(isPrint ? "成功" : "失败");
                     lstViewItem.SubItems.Add(resultMsg);
                     this.listView1.Items.Add(lstViewItem);
                     if (splitString.Length > 3 && !string.IsNullOrEmpty(splitString[3]) && isPrint)
                     {
                         string sql = string.Format("update mz_mzkf set isprint = 1 where id = '{0}'", splitString[3]);
                         PrescriptionPrint.DB.DoCommand(sql);
                     }
                     if (splitString.Length > 4 && !string.IsNullOrEmpty(splitString[4]))
                     {
                         string message = string.Format("正在打印{0}处方单", splitString[4]);
                         this.notifyIcon1.ShowBalloonTip(2000, "提示", message, System.Windows.Forms.ToolTipIcon.Info);
                     }
                 }));
             }
         }
     }
     catch (Exception ex)
     {
         receiveMessage = null;
     }
 }