using DevExpress.XtraEditors; using HL_FristAidPlatform_DTO; using HL_FristAidPlatform_Public; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Drawing; using System.IO; using System.Windows.Forms; namespace HL_FristAidPlatform_Apoplexy { public partial class UserControl_CraniotomyInformedConsent : UserControl { public string guid; public string fileAddress; public byte[] patientSignature; public byte[] doctorSignature; public string name; public string gender; public int age; public string number; public string patientGuid; public string diagnose; public string imageFile; public UserControl_CraniotomyInformedConsent(string _patientGuid, string _name, string _gender, int _age, string _number, string _diagnose,string _fileAddress) { InitializeComponent(); patientGuid = _patientGuid; name = _name; gender = _gender; age = _age; number = _number; diagnose = _diagnose; fileAddress = _fileAddress; } private void UserControl_CraniotomyInformedConsent_Load(object sender, EventArgs e) { lbl_name.Text = name; if (gender == "0") lbl_gender.Text = "未知"; if (gender == "1") lbl_gender.Text = "男"; if (gender == "2") lbl_gender.Text = "女"; lbl_age.Text = age.ToString(); //lbl_gender.Text = gender; lbl_number.Text = number; labelControl12.Text = diagnose; GetnformedConsentByPatientGuid(); } public void GetnformedConsentByPatientGuid() { T_Service_InformedConsentDTO dto = DBHelpClass.GetDateModel(string.Format("api/service/T_Service_InformedConsent/GetnformedConsentByPatientGuid?patientGuid={0}&flag={1}", patientGuid, 1)); if (dto != null) { fileAddress = dto.FileAddress; time_PatientSigningTime.TimeValue = dto.PatientSignatureTime; time_DoctorSignatureTime.TimeValue = dto.DoctorSignatureTime; //text_PatientPhone.Text = dto.PatientPhone; text_Relationship.Text = dto.Relationship; if (!string.IsNullOrEmpty(time_PatientSigningTime.TimeValue)) { time_PatientSigningTime.TimeValue = dto.PatientSignatureTime; } if (!string.IsNullOrEmpty(time_DoctorSignatureTime.TimeValue)) { time_DoctorSignatureTime.TimeValue = dto.DoctorSignatureTime; } //comboBox_Agree.Text = dto.Agree; if (dto.PatientSignature != null) { string ReferringDoctorSignature = Convert.ToBase64String(dto.PatientSignature); if (!string.IsNullOrEmpty(ReferringDoctorSignature)) { MemoryStream ms = new MemoryStream(Convert.FromBase64String(ReferringDoctorSignature)); Image img = Image.FromStream(ms); pic_PatientSignature.Image = img; } } if (dto.DoctorSignature != null) { string signature = Convert.ToBase64String(dto.DoctorSignature); if (!string.IsNullOrEmpty(signature)) { MemoryStream ms = new MemoryStream(Convert.FromBase64String(signature)); Image img = Image.FromStream(ms); pic_DoctorSignature.Image = img; } } } } public void SaveInformedConsent(int type) { T_Service_InformedConsentDTO dto = new T_Service_InformedConsentDTO(); List list = new List(); string Url = string.Empty; ClientFactory httpClient = new HttpClientFactory(); Client client = httpClient.VisitFactory(); Url = "api/service/T_Service_InformedConsent/SaveInformedConsent"; //dto.FileAddress = fileAddress; dto.DoctorSignature = doctorSignature; dto.PatientSignature = patientSignature; dto.PatientGuid = patientGuid; if (!string.IsNullOrEmpty(time_PatientSigningTime.TimeValue)) { dto.PatientSignatureTime = time_PatientSigningTime.TimeValue != null ? Convert.ToDateTime(time_PatientSigningTime.TimeValue).ToString("yyyy-MM-dd HH:mm") : ""; } if (!string.IsNullOrEmpty(time_DoctorSignatureTime.TimeValue)) { dto.DoctorSignatureTime = time_DoctorSignatureTime.TimeValue != null ? Convert.ToDateTime(time_DoctorSignatureTime.TimeValue).ToString("yyyy-MM-dd HH:mm") : ""; } dto.Relationship = text_Relationship.Text; if (!string.IsNullOrEmpty(imageFile)) { dto.InformedConsentImg = Convert.FromBase64String(imageFile); /*lbl_imageMessage.Visible = false; hyperlinklbl_Image.Visible = true;*/ } //dto.Agree = comboBox_Agree.Text; dto.Flag = 1; dto.CreateTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm")); dto.CreateUserID = Information.User.ID; list.Add(dto); //访问 ListEntity t = client.Post(Url, list); if (t.Success) { if (type == 0) { if (!string.IsNullOrEmpty(t.DataString)) { if (t.DataString.Contains("Success")) { JObject jo = (JObject)JsonConvert.DeserializeObject(t.DataString); string msg = jo["Msg"].ToString(); if (!string.IsNullOrEmpty(msg)) { XtraMessageBox.Show(msg); } } else { string msg1 = t.DataString.Replace("/", "").Replace(@"\", "").Replace("\"", ""); XtraMessageBox.Show(msg1); } } else { XtraMessageBox.Show("保存失败"); } } else { if (!string.IsNullOrEmpty(t.DataString)) { if (t.DataString.Contains("Success")) { XtraMessageBox.Show("保存成功"); } else { string msg1 = t.DataString.Replace("/", "").Replace(@"\", "").Replace("\"", ""); XtraMessageBox.Show(msg1); } } else { XtraMessageBox.Show("保存失败"); } } } } private void labelControl6_Click(object sender, EventArgs e) { } private void simpleButton1_Click(object sender, EventArgs e) { #region OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Image Files(*.JPG;*.PNG;*.JPEG;;*.BMP)|*.JPG;*.PNG;;*.BMP;*.JPEG"; openFileDialog.RestoreDirectory = true; if (openFileDialog.ShowDialog() == DialogResult.OK) { try { int Config109 = PublicClass.ToInt32(PublicClassForDataBase.Config109, 5); string FileName = openFileDialog.FileName; if (PublicClass.GetFileSize(FileName) <= Config109) { FileInfo file = new FileInfo(FileName); Bitmap bitmap = new Bitmap(FileName); imageFile = file.Extension; if (imageFile.ToLower() == ".png") { imageFile = PublicClass.Png2String(bitmap); } else { imageFile = PublicClass.Jpeg2String(bitmap); } } } catch (Exception ex) { PublicClass.WriteErrorLog(this.Text, "上传知情同意书:\r\n" + ex); } } #endregion } /*private void hyperlinklbl_Image_Click_1(object sender, EventArgs e) { byte[] image = Convert.FromBase64String(imageFile); HL_FristAidPlatform_MultiSystemPublic.Form_ImageShow frm = new HL_FristAidPlatform_MultiSystemPublic.Form_ImageShow(image); frm.ShowDialog(); }*/ private void labelControl10_Click(object sender, EventArgs e) { } } }