/// <summary> /// 保存方法 /// </summary> /// <returns></returns> private bool Save() { SResult rst = new SResult(); if (this.DialogStatus == UBaseLib.Enums.DialogStatus.New) //新增 { this.DataEntity = new ClinicarAllCheck(); this.Fill2Entity(); rst = clinicarAllCheckBiz.Insert(this.DataEntity); } else if (this.DialogStatus == UBaseLib.Enums.DialogStatus.Modify) //修改 { this.Fill2Entity(); rst = clinicarAllCheckBiz.Update(this.DataEntity); } if (rst.success) { UcMessageBox.Information(rst.message, "提示"); } else { UcMessageBox.Error(rst.message, "提示"); } return(rst.success); }
/// <summary> /// 保存方法 /// </summary> /// <returns></returns> private bool Save() { if (this.CheckBeforeSave())//保存前的校验 { SResult rst = new SResult(); if (this.DialogStatus == UBaseLib.Enums.DialogStatus.New) //新增 { this.DataEntityDetail = new ClinicarItemDetail(); this.Fill2Entity(); rst = clinicarDetailBiz.Insert(this.DataEntityDetail); } else if (this.DialogStatus == UBaseLib.Enums.DialogStatus.Modify) //修改 { this.Fill2Entity(); rst = clinicarDetailBiz.Update(this.DataEntityDetail); } if (rst.success) { UcMessageBox.Information(rst.message, "提示"); } else { UcMessageBox.Error(rst.message, "提示"); } return(rst.success); } return(false); }
/// <summary> /// 保存方法 /// </summary> /// <returns></returns> private bool Save() { if (this.CheckBeforeSave())//保存前的校验 { SResult rst = new SResult(); if (this.DialogStatus == UBaseLib.Enums.DialogStatus.New) //新增 { this.Fill2Entity(); rst = clinicarConsultationBiz.Insert(this.DataEntity); if (rst.success) { dataUpload(rst); } } else if (this.DialogStatus == UBaseLib.Enums.DialogStatus.Modify) //修改 { this.Fill2Entity(); rst = clinicarConsultationBiz.Update(this.DataEntity); } if (rst.success) { this.DialogResult = DialogResult.OK; UcMessageBox.Information(rst.message, "提示"); } else { this.DialogResult = DialogResult.No; UcMessageBox.Error(rst.message, "提示"); } return(rst.success); } return(false); }
/// <summary> /// /// </summary> private void fillBack() { ClinicarItem entity = null; //项目管理实体类 if (this.dgrdView.CurrentRow != null && this.dgrdView.CurrentRow.Index >= 0 && f_CheckId != 0) { entity = ((BindingList <ClinicarItem>) this.dgrdView.DataSource)[this.dgrdView.CurrentRow.Index]; SResult rst = new SResult(); ClinicarCheckItem clinicarCheckItem = new ClinicarCheckItem(); clinicarCheckItem.ItemCode = entity.Id; clinicarCheckItem.ItemName = entity.Name; clinicarCheckItem.DptCode = entity.DptCode; clinicarCheckItem.DptName = entity.DptName; clinicarCheckItem.CheckId = f_CheckId; rst = clinicarCheckItemBiz.Insert(clinicarCheckItem); if (rst.success) { UcMessageBox.Information("添加成功!", "提示"); } else { UcMessageBox.Error(rst.message, "提示"); } //刷新登记界面中的检查项目表 SPagintion <ClinicarCheckItem> page = clinicarCheckItemBiz.FindByPagination(1, 999, f_CheckId); IList <ClinicarCheckItem> list = page != null ? page.Data : new List <ClinicarCheckItem>(); SGridViewUtil.BindingData <ClinicarCheckItem>(list, this.dataGridViewTranmit, displayPropertiesTranmit); } else { UcMessageBox.Warning("请先选择一行数据", "提示"); } }
/// <summary> /// 上传文件方法 /// relativePath :数据库中文件的相对路径 /// </summary> private void uploadFile(string relativePath) { string strFilePath = strLocalFilePath; //需要上传的本地文件固定路径前缀 strFilePath = strFilePath + relativePath; //拼接路径 if (!File.Exists(strFilePath)) { return; } //获取外网ftp地址 int indexStart = SqlUtil.F_OutsideConnectionString.IndexOf("=") + 1; int indexEnd = SqlUtil.F_OutsideConnectionString.IndexOf(";"); ftpUristring = "ftp://" + SqlUtil.F_OutsideConnectionString.Substring(indexStart, indexEnd - indexStart); FileInfo fileinfo = new FileInfo(strFilePath); try { string uri = GetUriString(relativePath.Replace("\\", "/")); //检查目录是否存在,不存在创建 FtpCheckDirectoryExist(relativePath); FtpWebRequest request = CreateFtpWebRequest(uri, WebRequestMethods.Ftp.UploadFile); request.ContentLength = fileinfo.Length; int buflength = 8196; byte[] buffer = new byte[buflength]; FileStream filestream = fileinfo.OpenRead(); Stream responseStream = request.GetRequestStream(); //lstbxFtpState.Items.Add("打开上传流,文件上传中..."); int contenlength = filestream.Read(buffer, 0, buflength); while (contenlength != 0) { responseStream.Write(buffer, 0, contenlength); contenlength = filestream.Read(buffer, 0, buflength); } responseStream.Close(); filestream.Close(); FtpWebResponse response = GetFtpResponse(request); if (response == null) { UcMessageBox.Warning("服务器未响应...", "提示"); } } catch (WebException ex) { UcMessageBox.Error("上传发生错误,返回信息为:" + ex.Status, "提示"); } }
// 获取服务器返回的响应体 private FtpWebResponse GetFtpResponse(FtpWebRequest request) { FtpWebResponse response = null; try { response = (FtpWebResponse)request.GetResponse(); return(response); } catch (WebException ex) { UcMessageBox.Error("发送错误,返回信息为:" + ex.Status, "提示"); return(null); } }
/// <summary> /// 保存方法 /// </summary> /// <returns></returns> private bool Save() { SResult rst = new SResult(); if (this.DialogStatus == UBaseLib.Enums.DialogStatus.New) //新增 { } else if (this.DialogStatus == UBaseLib.Enums.DialogStatus.Modify) //修改 { } if (rst.success) { UcMessageBox.Information(rst.message, "提示"); } else { UcMessageBox.Error(rst.message, "提示"); } return(rst.success); }
private bool saveMaster() { if (this.CheckBeforeSave())//保存前的校验 { SResult rst = new SResult(); this.DataEntity = new ClinicarCheck(); this.DataEntityTransmit = new ClinicarCheck(); this.Fill2Entity(); rst = clinicarCheckBiz.Insert(this.DataEntity); if (rst.success) { DataEntityId = Convert.ToInt32(((cis_model.clinicar.ClinicarCheck)rst.data).Id); this.DataEntityTransmit = (cis_model.clinicar.ClinicarCheck)rst.data; UcMessageBox.Information("人员信息保存成功,请添加项目信息。", "提示!"); } else { DataEntityId = 0; UcMessageBox.Error(rst.message); } return(rst.success); } return(false); }
/// <summary> /// 保存相关方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_save_Click(object sender, EventArgs e) { if (this.CheckBeforeSave())//保存前的校验 { //获取检查项目聚焦行数据 ClinicarCheckItem entity = this.GetCurrentRowData(); if (entity == null || Convert.IsDBNull(entity)) { return; } //图片类或pdf if (Util.showType(entity.DptName).Equals(Util.image) || Util.showType(entity.DptName).Equals(Util.pdf)) { SResult rst = new SResult(); this.DataEntityClinicarCheckResult = new ClinicarCheckResult(); this.DataEntityClinicarCheckResult.Deleted = false; this.DataEntityClinicarCheckResult.CheckNumber = uTxt_checkNumber.Text.Trim(); this.DataEntityClinicarCheckResult.AttachmentPath = this.imageOrPdfPath; this.DataEntityClinicarCheckResult.ItemCode = entity.ItemCode; this.DataEntityClinicarCheckResult.ItemName = entity.ItemName; //检查结果表格绑定数据 SPagintion <ClinicarCheckResult> page = clinicarCheckResultBiz.FindByPagination(1, 100, uTxt_checkNumber.Text.Trim(), entity.ItemCode); IList <ClinicarCheckResult> list = page != null ? page.Data : new List <ClinicarCheckResult>(); if (list != null && Convert.IsDBNull(list) == false && list.Count > 0) { this.DataEntityClinicarCheckResult.Id = list[0].Id; rst = clinicarCheckResultBiz.Update(DataEntityClinicarCheckResult); } else { rst = clinicarCheckResultBiz.Insert(DataEntityClinicarCheckResult); } if (rst.success) { UcMessageBox.Information("保存成功.", "提示"); entity.Summary = uRic_summary.Text; entity.Completed = true; rst = clinicarCheckItemBiz.Update(entity); } else { UcMessageBox.Error("保存失败.", "提示"); } } //数据类 else if (Util.showType(entity.DptName).Equals(Util.data)) { SResult rst = new SResult(); if (dataGridView_Result != null && !Convert.IsDBNull(dataGridView_Result) && dataGridView_Result.RowCount > 0) { try { for (int i = 0; i < dataGridView_Result.RowCount; i++) { this.DataEntityClinicarCheckResult = new ClinicarCheckResult(); this.DataEntityClinicarCheckResult.DetailName = dataGridView_Result.Rows[i].Cells[0].Value == null ? "" : dataGridView_Result.Rows[i].Cells[0].Value.ToString(); this.DataEntityClinicarCheckResult.Result = dataGridView_Result.Rows[i].Cells[1].Value == null ? "" : dataGridView_Result.Rows[i].Cells[1].Value.ToString(); this.DataEntityClinicarCheckResult.Unit = dataGridView_Result.Rows[i].Cells[3].Value == null ? "" : dataGridView_Result.Rows[i].Cells[3].Value.ToString(); this.DataEntityClinicarCheckResult.Conclusion = dataGridView_Result.Rows[i].Cells[4].Value == null ? "" : dataGridView_Result.Rows[i].Cells[4].Value.ToString(); this.DataEntityClinicarCheckResult.Deleted = false; this.DataEntityClinicarCheckResult.CheckNumber = uTxt_checkNumber.Text.Trim(); this.DataEntityClinicarCheckResult.AttachmentPath = ""; this.DataEntityClinicarCheckResult.ItemCode = entity.ItemCode; this.DataEntityClinicarCheckResult.ItemName = entity.ItemName; if (!f_blEdit) //新增 { this.DataEntityClinicarCheckResult.DetailCode = dataGridView_Result.Rows[i].Cells[5].Value == null ? "" : dataGridView_Result.Rows[i].Cells[5].Value.ToString(); rst = clinicarCheckResultBiz.Insert(DataEntityClinicarCheckResult); } else if (f_blEdit) //修改 { this.DataEntityClinicarCheckResult.DetailCode = dataGridView_Result.Rows[i].Cells[6].Value == null ? "" : dataGridView_Result.Rows[i].Cells[6].Value.ToString(); this.DataEntityClinicarCheckResult.Id = dataGridView_Result.Rows[i].Cells[5].Value == null ? 0 : Convert.ToInt32(dataGridView_Result.Rows[i].Cells[5].Value); rst = clinicarCheckResultBiz.Update(DataEntityClinicarCheckResult); } } } catch { } finally { if (rst.success) { UcMessageBox.Information("保存成功.", "提示"); entity.Summary = uRic_summary.Text; entity.Completed = true; rst = clinicarCheckItemBiz.Update(entity); } else { UcMessageBox.Error("保存失败.", "提示"); } } } } //重新查询科室表 DataEntity = new ClinicarCheck(); DataEntity = clinicarCheckBiz.FindByCheckNum(uTxt_checkNumber.Text.Trim()); fillByCheckNum(); } }
/// <summary> /// 将本地指定数据同步到公网 /// </summary> private void dataUpload(SResult rst) { #region + 会诊记录表 DataTable _dtHz = MySQLHelper.ExecuteDataTable(SqlUtil.F_OutsideConnectionString, CommandType.Text, "select id from t_clinicar_consultation where id in (" + ((ClinicarConsultation)rst.data).Id + ")"); if (_dtHz == null || Convert.IsDBNull(_dtHz) || _dtHz.Rows.Count <= 0) { try { string sql = "insert into t_clinicar_consultation values (" + "'" + ((ClinicarConsultation)rst.data).Id + "'," + "'" + ((ClinicarConsultation)rst.data).ApplyHospitalCode + "'," + "'" + ((ClinicarConsultation)rst.data).ApplyHospitalName + "'," + "'" + ((ClinicarConsultation)rst.data).ApplyHospitalTel + "'," + "'" + ((ClinicarConsultation)rst.data).ApplyHospitalDate + "'," + "'" + ((ClinicarConsultation)rst.data).HospitalCode + "'," + "'" + ((ClinicarConsultation)rst.data).HospitalName + "'," + "'" + ((ClinicarConsultation)rst.data).DeptCode + "'," + "'" + ((ClinicarConsultation)rst.data).DeptName + "'," + "'" + ((ClinicarConsultation)rst.data).UserName + "'," + "'" + ((ClinicarConsultation)rst.data).ConsultationDate + "'," + "'" + ((ClinicarConsultation)rst.data).ConsultationType + "'," + "'" + ((ClinicarConsultation)rst.data).Name + "'," + "'" + ((ClinicarConsultation)rst.data).CheckNumber + "'," + "'" + ((ClinicarConsultation)rst.data).Sex + "'," + "'" + ((ClinicarConsultation)rst.data).Age + "'," + "'" + ((ClinicarConsultation)rst.data).Married + "'," + "'" + ((ClinicarConsultation)rst.data).Cardnumber + "'," + "'" + ((ClinicarConsultation)rst.data).Tel + "'," + "'" + ((ClinicarConsultation)rst.data).Diagnosis + "'," + "'" + ((ClinicarConsultation)rst.data).Medicalhistory + "'," + "'" + ((ClinicarConsultation)rst.data).Results + "'" + " )"; MySQLHelper.ExecuteNonQuery(SqlUtil.F_OutsideConnectionString, CommandType.Text, sql); } catch (Exception exception) { UcMessageBox.Error("申请会诊数据上传失败 -- ", exception.Message + "\r\n" + exception.StackTrace + "\r\n" + exception.Source); } } #endregion #region + 检查结果表 if (F_checkResultList != null && F_checkResultList.Count > 0) { StringBuilder strId = new StringBuilder(); foreach (ClinicarCheckResult r in F_checkResultList) { DataTable _dtJg = MySQLHelper.ExecuteDataTable(SqlUtil.F_OutsideConnectionString, CommandType.Text, "select id from t_clinicar_check_result where id in (" + r.Id + ")"); if (_dtJg == null || Convert.IsDBNull(_dtJg) || _dtJg.Rows.Count <= 0) { strId.Append(r.Id); strId.Append(","); } } if (strId.Length > 0) { strId.Remove(strId.Length - 1, 1); } else { strId.Append("0"); } //获取本地数据,并过滤掉服务器已有的数据 DataTable _dt = MySQLHelper.ExecuteDataTable(SqlUtil.F_LocalConnectionString, CommandType.Text, "select * from t_clinicar_check_result where id in (" + strId + ")"); if (_dt != null && Convert.IsDBNull(_dt) == false && _dt.Rows.Count > 0) { try { for (int i = 0; i < _dt.Rows.Count; i++) { string sql = "insert into t_clinicar_check_result values (" + "'" + _dt.Rows[i][0] + "'," + _dt.Rows[i][1] + "," + "'" + _dt.Rows[i][2] + "'," + "'" + _dt.Rows[i][3] + "'," + "'" + _dt.Rows[i][4] + "'," + "'" + _dt.Rows[i][5] + "'," + "'" + _dt.Rows[i][6] + "'," + "'" + _dt.Rows[i][7] + "'," + "'" + _dt.Rows[i][8] + "'," + "'" + _dt.Rows[i][9] + "'," + "'" + _dt.Rows[i][10] + "'," + "'" + _dt.Rows[i][11].ToString().Replace(@"\", @"\\") + "'," + "'" + _dt.Rows[i][12] + "'," + "'" + _dt.Rows[i][13] + "'," + "'" + _dt.Rows[i][14] + "'" + " )"; this.uploadFile(_dt.Rows[i][11].ToString(), _dt.Rows[i][3].ToString()); //上传文件 MySQLHelper.ExecuteNonQuery(SqlUtil.F_OutsideConnectionString, CommandType.Text, sql); } } catch (Exception exception) { UcMessageBox.Error("检查结果表数据上传失败 -- " + exception.Message + "\r\n" + exception.StackTrace + "\r\n" + exception.Source); } } } #endregion }
/// <summary> /// 保存方法 /// </summary> private void save() { bool blSuccess = false; #region + 会诊记录表 //申请会诊记录表 if (uCbo_UploadItem.SelectedValue.Equals("t_clinicar_consultation")) { StringBuilder strOutId = new StringBuilder(); //取出外网已有数据的id DataTable _dtOutSide = MySQLHelper.ExecuteDataTable(SqlUtil.F_OutsideConnectionString, CommandType.Text, "select id from t_clinicar_consultation"); if (_dtOutSide != null && Convert.IsDBNull(_dtOutSide) == false && _dtOutSide.Rows.Count > 0) { for (int i = 0; i < _dtOutSide.Rows.Count; i++) { strOutId.Append(_dtOutSide.Rows[i]["id"]); strOutId.Append(","); } } if (strOutId.Length > 0) { strOutId.Remove(strOutId.Length - 1, 1); } else { strOutId.Append("0"); } //获取本地数据,并过滤掉服务器已有的数据 DataTable _dt = MySQLHelper.ExecuteDataTable(SqlUtil.F_LocalConnectionString, CommandType.Text, "select * from t_clinicar_consultation where id not in (" + strOutId + ")"); if (_dt != null && Convert.IsDBNull(_dt) == false && _dt.Rows.Count > 0) { try { for (int i = 0; i < _dt.Rows.Count; i++) { string sql = "insert into t_clinicar_consultation values (" + "'" + _dt.Rows[i][0] + "'," + "'" + _dt.Rows[i][1] + "'," + "'" + _dt.Rows[i][2] + "'," + "'" + _dt.Rows[i][3] + "'," + "'" + _dt.Rows[i][4] + "'," + "'" + _dt.Rows[i][5] + "'," + "'" + _dt.Rows[i][6] + "'," + "'" + _dt.Rows[i][7] + "'," + "'" + _dt.Rows[i][8] + "'," + "'" + _dt.Rows[i][9] + "'," + "'" + _dt.Rows[i][10] + "'," + "'" + _dt.Rows[i][11] + "'," + "'" + _dt.Rows[i][12] + "'," + "'" + _dt.Rows[i][13] + "'," + "'" + _dt.Rows[i][14] + "'," + "'" + _dt.Rows[i][15] + "'," + "'" + _dt.Rows[i][16] + "'," + "'" + _dt.Rows[i][17] + "'," + "'" + _dt.Rows[i][18] + "'," + "'" + _dt.Rows[i][19] + "'," + "'" + _dt.Rows[i][20] + "'," + "'" + _dt.Rows[i][21] + "'" + " )"; MySQLHelper.ExecuteNonQuery(SqlUtil.F_OutsideConnectionString, CommandType.Text, sql); blSuccess = true; } } catch (Exception exception) { blSuccess = false; UcMessageBox.Error("数据上传失败 -- ", exception.Message + "\r\n" + exception.StackTrace + "\r\n" + exception.Source); } finally { if (blSuccess) { UcMessageBox.Information("上传成功.", "提示"); } } } else { UcMessageBox.Information("没有需要上传的新增数据.", "提示"); } } #endregion #region + 检查结果表 //申请会诊记录表 else if (uCbo_UploadItem.SelectedValue.Equals("t_clinicar_check_result")) { StringBuilder strOutId = new StringBuilder(); //取出外网已有数据的id DataTable _dtOutSide = MySQLHelper.ExecuteDataTable(SqlUtil.F_OutsideConnectionString, CommandType.Text, "select id from t_clinicar_check_result"); if (_dtOutSide != null && Convert.IsDBNull(_dtOutSide) == false && _dtOutSide.Rows.Count > 0) { for (int i = 0; i < _dtOutSide.Rows.Count; i++) { strOutId.Append(_dtOutSide.Rows[i]["id"]); strOutId.Append(","); } } if (strOutId.Length > 0) { strOutId.Remove(strOutId.Length - 1, 1); } else { strOutId.Append("0"); } //获取本地数据,并过滤掉服务器已有的数据 DataTable _dt = MySQLHelper.ExecuteDataTable(SqlUtil.F_LocalConnectionString, CommandType.Text, "select * from t_clinicar_check_result where id not in (" + strOutId + ")"); if (_dt != null && Convert.IsDBNull(_dt) == false && _dt.Rows.Count > 0) { try { for (int i = 0; i < _dt.Rows.Count; i++) { string sql = "insert into t_clinicar_check_result values (" + "'" + _dt.Rows[i][0] + "'," + _dt.Rows[i][1] + "," + "'" + _dt.Rows[i][2] + "'," + "'" + _dt.Rows[i][3] + "'," + "'" + _dt.Rows[i][4] + "'," + "'" + _dt.Rows[i][5] + "'," + "'" + _dt.Rows[i][6] + "'," + "'" + _dt.Rows[i][7] + "'," + "'" + _dt.Rows[i][8] + "'," + "'" + _dt.Rows[i][9] + "'," + "'" + _dt.Rows[i][10] + "'," + "'" + _dt.Rows[i][11].ToString().Replace(@"\", @"\\") + "'" + " )"; this.uploadFile(_dt.Rows[i][11].ToString()); //上传文件 MySQLHelper.ExecuteNonQuery(SqlUtil.F_OutsideConnectionString, CommandType.Text, sql); blSuccess = true; } } catch (Exception exception) { blSuccess = false; UcMessageBox.Error("数据上传失败 -- " + exception.Message + "\r\n" + exception.StackTrace + "\r\n" + exception.Source); } if (blSuccess) { UcMessageBox.Information("上传成功.", "提示"); } } else { UcMessageBox.Information("没有需要上传的新增数据.", "提示"); } } #endregion }