/// <summary> /// 点击事件:选择医师证 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_selectLicense_Click(object sender, EventArgs e) { if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { licensePath = openFileDialog.FileName; FileInfo fileInfo = new FileInfo(licensePath); if (fileInfo.Length > 2 * 1024 * 1024) { MyMessageBox.Show(ResourceCulture.GetString("pic_no_more_than_2m")); return; } //图片是否低于1024*768 try { using (Image image = Image.FromFile(licensePath)) { if (image.Width > MAX_WIDTH || image.Height > MAX_HEIGHT) { MyMessageBox.Show(ResourceCulture.GetString("pic_no_more_than_1024x768")); return; } } } catch (OutOfMemoryException) { MyMessageBox.Show(ResourceCulture.GetString("illegal_pic_format")); return; } picBox_license.Image = Image.FromFile(licensePath); lbl_license.Text = Path.GetFileName(licensePath); lbl_license.ForeColor = myForeColor; } }
/// <summary> /// 窗体加载时触发 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SelfCheckListForm_Load(object sender, EventArgs e) { //国际化 InitLanguage(); //显示用户名 lbl_username.Text = patientName; //年龄清空 lbl_age.Text = ""; //加载所有与该用户相关的自检信息 new Thread((a) => { ChangeFormCursor(Cursors.WaitCursor); //获取与病人有关的信息 JObject jObj = new JObject(); jObj.Add("username", patientName); string result = HttpHelper.ConnectionForResult("PatientInfoHandler.ashx", jObj.ToString()); if (result != null && !result.Equals("null")) { UserModel patient = JsonConvert.DeserializeObject <UserModel>(result); if (patient.Date_of_birth != null) { TimeSpan timeSpan = DateTime.Now - (DateTime)patient.Date_of_birth; int age = timeSpan.Days / 365; if (ResourceCulture.GetCurrentCultureName().Equals("zh-CN")) { ChangeAgeLabel(age + "岁"); } else { ChangeAgeLabel(age.ToString()); } } else { ChangeAgeLabel(""); } string requestContent = "Patient: " + patientName; string selfCheck = HttpHelper.ConnectionForResult("SelfCheckHandler.ashx", requestContent); if (!string.IsNullOrEmpty(selfCheck)) { JObject jObjResult = JObject.Parse(selfCheck); int count = (int)jObjResult["count"]; if (count != 0) { List <ExRecordModel> list = new List <ExRecordModel>(); JArray jlist = JArray.Parse(jObjResult["content"].ToString()); for (int i = 0; i < jlist.Count; ++i) { ExRecordModel record = new ExRecordModel(JsonConvert.DeserializeObject <RecordModel>(jlist[i].ToString())); list.Add(record); } //JArray str_content = (JArray)jObjResult.Property("content"); // JArray ja = (JArray)JsonConvert.DeserializeObject(str_content); BindDataGridView(list); } } else { MyMessageBox.Show(ResourceCulture.GetString("network_error")); } } ChangeFormCursor(Cursors.Default); }).Start(); }
/// <summary> /// 点击事件:添加为联系人 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void link_addContact_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { MyIMClient.AddContact(patientName); MyMessageBox.Show(ResourceCulture.GetString("insert_complete")); }
private void Confirm() { //基本信息 //1.用户名 string username = tb_username.Text.Trim(); if (string.IsNullOrEmpty(username)) { tabControl1.SelectedTab = tabControl1.TabPages[0]; MyMessageBox.Show(ResourceCulture.GetString("please_input_username")); tb_username.Focus(); return; } //2.密码 string password = tb_password.Text; if (string.IsNullOrEmpty(password)) { tabControl1.SelectedTab = tabControl1.TabPages[0]; MyMessageBox.Show(ResourceCulture.GetString("please_input_password")); tb_password.Focus(); return; } //3.再次输入密码 string passwordAgain = tb_passwordAgain.Text; if (string.IsNullOrEmpty(passwordAgain)) { tabControl1.SelectedTab = tabControl1.TabPages[0]; MyMessageBox.Show(ResourceCulture.GetString("please_input_password_again")); tb_passwordAgain.Focus(); return; } if (!password.Equals(passwordAgain)) { tabControl1.SelectedTab = tabControl1.TabPages[0]; MyMessageBox.Show(ResourceCulture.GetString("password_do_not_match")); tb_passwordAgain.Focus(); return; } //4.个人照片 if (string.IsNullOrEmpty(photoPath)) { tabControl1.SelectedTab = tabControl1.TabPages[0]; MyMessageBox.Show(ResourceCulture.GetString("please_choose_self_photo")); return; } //认证信息 //1.真实姓名 string realName = tb_realname.Text.Trim(); if (string.IsNullOrEmpty(realName)) { tabControl1.SelectedTab = tabControl1.TabPages[1]; MyMessageBox.Show(ResourceCulture.GetString("please_input_real_name")); tb_realname.Focus(); return; } //2.省市县医院选择 if (cb_province.SelectedIndex < 0) { tabControl1.SelectedTab = tabControl1.TabPages[1]; MyMessageBox.Show(ResourceCulture.GetString("please_select_province")); cb_province.Focus(); return; } if (cb_city.SelectedIndex < 0) { tabControl1.SelectedTab = tabControl1.TabPages[1]; MyMessageBox.Show(ResourceCulture.GetString("please_select_city")); cb_city.Focus(); return; } if (cb_area.SelectedIndex < 0) { tabControl1.SelectedTab = tabControl1.TabPages[1]; MyMessageBox.Show(ResourceCulture.GetString("please_select_area")); cb_area.Focus(); return; } if (cb_hospital.SelectedIndex < 0) { tabControl1.SelectedTab = tabControl1.TabPages[1]; MyMessageBox.Show(ResourceCulture.GetString("please_select_hospital")); cb_hospital.Focus(); return; } //3.执业医师证编码 string licenseNo = tb_license.Text.Trim(); if (string.IsNullOrEmpty(licenseNo)) { tabControl1.SelectedTab = tabControl1.TabPages[1]; MyMessageBox.Show(ResourceCulture.GetString("please_input_license_no")); tb_license.Focus(); return; } if (licenseNo.Length != 24 && licenseNo.Length != 27) { tabControl1.SelectedTab = tabControl1.TabPages[1]; MyMessageBox.Show(ResourceCulture.GetString("illegal_license_no")); tb_license.Focus(); return; } if (string.IsNullOrEmpty(licensePath)) { tabControl1.SelectedTab = tabControl1.TabPages[1]; MyMessageBox.Show(ResourceCulture.GetString("please_choose_license_photo")); return; } DoctorModel model = new DoctorModel(); //必须信息 model.Name = username; model.Password = MD5.GetMD5(tb_passwordAgain.Text); //非必须信息(认证信息) this.Cursor = Cursors.WaitCursor; tokenSource = new CancellationTokenSource(); Hospital selectedHospital = cb_hospital.SelectedItem as Hospital; //先发送图片,保证图片上传完成再发送注册表单 Task <string> task1 = Task.Factory.StartNew(() => { //图片直到发送成功为止,或点击取消取消发送 string result = null; while (true) { if (tokenSource.IsCancellationRequested) { return(null); } result = HttpHelper.UploadFile("PicUploadHandler.ashx", photoPath); if (!string.IsNullOrEmpty(result)) { return(result); } } }, tokenSource.Token); Task <string> task2 = Task.Factory.StartNew(() => { string result = null; while (true) { if (tokenSource.IsCancellationRequested) { return(null); } result = HttpHelper.UploadFile("PicUploadHandler.ashx", licensePath); if (!string.IsNullOrEmpty(result)) { return(result); } } }, tokenSource.Token); Task.Factory.StartNew(() => { Task.WaitAll(task1, task2); if (task1 == null || task2 == null || tokenSource.IsCancellationRequested) { return; } model.PhotoPath = task1.Result; model.LicensePath = task2.Result; model.RealName = tb_realname.Text.Trim(); model.LicenseNo = tb_license.Text; model.Hospital_id = selectedHospital.Hospital_id; string result = HttpHelper.ConnectionForResult("RegisterHandler.ashx", JsonConvert.SerializeObject(model)); SafeChangeCursor(Cursors.Default); if (string.IsNullOrEmpty(result)) { MyMessageBox.Show(ResourceCulture.GetString("network_error")); } else { JObject jObj = JObject.Parse(result); string state = (string)jObj["state"]; if ("username exist".Equals(state)) { MyMessageBox.Show(ResourceCulture.GetString("username_exist")); } else if ("failed".Equals(state)) { MyMessageBox.Show(ResourceCulture.GetString("register_failed")); } else if ("success".Equals(state)) { MyMessageBox.Show(ResourceCulture.GetString("register_success")); SafeClose(); } } }, tokenSource.Token); }
private void AddContact() { if (string.IsNullOrEmpty(tb_username.Text.Trim())) { MyMessageBox.Show(ResourceCulture.GetString("please_input_username")); cb_groups.Focus(); return; } if (cb_groups.SelectedIndex == -1) { MyMessageBox.Show(ResourceCulture.GetString("please_choose_group")); cb_groups.Focus(); return; } //检查是否添加自己 string username = tb_username.Text.Trim(); if (username.Equals(LoginStatus.UserInfo.Name)) { MyMessageBox.Show(ResourceCulture.GetString("cannot_add_yourself")); return; } //检查是否已经添加 if (MyIMClient.HasContact(username)) { MyMessageBox.Show(ResourceCulture.GetString("user_already_added")); return; } //发送检查用户名存在的请求 new Thread(() => { JObject jObj = new JObject(); jObj.Add("username", username); string result = HttpHelper.ConnectionForResult("CheckUsernameExistHandler.ashx", jObj.ToString()); this.Invoke(new FlushClient(() => { if (string.IsNullOrEmpty(result)) { MyMessageBox.Show(ResourceCulture.GetString("network_error")); return; } //返回信息解析 JObject jObjRes = JObject.Parse(result); string state = (string)jObjRes["state"]; if ("not exist".Equals(state)) { MyMessageBox.Show(ResourceCulture.GetString("username_not_exist")); tb_username.Focus(); return; } else { string groupName = cb_groups.SelectedItem.ToString(); MyIMClient.AddContact(username, groupName); this.Close(); } })); }).Start(); }