/// <summary> /// 公用方法 /// </summary> public class DemPublic { private const string BEGIN = "Begin"; private const string END = "End"; /// <summary> /// 将一个DataGridView导入,默认导出Excel(YS) /// </summary> /// <param name="dgv"></param> /// <param name="typ">导出类型默认导出Excel</param> public static bool ExportDataToExcel(MzGridControl dgv, GridExportType typ = GridExportType.Excel) { //string fileName = ""; string saveFileName = ""; SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.DefaultExt = "xls"; saveDialog.Filter = "Excel文件|*.xls"; //saveDialog.FileName = fileName; if (saveDialog.ShowDialog() == DialogResult.OK) { saveFileName = saveDialog.FileName; dgv.GridExport(saveFileName, typ); return true; } return false; } /// <summary> /// ComBox输入非下拉数据源清空 /// </summary> public static void SetCmbNonInclusiveEmptying(MzComboBox cmb) { if (cmb.Items.Count <= 0) { cmb.Value = null; return; } if (!cmb.IsItemInList()) { cmb.Value = null; } } /// <summary> /// 设置节点颜色及选中颜色(YS) /// </summary> /// <param name="rNode">节点</param> /// <param name="color">颜色</param> public static void SetNodesColour(UltraTreeNode rNode, Color color) { rNode.Override.NodeAppearance.ForeColor = color; rNode.Override.ActiveNodeAppearance.ForeColor = color; } /// <summary> /// 重置节点颜色及选中颜色(YS) /// </summary> /// <param name="rNode">节点</param> public static void ResetNodesColour(UltraTreeNode rNode) { rNode.Override.NodeAppearance.ResetForeColor(); rNode.Override.ActiveNodeAppearance.ResetForeColor(); } /// <summary> /// 自动初始化配置列 /// </summary> /// <param name="frmName">窗口名称</param> /// <param name="tabName">列表名称(适用于同一窗口多个列表,如果只有一个列表可以为空)</param> /// <param name="funcId">功能ID</param> /// <param name="usrId">用户ID</param> /// <returns></returns> public static List<Ctrls.Grid.GridColumn> InitPubColumns(string frmName, string tabName, string funcId, string usrId) { List<GridCol> gridCols = ResourceBus.Current[ResourceBus.GRIDCOL_LIST] as List<GridCol>; if (gridCols != null) { if (string.IsNullOrEmpty(tabName)) { gridCols = gridCols.Where(m => m.GcForm == frmName && m.GcOwner == funcId).ToList(); } else { gridCols = gridCols.Where(m => m.GcForm == frmName && m.GcOwner == funcId && m.GcGrid == tabName).ToList(); } } GridCol gridCol = new GridCol(); //先从用户中取,否则取第一个 if (gridCols != null && gridCols.Count > 0) { gridCol = gridCols.FirstOrDefault(m => m.UsrId == usrId); if (gridCol == null) { gridCol = gridCols[0]; } } List<Ctrls.Grid.GridColumn> columns = new List<Ctrls.Grid.GridColumn>(); if (gridCol != null && !string.IsNullOrEmpty(gridCol.GcColSet)) { //列配置串 //columnCfg = gridCol.GcColSet; columns = Common.Serializer.Deserialize<List<Ctrls.Grid.GridColumn>>(gridCol.GcColSet); } return columns; } /// <summary> /// 得到本周第一天(以星期一为第一天) /// </summary> /// <param name="datetime"></param> /// <returns></returns> public static DateTime GetWeekFirstDayMon(DateTime datetime) { //星期一为第一天 int weeknow = Convert.ToInt32(datetime.DayOfWeek); //因为是以星期一为第一天,所以要判断weeknow等于0时,要向前推6天。 weeknow = (weeknow == 0 ? (7 - 1) : (weeknow - 1)); int daydiff = (-1) * weeknow; //本周第一天 return datetime.AddDays(daydiff).Date; } /// <summary> /// 得到本周最后一天(以星期天为最后一天) /// </summary> /// <param name="datetime"></param> /// <returns></returns> public static DateTime GetWeekLastDaySun(DateTime datetime) { //星期天为最后一天 int weeknow = Convert.ToInt32(datetime.DayOfWeek); weeknow = (weeknow == 0 ? 7 : weeknow); int daydiff = (7 - weeknow); //本周最后一天 return datetime.AddDays(daydiff).Date.AddDays(1).AddSeconds(-1); } /// <summary> /// 根据RelativeTimeType类型获取开始时间 /// </summary> /// <param name="nowTime">当前时间</param> /// <param name="rtype">类型</param> /// <returns></returns> public static DateTime GetBeginTime(DateTime nowTime, string rtype) { if (rtype == "Month") { return nowTime.AddDays(1 - nowTime.Day).Date; } else if (rtype == "Week") { return GetWeekFirstDayMon(nowTime); } else if (rtype == "Today") { return nowTime.Date; } else if (rtype == "Yesterday") { return nowTime.AddDays(-1).Date; } else if (rtype == "BeforeYesterday") { return nowTime.AddDays(-2).Date; } else if (rtype.Contains(",")) { string[] arr = rtype.Split(','); return DateTime.Parse(arr[0]); } else { return nowTime.AddDays(-Convert.ToDouble(rtype) + 1).Date; } } /// <summary> /// 根据RelativeTimeType类型获取截止时间 /// </summary> /// <param name="nowTime">当前时间</param> /// <param name="rtype">类型</param> /// <returns></returns> public static DateTime GetEndTime(DateTime nowTime, string rtype) { if (rtype == "Month") { return nowTime.AddDays(1 - nowTime.Day).Date.AddMonths(1).AddSeconds(-1); } else if (rtype == "Week") { return GetWeekLastDaySun(nowTime); } else if (rtype == "Today") { return nowTime.Date.AddDays(1).AddSeconds(-1); } else if (rtype == "Yesterday") { return nowTime.AddDays(-1).Date.AddDays(1).AddSeconds(-1); } else if (rtype == "BeforeYesterday") { return nowTime.AddDays(-2).Date.AddDays(1).AddSeconds(-1); } else if (rtype.Contains(",")) { string[] arr = rtype.Split(','); if (string.IsNullOrEmpty(arr[1])) { return nowTime.Date.AddDays(10000).AddSeconds(-1); } return DateTime.Parse(arr[1]); } else { return nowTime.Date.AddDays(1).AddSeconds(-1); } } /// <summary> /// 获取下拉控件选中项的ID /// </summary> /// <param name="cmb"></param> /// <returns></returns> private string GetSelectedValues(MzComboBox cmb) { string values = string.Empty; if (cmb.CheckedItems.Count > 0) { foreach (var item in cmb.CheckedItems) { values += "'" + item.DataValue + "',"; } } var vals = values.Remove(values.Length - 1); return vals; } /// <summary> /// 获取下拉控件选中项的Name /// </summary> /// <param name="cmb"></param> /// <returns></returns> private string GetSelectedNames(MzComboBox cmb) { string names = string.Empty; if (cmb.CheckedItems.Count > 0) { foreach (var item in cmb.CheckedItems) { names += "'" + item.DisplayText + "',"; } } var values = names.Remove(names.Length - 1); return values; } /// <summary> /// 对List进行随机排序 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="ListT"></param> /// <returns></returns> public List<T> RandomSortList<T>(List<T> ListT) { Random random = new Random(); List<T> newList = new List<T>(); foreach (T item in ListT) { newList.Insert(random.Next(newList.Count), item); } return newList; } /// <summary> /// 设置时间控件集合 /// </summary> /// <param name="value"></param> /// <param name="tl"></param> public static void SetTimeList(string value, MzTimeList tl) { if (value == RelativeTimeType.Month.ToString()) { tl.InitTime(RelativeTimeType.Month); } else if (value == RelativeTimeType.Week.ToString()) { tl.InitTime(RelativeTimeType.Week); } else if (value == RelativeTimeType.Today.ToString()) { tl.InitTime(RelativeTimeType.Today); } else if (value == RelativeTimeType.Yesterday.ToString()) { tl.InitTime(RelativeTimeType.Yesterday); } else if (value == RelativeTimeType.BeforeYesterday.ToString()) { tl.InitTime(RelativeTimeType.BeforeYesterday); } else if (value.Contains(",")) { string[] arr = value.Split(','); tl.InitTime(RelativeTimeType.AssignDate, DateTime.Parse(arr[0]), DateTime.Parse(arr[1])); } else { tl.InitTime(RelativeTimeType.AssignDay, null, null, Convert.ToInt32(value)); } } ///// <summary> /// 列表控件定位下一个光标地址 /// </summary> /// <param name = "dgv" ></ param > /// < param name="index"></param> /// <param name = "cloName" ></ param > /// < param name="isNotNull"></param> public static void NextFocus(MzGridControl dgv, int index, string cloName, bool isNotNull) { if (isNotNull) { string cellValue = dgv.Grid.ActiveCell?.Text; if (!string.IsNullOrEmpty(cellValue)) { dgv.Grid.ActiveRow = dgv.Grid.Rows[index]; dgv.Grid.ActiveCell = dgv.Grid.ActiveRow.Cells[cloName]; dgv.Grid.Focus(); dgv.Grid.PerformAction(UltraGridAction.EnterEditMode, false, false); } } else { dgv.Grid.ActiveRow = dgv.Grid.Rows[index]; dgv.Grid.ActiveCell = dgv.Grid.ActiveRow.Cells[cloName]; dgv.Grid.Focus(); dgv.Grid.PerformAction(UltraGridAction.EnterEditMode, false, false); } } /// <summary> /// 清空重复数据(只做清空用)ys /// </summary> /// <typeparam name="T"></typeparam> /// <param name="dgv">dgv控件名称</param> /// <param name="newList">根据条件筛选后无重复集合</param> /// <param name="data">T新实例化对象</param> public static void RemovalDuplicateData<T>(MzGridControl dgv, List<T> newList, T data) { var datas = dgv.DataSource as List<T>; if (newList != null && newList.Count > 0 && datas != null && datas.Count > 0) { datas.Remove(newList.Last()); } datas?.Add(data); dgv.DataSource = datas; } /// <summary> /// 定位Grid光标 /// </summary> /// <param name="dgv">控件</param> /// <param name="index">索引</param> /// <param name="cloName">列名</param> /// <param name="isNotNull">“列名”是否允许为空</param> /// <param name="isUpdate">是否为update事件</param> public static void NextFocusNew(MzGridControl dgv, int index, string cloName, bool isNotNull, bool isUpdate) { if (isNotNull) { string cellValue = dgv.Grid.ActiveCell?.Text; if (!string.IsNullOrEmpty(cellValue)) { NextFocusPublic(dgv, index, cloName, isUpdate); } } else { NextFocusPublic(dgv, index, cloName, isUpdate); } } /// <summary> /// 定义Grid光标 /// </summary> /// <param name="dgv">控件</param> /// <param name="index">索引</param> /// <param name="cloName">列名</param> /// <param name="isUpdate">是否为update事件</param> private static void NextFocusPublic(MzGridControl dgv, int index, string cloName, bool isUpdate) { if (isUpdate) { dgv.Grid.ActiveRow = dgv.Grid.Rows[index]; dgv.Tag = dgv.Grid.Rows.Last().Cells[cloName]; dgv.SetEditCell(dgv.Tag as UltraGridCell); } else { if (index < dgv.Grid.Rows.Count && index >= 0) { dgv.Grid.ActiveRow = dgv.Grid.Rows[index]; } if (dgv.Grid.ActiveRow?.Cells?.Count > 0) { dgv.Tag = dgv.Grid.ActiveRow.Cells[cloName]; dgv.Grid.PerformAction(UltraGridAction.ExitEditMode, false, false); dgv.SetEditCell(dgv.Tag as UltraGridCell); } } } /// <summary> /// 获取MzTimeList控件的值的集合 /// </summary> /// <param name="conditionList"></param> /// <param name="tlDate"></param> /// <returns></returns> public static List<QueryCriteria> GetDateList(List<QueryCriteria> conditionList, MzTimeList tlDate, string property) { RelativeTimeType dateType = tlDate.RelativeTime; if (dateType == RelativeTimeType.AssignDay) { int days = 0; if (tlDate.EndTime != null && tlDate.BeginTime != null) { TimeSpan? ts = tlDate.EndTime - tlDate.BeginTime; days = TimeSpan.Parse(ts.ToString()).Days + 1; } else { MsgBox.Show("请输入天数"); return conditionList; } conditionList.Add(new QueryCriteria() { Property = property, Value = days, Condition = QueryCriteria.QueryCondition.Equal }); } else if (dateType == RelativeTimeType.AssignDate) { if (tlDate.BeginTime == null) { MsgBox.Show("请输入起始日期"); tlDate.BeginTime = DateTime.Parse("2000-01-01"); return conditionList; } if (tlDate.EndTime == null) { MsgBox.Show("请输入截止日期"); tlDate.EndTime = DateTime.Parse("2000-01-01"); return conditionList; } conditionList.Add(new QueryCriteria() { Property = property, Value = tlDate.BeginTime.ToString() + "," + tlDate.EndTime.ToString(), Condition = QueryCriteria.QueryCondition.Equal }); } else { conditionList.Add(new QueryCriteria() { Property = property, Value = dateType.ToString() }); } return conditionList; } /// <summary> /// 显示子列表数据 /// </summary> /// <param name="dgvCurrent"></param> /// <param name="e"></param> public static void ShowDgv(MzGridControl dgvCurrent, CancelableRowEventArgs e) { if (dgvCurrent.Grid.ActiveRow == null) { return; } if (e.Row != dgvCurrent.Grid.ActiveRow) { // 不展开当前行 dgvCurrent.Grid.ActiveRow.Expanded = false; // 激活传入的行 dgvCurrent.Grid.ActiveRow = e.Row; } //刷新子列表显示 e.Row.ChildBands[0].Rows.Refresh(RefreshRow.RefreshDisplay); } /// <summary> /// 去除原弹出框 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public static void DgvCellDataError(object sender, CellDataErrorEventArgs e) { // 防止消息框显示 e.RaiseErrorEvent = false; // 还原到上一个值 e.RestoreOriginalValue = true; // 光标不跳转 e.StayInEditMode = true; } /// <summary> /// 设置子列表字体颜色 /// </summary> /// <param name="e"></param> /// <param name="color"></param> public static void SetDgvForeColor(CancelableRowEventArgs e, Color color) { RowsCollection childRows = e.Row.ChildBands[0].Rows; foreach (UltraGridRow childRow in childRows) { childRow.Appearance.ForeColor = color; } } /// <summary> /// 药品模块通用打印方法2.0 /// </summary> /// <param name="printArgs"></param> /// <param name="dcrApptypCodes">应用场合类型 Eg: PubEnum.ApplicationOccasion.UnLimit.GetHashCode().ToString()</param> /// <param name="dcrTltypCode">模板类型 Eg:PubEnum.PrintModelType.ArModel.GetHashCode().ToString()</param> /// <param name="hosInfo">医院信息实体名称</param> /// <param name="hosList">医院信息集合</param> /// <param name="dvcPrtLogVoList">设备资产编号(设备目录打印传)</param> public static void Print(PrintArgs printArgs, string dcrApptypCodes, string dcrTltypCode, string hosInfo, List<HosInfo> hosList, List<DvcPrtLogVo> dvcPrtLogVoList = null) { var result = Client.QueryListByObject<List<DicCircpVo>>(ApiKey.ADMIN_DICCIRCPHANDLER_GETOTHCICPBYSFNAMEANDDCRAPPTYPCODES, new { tcDcrNo = printArgs.DcrNo, sfName = printArgs.SubFuncName, dcrApptypCodes = dcrApptypCodes, prwcWsIp = LocalMachine.GetInstance.IpAddress, prwcWsPhyaddr = LocalMachine.GetInstance.Mac }); if (result.Flag == ResultFlag.SUCCESS) { List<DicCircpVo> dicCircps = result.Value ?? new List<DicCircpVo>(); //过滤掉编辑器模板 printArgs.DicCircps = dicCircps.FindAll(p => p.DcrTltypCode == dcrTltypCode); if (dicCircps.Any()) { string erroMsg = ""; ReportEntity reportInEntity = new ReportEntity(); reportInEntity.Printed += (sender, e) => { var resultList = e.PrintResultCollection.ToList(); if (resultList.Count > 0) { DateTime dtNow = Client.SystemDate; foreach (var item in resultList) { //从结果中转换而来 DicCircpVo model = item.DataObj as DicCircpVo; if (item.Result == PrintResults.Success) { PfmPrtLog prtLog = new PfmPrtLog(); prtLog = GeneralPrint.GetInstance.GetPrtLogFromCircp(dtNow, model); UpdatePrintInfo(model?.DcrNo, printArgs.MainId, dvcPrtLogVoList); } else { GeneralPrint.GetInstance.WritePrintDbLog(dicCircps, false); } } } }; //本地配置转为datatable if (hosList != null) { DataTable dtLocal = GeneralPrint.GetInstance.List2DataTable<HosInfo>(hosList); if (dtLocal != null) { if (printArgs.LocalDataSource == null) { printArgs.LocalDataSource = new Dictionary<string, DataTable>(); printArgs.LocalDataSource.Add(hosInfo, dtLocal); } else { if (!printArgs.LocalDataSource.ContainsKey(hosInfo)) { printArgs.LocalDataSource.Add(hosInfo, dtLocal); } } } } //打印或预览 GeneralPrint.GetInstance.Print(printArgs, reportInEntity); } else { MsgBox.Show("您没有打印权限![ " + printArgs.DcrNo + " ] "); } } else { MsgBox.Show(result.Message); } } /// <summary> /// 更新打印次数 /// </summary> /// <param name="templateCode">模板Code</param> /// <param name="pkId">单据主表主键</param> /// <param name="dvcPrtLogVoList">设备资产编号(设备目录打印传)</param> private static void UpdatePrintInfo(string templateCode, string pkId, List<DvcPrtLogVo> dvcPrtLogVoList = null) { Result<string> res = null; switch (templateCode) { #region 药品 #region 药品入库,出库,盘点 //药品自制入库 case PrintTemplateCode.DrugSelfMadeStockInDoc: //药品验收入库 case PrintTemplateCode.DrugAcceptanceSheet: //药品其他入库 case PrintTemplateCode.DrugOtherWarehousingListOf: //药品验收单 case PrintTemplateCode.DrugCheckAndAccept: //药品盘盈入库单 case PrintTemplateCode.DrugInventoryGainReceipt: //药品调拨单 case PrintTemplateCode.DrugAllocation: //药品报损单 case PrintTemplateCode.DrugReportLoss: //药品申领单 case PrintTemplateCode.DrugApplicationForm: //药品退库单 case PrintTemplateCode.DrugRetreatFromStorage: //药品其他出库单 case PrintTemplateCode.DrugOtherOutlets: //药品盘点单 case PrintTemplateCode.DrugCheckList: res = Client.DataWrite<string>(ApiKey.ADMIN_DRUGIOSUMHANDLER_UPDATEPRINTINFO, pkId); break; #endregion //药品调价单 case PrintTemplateCode.DrugModify: res = Client.DataWrite<string>(ApiKey.ADMIN_PRADJMAINHANDLER_UPDATEPRINTINFO, pkId); break; ////药品计划单 //case PrintTemplateCode.DrugPlan: // var drugPlan = Client.DataWrite<string>(ApiKey.ADMIN_PRADJMAINHANDLER_UPDATEPRINTINFO, pfmPrtLog); // break; ////药品采购单 //case PrintTemplateCode.DrugPurchase: // var drugPurchase = Client.DataWrite<string>(ApiKey.ADMIN_PRADJMAINHANDLER_UPDATEPRINTINFO, pfmPrtLog); // break; ////药品合同单 //case PrintTemplateCode.DrugContract: // var drugContract = Client.DataWrite<string>(ApiKey.ADMIN_PRADJMAINHANDLER_UPDATEPRINTINFO, pfmPrtLog); // break; #endregion 药品 #region 卫材 #region 卫材入库 //自制入库 case PrintTemplateCode.EisaiSelfMadeStockInDoc: //验收入库 case PrintTemplateCode.EisaiAcceptanceSheet: //其他入库 case PrintTemplateCode.EisaiOtherWarehousingListOf: //验收单 case PrintTemplateCode.EisaiCheckAndAccept: //采购单 case PrintTemplateCode.EisaiPurchaseOrder: //盘盈入库单 case PrintTemplateCode.EisaiInventoryGainReceipt: //调拨单 case PrintTemplateCode.EisaiAllocation: //报损单 case PrintTemplateCode.EisaiReportLoss: //申领单 case PrintTemplateCode.EisaiApplicationForm: //退库单 case PrintTemplateCode.EisaiRetreatFromStorage: //其他出库单 case PrintTemplateCode.EisaiOtherOutlets: //耗材使用出库单 case PrintTemplateCode.EisaiApplyForStockReturn: //盘点单 case PrintTemplateCode.EisaiCheckList: res = Client.DataWrite<string>(ApiKey.ADMIN_EISAIIOSUMHANDLER_UPDATEPRINTINFO, pkId); break; #endregion //调价单 case PrintTemplateCode.EisaiModify: res = Client.DataWrite<string>(ApiKey.ADMIN_PRADJMAINHANDLER_UPDATEPRINTINFO, pkId); break; ////计划单 //case PrintTemplateCode.EisaiPlan: // var drugPlan = Client.DataWrite<string>(ApiKey.ADMIN_PRADJMAINHANDLER_UPDATEPRINTINFO, pfmPrtLog); // break; ////采购单 //case PrintTemplateCode.EisaiPurchase: // var drugPurchase = Client.DataWrite<string>(ApiKey.ADMIN_PRADJMAINHANDLER_UPDATEPRINTINFO, pfmPrtLog); // break; ////合同单 //case PrintTemplateCode.EisaiContract: // var drugContract = Client.DataWrite<string>(ApiKey.ADMIN_PRADJMAINHANDLER_UPDATEPRINTINFO, pfmPrtLog); // break; #endregion #region 耗材 #region 耗材入库 //自制入库 case PrintTemplateCode.MatSelfMadeStockInDoc: //验收入库 case PrintTemplateCode.MatAcceptanceSheet: //其他入库 case PrintTemplateCode.MatOtherWarehousingListOf: //验收单 case PrintTemplateCode.MatCheckAndAccept: //盘盈入库单 case PrintTemplateCode.MatInventoryGainReceipt: res = Client.DataWrite<string>(ApiKey.ADMIN_MATGODOWNENTRYHANDLER_UPDATEMATGODOWNPRINT, pkId); break; #endregion #region 耗材出库 //调拨单 case PrintTemplateCode.MatAllocation: //报损单 case PrintTemplateCode.MatReportLoss: //申领单 case PrintTemplateCode.MatApplicationForm: //退库单 case PrintTemplateCode.MatRetreatFromStorage: //其他出库单 case PrintTemplateCode.MatOtherOutlets: res = Client.DataWrite<string>(ApiKey.ADMIN_MATOUTSTGHANDLER_UPDATEPRTCNT, pkId); break; #endregion //盘点单 case PrintTemplateCode.MatCheckList: res = Client.DataWrite<string>(ApiKey.ADMIN_MATINVCHKRECHANDLER_UPDATEPRINTINFO, pkId); break; ////计划单 //case PrintTemplateCode.MatPlan: // var drugPlan = Client.DataWrite<string>(ApiKey.ADMIN_PRADJMAINHANDLER_UPDATEPRINTINFO, pfmPrtLog); // break; ////采购单 //case PrintTemplateCode.MatPurchase: // var drugPurchase = Client.DataWrite<string>(ApiKey.ADMIN_PRADJMAINHANDLER_UPDATEPRINTINFO, pfmPrtLog); // break; ////合同单 //case PrintTemplateCode.MatContract: // var drugContract = Client.DataWrite<string>(ApiKey.ADMIN_PRADJMAINHANDLER_UPDATEPRINTINFO, pfmPrtLog); // break; #endregion #region 器械 #region 器械入库 //自制入库 case PrintTemplateCode.AppSelfMadeStockInDoc: //验收入库 case PrintTemplateCode.AppAcceptanceSheet: //其他入库 case PrintTemplateCode.AppOtherWarehousingListOf: //验收单 case PrintTemplateCode.AppCheckAndAccept: //盘盈入库单 case PrintTemplateCode.AppInventoryGainReceipt: res = Client.DataWrite<string>(ApiKey.ADMIN_PLATFORM_MAIOSUMHANDLER_UPDATEPRINTINGTIMESBYMAIOSID, pkId); break; #endregion #region 器械出库 //调拨单 case PrintTemplateCode.AppAllocation: //报损单 case PrintTemplateCode.AppReportLoss: //申领单 case PrintTemplateCode.AppApplicationForm: //退库单 case PrintTemplateCode.AppRetreatFromStorage: //其他出库单 case PrintTemplateCode.AppOtherOutlets: res = Client.DataWrite<string>(ApiKey.ADMIN_PLATFORM_MAIOSUMHANDLER_UPDATEPRINTINGTIMESBYMAIOSID, pkId); break; #endregion //盘点单 case PrintTemplateCode.AppCheckList: //res = Client.DataWrite<string>(ApiKey.ADMIN_APPINVCHKRECHANDLER_UPDATEPRINTINFO, pkId); break; ////计划单 //case PrintTemplateCode.AppPlan: // var drugPlan = Client.DataWrite<string>(ApiKey.ADMIN_PRADJMAINHANDLER_UPDATEPRINTINFO, pfmPrtLog); // break; ////采购单 //case PrintTemplateCode.AppPurchase: // var drugPurchase = Client.DataWrite<string>(ApiKey.ADMIN_PRADJMAINHANDLER_UPDATEPRINTINFO, pfmPrtLog); // break; ////合同单 //case PrintTemplateCode.AppContract: // var drugContract = Client.DataWrite<string>(ApiKey.ADMIN_PRADJMAINHANDLER_UPDATEPRINTINFO, pfmPrtLog); // break; #endregion 器械 } if (dvcPrtLogVoList != null) { //设备入库单 if (templateCode == PrintTemplateCode.EqmentDirectoryGoDown) { string json = Serializer.SerializeCamelCase(dvcPrtLogVoList); //string json = string.Join(",", dvcPrtLogVoData); var result = Client.DataWrite<string>(ApiKey.ADMIN_PLATFORM_DVCCARDHANDLER_UPDATEDVCINNOBYDVCCNOS, json); if (result.Flag != ResultFlag.SUCCESS) { MsgBox.Show($"更新入库单号接口失败!失败原因:{result.Message}", "提示"); } } else if (templateCode == PrintTemplateCode.EqmentDirectoryBCollect) { string json = Serializer.SerializeCamelCase(dvcPrtLogVoList); //string json = string.Join(",", dvcPrtLogVoData); var result = Client.DataWrite<string>(ApiKey.ADMIN_PLATFORM_DVCCHGRECHANDLER_UPDATEDVCOUTNOBYDVCCNOS, json); if (result.Flag != ResultFlag.SUCCESS) { MsgBox.Show($"更新领用单号接口失败!失败原因:{result.Message}", "提示"); } } } //if (res?.Flag == ResultFlag.SUCCESS) //{ // return true; //} //else //{ // return false; //} } /// <summary> /// 查询打印次数 /// </summary> /// <param name="templateCode">模板Code</param> /// <param name="id">主表ID</param> public static int? GetPrintNumber(string templateCode, string id) { switch (templateCode) { #region 药品 #region 药品入库 //药品自制入库 case PrintTemplateCode.DrugSelfMadeStockInDoc: //药品验收入库 case PrintTemplateCode.DrugAcceptanceSheet: //药品其他入库 case PrintTemplateCode.DrugOtherWarehousingListOf: //药品验收单 case PrintTemplateCode.DrugCheckAndAccept: //盘盈入库单 case PrintTemplateCode.DrugInventoryGainReceipt: //药品调拨单 case PrintTemplateCode.DrugAllocation: //药品报损单 case PrintTemplateCode.DrugReportLoss: //药品申领单 case PrintTemplateCode.DrugApplicationForm: //药品退库单 case PrintTemplateCode.DrugRetreatFromStorage: //药品其他出库单 case PrintTemplateCode.DrugOtherOutlets: //药品盘点单 case PrintTemplateCode.DrugCheckList: var drugGodownEntrysResult = Client.QueryEntityByString<DrugIosum>(ApiKey.ADMIN_DRUGIOSUMHANDLER_GETBYPK, id); if (drugGodownEntrysResult.Flag == ResultFlag.SUCCESS) { DrugIosum drugGodownEntrys = drugGodownEntrysResult.Value ?? new DrugIosum(); return drugGodownEntrys?.DiosPrtCnt; } else { Common.LocalLog.Write(Common.LogLevel.important, $"根据主键查询实体失败:{drugGodownEntrysResult.Flag.ToString()},{drugGodownEntrysResult.Message}"); return null; } break; #endregion //药品调价单 case PrintTemplateCode.DrugModify: var drugPradjMainResult = Client.QueryEntityByString<PradjMain>(ApiKey.ADMIN_PRADJMAINHANDLER_GETBYPK, id); if (drugPradjMainResult.Flag == ResultFlag.SUCCESS) { PradjMain drugPradjMains = drugPradjMainResult.Value ?? new PradjMain(); return drugPradjMains?.PamPrintNum; } else { Common.LocalLog.Write(Common.LogLevel.important, $"药品调价根据主键查询实体失败:{drugPradjMainResult.Flag.ToString()},{drugPradjMainResult.Message}"); return null; } break; ////计划单 //case PrintTemplateCode.DrugPlan: // var drugrugPlan = Client.QueryEntityByString<PradjMain>(ApiKey.ADMIN_PRADJMAINHANDLER_GETBYPK, id); // if (drugrugPlan.Flag == ResultFlag.SUCCESS) // { // PradjMain drugPradjMains = drugrugPlan.Value ?? new PradjMain(); // return drugPradjMains?.PamPrintNum; // } // else // { // Common.LocalLog.Write(Common.LogLevel.important, $"药品调价根据主键查询实体失败:{drugrugPlan.Flag.ToString()},{drugrugPlan.Message}"); // return null; // } // break; ////采购单 //case PrintTemplateCode.DrugPurchase: // var drugPurchase = Client.QueryEntityByString<PradjMain>(ApiKey.ADMIN_PRADJMAINHANDLER_GETBYPK, id); // if (drugPurchase.Flag == ResultFlag.SUCCESS) // { // PradjMain drugPradjMains = drugPurchase.Value ?? new PradjMain(); // return drugPradjMains?.PamPrintNum; // } // else // { // Common.LocalLog.Write(Common.LogLevel.important, $"药品调价根据主键查询实体失败:{drugPurchase.Flag.ToString()},{drugPurchase.Message}"); // return null; // } // break; ////合同单 //case PrintTemplateCode.DrugContract: // var drugContractResult = Client.QueryEntityByString<PradjMain>(ApiKey.ADMIN_PRADJMAINHANDLER_GETBYPK, id); // if (drugContractResult.Flag == ResultFlag.SUCCESS) // { // PradjMain drugPradjMains = drugContractResult.Value ?? new PradjMain(); // return drugPradjMains?.PamPrintNum; // } // else // { // Common.LocalLog.Write(Common.LogLevel.important, $"药品调价根据主键查询实体失败:{drugContractResult.Flag.ToString()},{drugContractResult.Message}"); // return null; // } // break; #endregion 药品 #region 卫材 #region 卫材入库 //自制入库 case PrintTemplateCode.EisaiSelfMadeStockInDoc: //验收入库 case PrintTemplateCode.EisaiAcceptanceSheet: //其他入库 case PrintTemplateCode.EisaiOtherWarehousingListOf: //验收单 case PrintTemplateCode.EisaiCheckAndAccept: //采购单 case PrintTemplateCode.EisaiPurchaseOrder: //盘盈入库单 case PrintTemplateCode.EisaiInventoryGainReceipt: //调拨入库单 case PrintTemplateCode.EisaiDBRK: //调拨出库单 case PrintTemplateCode.EisaiAllocation: //报损单 case PrintTemplateCode.EisaiReportLoss: //申领单 case PrintTemplateCode.EisaiApplicationForm: //退库单 case PrintTemplateCode.EisaiRetreatFromStorage: //耗材使用出库单 case PrintTemplateCode.EisaiApplyForStockReturn: //其他出库单 case PrintTemplateCode.EisaiOtherOutlets: //盘点单 case PrintTemplateCode.EisaiCheckList: var eisaiGodownEntryResult = Client.QueryEntityByString<EisaiIosum>(ApiKey.ADMIN_EISAIIOSUMHANDLER_GETBYPK, id); if (eisaiGodownEntryResult.Flag == ResultFlag.SUCCESS) { EisaiIosum eisaiGodownEntrys = eisaiGodownEntryResult.Value ?? new EisaiIosum(); return eisaiGodownEntrys?.EiosPrtCnt; } else { Common.LocalLog.Write(Common.LogLevel.important, $"根据主键查询实体失败:{eisaiGodownEntryResult.Flag.ToString()},{eisaiGodownEntryResult.Message}"); return null; } break; #endregion //调价单 case PrintTemplateCode.EisaiModify: var eisaiPradjMainResult = Client.QueryEntityByString<PradjMain>(ApiKey.ADMIN_PRADJMAINHANDLER_GETBYPK, id); if (eisaiPradjMainResult.Flag == ResultFlag.SUCCESS) { PradjMain eisaiPradjMains = eisaiPradjMainResult.Value ?? new PradjMain(); return eisaiPradjMains?.PamPrintNum; } else { Common.LocalLog.Write(Common.LogLevel.important, $"卫材调价根据主键查询实体失败:{eisaiPradjMainResult.Flag.ToString()},{eisaiPradjMainResult.Message}"); return null; } break; ////计划单 //case PrintTemplateCode.EisaiPlan: // var eisaiPlanResult = Client.QueryEntityByString<PradjMain>(ApiKey.ADMIN_PRADJMAINHANDLER_GETBYPK, id); // if (eisaiPlanResult.Flag == ResultFlag.SUCCESS) // { // PradjMain drugPradjMains = eisaiPlanResult.Value ?? new PradjMain(); // return drugPradjMains?.PamPrintNum; // } // else // { // Common.LocalLog.Write(Common.LogLevel.important, $"药品调价根据主键查询实体失败:{eisaiPlanResult.Flag.ToString()},{eisaiPlanResult.Message}"); // return null; // } // break; ////采购单 //case PrintTemplateCode.EisaiPurchase: // var eisaiPurchaseResult = Client.QueryEntityByString<PradjMain>(ApiKey.ADMIN_PRADJMAINHANDLER_GETBYPK, id); // if (eisaiPurchaseResult.Flag == ResultFlag.SUCCESS) // { // PradjMain drugPradjMains = eisaiPurchaseResult.Value ?? new PradjMain(); // return drugPradjMains?.PamPrintNum; // } // else // { // Common.LocalLog.Write(Common.LogLevel.important, $"药品调价根据主键查询实体失败:{eisaiPurchaseResult.Flag.ToString()},{eisaiPurchaseResult.Message}"); // return null; // } // break; ////合同单 //case PrintTemplateCode.EisaiContract: // var eisaiContractResult = Client.QueryEntityByString<PradjMain>(ApiKey.ADMIN_PRADJMAINHANDLER_GETBYPK, id); // if (eisaiContractResult.Flag == ResultFlag.SUCCESS) // { // PradjMain drugPradjMains = eisaiContractResult.Value ?? new PradjMain(); // return drugPradjMains?.PamPrintNum; // } // else // { // Common.LocalLog.Write(Common.LogLevel.important, $"药品调价根据主键查询实体失败:{eisaiContractResult.Flag.ToString()},{eisaiContractResult.Message}"); // return null; // } // break; #endregion #region 耗材 #region 耗材入库 //自制入库 case PrintTemplateCode.MatSelfMadeStockInDoc: //验收入库 case PrintTemplateCode.MatAcceptanceSheet: //其他入库 case PrintTemplateCode.MatOtherWarehousingListOf: //验收单 case PrintTemplateCode.MatCheckAndAccept: //盘盈入库单 case PrintTemplateCode.MatInventoryGainReceipt: var matGodownEntryResult = Client.QueryEntityByString<MatGodownEntry>(ApiKey.ADMIN_MATGODOWNENTRYHANDLER_GETBYPK, id); if (matGodownEntryResult.Flag == ResultFlag.SUCCESS) { MatGodownEntry matGodownEntrys = matGodownEntryResult.Value ?? new MatGodownEntry(); return matGodownEntrys?.MgePrtCnt; } else { Common.LocalLog.Write(Common.LogLevel.important, $"耗材入库根据主键查询实体失败:{matGodownEntryResult.Flag.ToString()},{matGodownEntryResult.Message}"); return null; } break; #endregion #region 耗材出库 //调拨单 case PrintTemplateCode.MatAllocation: //报损单 case PrintTemplateCode.MatReportLoss: //申领单 case PrintTemplateCode.MatApplicationForm: //退库单 case PrintTemplateCode.MatRetreatFromStorage: //其他出库单 case PrintTemplateCode.MatOtherOutlets: var matOutstgResult = Client.QueryEntityByString<MatOutstg>(ApiKey.ADMIN_MATOUTSTGHANDLER_GETBYPK, id); if (matOutstgResult.Flag == ResultFlag.SUCCESS) { MatOutstg matOutstgs = matOutstgResult.Value ?? new MatOutstg(); return matOutstgs?.MosPrtCnt; } else { Common.LocalLog.Write(Common.LogLevel.important, $"耗材出库根据主键查询实体失败:{matOutstgResult.Flag.ToString()},{matOutstgResult.Message}"); return null; } break; #endregion //盘点单 case PrintTemplateCode.MatCheckList: var matInvchkRecResult = Client.QueryEntityByString<MatInvchkRec>(ApiKey.ADMIN_MATINVCHKRECHANDLER_GETBYPK, id); if (matInvchkRecResult.Flag == ResultFlag.SUCCESS) { MatInvchkRec matInvchkRecs = matInvchkRecResult.Value ?? new MatInvchkRec(); return matInvchkRecs?.MicrPrintNum; } else { Common.LocalLog.Write(Common.LogLevel.important, $"耗材盘点根据主键查询实体失败:{matInvchkRecResult.Flag.ToString()},{matInvchkRecResult.Message}"); return null; } break; //计划单 case PrintTemplateCode.MatPlan: var matPlanResult = Client.QueryEntityByString<PradjMain>(ApiKey.ADMIN_PRADJMAINHANDLER_GETBYPK, id); if (matPlanResult.Flag == ResultFlag.SUCCESS) { PradjMain drugPradjMains = matPlanResult.Value ?? new PradjMain(); return drugPradjMains?.PamPrintNum; } else { Common.LocalLog.Write(Common.LogLevel.important, $"药品调价根据主键查询实体失败:{matPlanResult.Flag.ToString()},{matPlanResult.Message}"); return null; } break; ////采购单 //case PrintTemplateCode.MatPurchase: // var matPurchaseResult = Client.QueryEntityByString<PradjMain>(ApiKey.ADMIN_PRADJMAINHANDLER_GETBYPK, id); // if (matPurchaseResult.Flag == ResultFlag.SUCCESS) // { // PradjMain drugPradjMains = matPurchaseResult.Value ?? new PradjMain(); // return drugPradjMains?.PamPrintNum; // } // else // { // Common.LocalLog.Write(Common.LogLevel.important, $"药品调价根据主键查询实体失败:{matPurchaseResult.Flag.ToString()},{matPurchaseResult.Message}"); // return null; // } // break; ////合同单 //case PrintTemplateCode.MatContract: // var matContractResult = Client.QueryEntityByString<PradjMain>(ApiKey.ADMIN_PRADJMAINHANDLER_GETBYPK, id); // if (matContractResult.Flag == ResultFlag.SUCCESS) // { // PradjMain drugPradjMains = matContractResult.Value ?? new PradjMain(); // return drugPradjMains?.PamPrintNum; // } // else // { // Common.LocalLog.Write(Common.LogLevel.important, $"药品调价根据主键查询实体失败:{matContractResult.Flag.ToString()},{matContractResult.Message}"); // return null; // } // break; #endregion #region 器械 #region 器械入库 器械出库 //自制入库 case PrintTemplateCode.AppSelfMadeStockInDoc: //验收入库 case PrintTemplateCode.AppAcceptanceSheet: //其他入库 case PrintTemplateCode.AppOtherWarehousingListOf: //验收单 case PrintTemplateCode.AppCheckAndAccept: //盘盈入库单 case PrintTemplateCode.AppInventoryGainReceipt: //调拨单 case PrintTemplateCode.AppAllocation: //报损单 case PrintTemplateCode.AppReportLoss: //申领单 case PrintTemplateCode.AppApplicationForm: //退库单 case PrintTemplateCode.AppRetreatFromStorage: //其他出库单 case PrintTemplateCode.AppOtherOutlets: var queries = new List<QueryCriteria>(); queries.Add(new QueryCriteria() { Property = nameof(MaIosumVo.MaiosId), Value = id, Condition = QueryCriteria.QueryCondition.Equal }); var appGodownEntryResult = Client.QueryList<List<MaIosumVo>>(ApiKey.ADMIN_PLATFORM_MAIOSUMHANDLER_GETALL, queries, null); if (appGodownEntryResult.Flag == ResultFlag.SUCCESS) { if (appGodownEntryResult.Value.Count > 0) { MaIosumVo appGodownEntrys = appGodownEntryResult.Value[0] ?? new MaIosumVo(); return appGodownEntrys?.MaiosPrtCnt; } else { Common.LocalLog.Write(Common.LogLevel.important, $"器械出入库根据主键查询为空:{appGodownEntryResult.Flag.ToString()},{appGodownEntryResult.Message}"); return null; } } else { Common.LocalLog.Write(Common.LogLevel.important, $"器械出入库根据主键查询实体失败:{appGodownEntryResult.Flag.ToString()},{appGodownEntryResult.Message}"); return null; } break; #endregion //盘点单 case PrintTemplateCode.AppCheckList: var appInvchkRecResult = Client.QueryEntityByString<AppInvchkRec>(ApiKey.ADMIN_APPINVCHKRECHANDLER_GETBYPK, id); if (appInvchkRecResult.Flag == ResultFlag.SUCCESS) { AppInvchkRec appInvchkRecs = appInvchkRecResult.Value ?? new AppInvchkRec(); return appInvchkRecs?.AicrPrintNum; } else { Common.LocalLog.Write(Common.LogLevel.important, $"器械盘点根据主键查询实体失败:{appInvchkRecResult.Flag.ToString()},{appInvchkRecResult.Message}"); return null; } break; ////采购单 //case PrintTemplateCode.AppPurchase: // var appPurchaseResult = Client.QueryEntityByString<PradjMain>(ApiKey.ADMIN_PRADJMAINHANDLER_GETBYPK, id); // if (appPurchaseResult.Flag == ResultFlag.SUCCESS) // { // PradjMain drugPradjMains = appPurchaseResult.Value ?? new PradjMain(); // return drugPradjMains?.PamPrintNum; // } // else // { // Common.LocalLog.Write(Common.LogLevel.important, $"药品调价根据主键查询实体失败:{appPurchaseResult.Flag.ToString()},{appPurchaseResult.Message}"); // return null; // } // break; ////合同单 //case PrintTemplateCode.AppContract: // var appContractResult = Client.QueryEntityByString<PradjMain>(ApiKey.ADMIN_PRADJMAINHANDLER_GETBYPK, id); // if (appContractResult.Flag == ResultFlag.SUCCESS) // { // PradjMain drugPradjMains = appContractResult.Value ?? new PradjMain(); // return drugPradjMains?.PamPrintNum; // } // else // { // Common.LocalLog.Write(Common.LogLevel.important, $"药品调价根据主键查询实体失败:{appContractResult.Flag.ToString()},{appContractResult.Message}"); // return null; // } // break; #endregion 器械 } return null; } /// <summary> /// 设置 /// </summary> public static void PrintSeeting(Func funcEntity) { FrmPrinterSetting frmPrinterSetting = new FrmPrinterSetting(); frmPrinterSetting.FuncEntity = funcEntity; frmPrinterSetting.ShowDialog(); } /// <summary> /// 设置行数据颜色及不可编辑 /// </summary> /// <param name="currDgv">当前列表控件</param> /// <param name="amtCol">需要判断的数量字段名称</param> public static void SetDgvForeColorAndNoEdit(MzGridControl currDgv, string amtCol) { foreach (var dr in currDgv.Grid.Rows) { var amt = dr.Cells[amtCol].Value == null ? "" : dr.Cells[amtCol].Value.ToString(); if (amt == "0") { dr.Appearance.ForeColor = Color.FromName(CfgOperate.GetCfgValue(CfgCodeDefine.DOCUMENTNOEDITCOLOR)); dr.Activation = Infragistics.Win.UltraWinGrid.Activation.NoEdit; } } } #region 计划,采购,合同,验收公用方法 /// <summary> /// 查询条件 /// </summary> /// <param name="list">高级查询条件集</param> /// <param name="workflowObject">流程对象</param> /// <param name="typCode">单号类型字段名称</param> /// <param name="fillDt">编制时间字段名称</param> /// <returns></returns> private static object GetPlanObject(List<QueryCriteria> list, string workflowObject, string typCode, string fillDt) { //创建属性,并赋值。 dynamic obj = new System.Dynamic.ExpandoObject(); (obj as ICollection<KeyValuePair<string, object>>).Add(new KeyValuePair<string, object>(typCode, workflowObject)); var sysTime = Client.SystemDate; if (list.Count > 0) { foreach (var item in list) { (obj as ICollection<KeyValuePair<string, object>>).Add(new KeyValuePair<string, object>(item.Property, item.Value)); } } else { (obj as ICollection<KeyValuePair<string, object>>).Add(new KeyValuePair<string, object>(fillDt + BEGIN, string.Format("{0:" + ExtraCharacterStrDefine.DATETIME_START + "}", sysTime.AddDays(-7)))); (obj as ICollection<KeyValuePair<string, object>>).Add(new KeyValuePair<string, object>(fillDt + END, string.Format("{0:" + ExtraCharacterStrDefine.DATETIME_END + "}", sysTime))); } return obj; } /// <summary> /// 设置行数据颜色 /// </summary> /// <param name="currDgv">当前列表控件</param> /// <param name="stat">状态字段名称</param> /// <param name="rfseCoz">驳回理由字段名称</param> private static void SetPlanForeColor(MzGridControl currDgv, string stat, string rfseCoz) { foreach (var dr in currDgv.Grid.Rows) { var doStat = dr.Cells[stat].Value; if (doStat != null) { if (doStat.ToString() == WorkflowState.Wtj.GetHashCode().ToString()) { if (dr.Cells[rfseCoz].Value != null) { dr.Appearance.ForeColor = Color.FromName(CfgOperate.GetCfgValue(CfgCodeDefine.DOCUMENTREVOKECOLOR)); } else { dr.Appearance.ForeColor = Color.FromName(CfgOperate.GetCfgValue(CfgCodeDefine.DOCUMENTPRESERVATIONCOLOR)); } } else if (doStat.ToString() == WorkflowState.Ytj.GetHashCode().ToString()) { dr.Appearance.ForeColor = Color.FromName(CfgOperate.GetCfgValue(CfgCodeDefine.DOCUMENTSUBMISSIONCOLOR)); } else { dr.Appearance.ForeColor = Color.FromName(CfgOperate.GetCfgValue(CfgCodeDefine.DOCUMENTAUDITCOLOR)); } } } } /// <summary> /// 刷新数据 /// </summary> /// <param name="list">高级查询条件集</param> /// <param name="workflowObject">流程对象</param> /// <param name="currDgv">当前列表控件</param> /// <param name="typCode">单号类型字段名称</param> /// <param name="fillDt">编制时间字段名称</param> /// <param name="stat">状态字段名称</param> /// <param name="rfseCoz">驳回理由字段名称</param> public static void RefreshDrugLists(List<QueryCriteria> list, string workflowObject, MzGridControl currDgv, string typCode, string fillDt, string stat, string rfseCoz) { var obj = GetPlanObject(list, workflowObject, typCode, fillDt); //需要替换接口 var result = Client.QueryListByObject<List<DrugOrd>>(ApiKey.ADMIN_DRUGORDHANDLER_GETDRUGORDINFO, obj); if (result.Flag == ResultFlag.SUCCESS) { var drugPurOrdList = result.Value ?? new List<DrugOrd>(); if (drugPurOrdList.Count > 0) { drugPurOrdList = drugPurOrdList.OrderByDescending(m => m.DoFillDt).ToList(); currDgv.DataSource = drugPurOrdList; SetPlanForeColor(currDgv, stat, rfseCoz); } else { currDgv.DataSource = new List<DrugOrd>(); } } else { currDgv.DataSource = new List<DrugOrd>(); MsgBox.Show(result.Message, "查询失败"); Common.LocalLog.Write(Common.LogLevel.important, "{0}:{1},{2}", "查询失败", result.Flag.ToString(), result.Message); } } #region 耗材 /// <summary> /// 刷新耗材 /// </summary> /// <param name="list">高级查询条件集</param> /// <param name="workflowObject">流程对象</param> /// <param name="currDgv">当前列表控件</param> /// <param name="typCode">单号类型字段名称</param> /// <param name="fillDt">编制时间字段名称</param> /// <param name="stat">状态字段名称</param> /// <param name="rfseCoz">驳回理由字段名称</param> public static void RefreshConsumablesLists(List<QueryCriteria> list, string workflowObject, MzGridControl currDgv, string typCode, string fillDt, string stat, string rfseCoz) { var obj = GetPlanObject(list, workflowObject, typCode, fillDt); //需要替换接口 var result = Client.QueryListByObject<List<MatOrd>>(ApiKey.ADMIN_MATORDHANDLER_GETMATORDINFO, obj); if (result.Flag == ResultFlag.SUCCESS) { var matPurOrdList = result.Value ?? new List<MatOrd>(); if (matPurOrdList.Count > 0) { matPurOrdList = matPurOrdList.OrderByDescending(m => m.MoFillDt).ToList(); currDgv.DataSource = matPurOrdList; SetPlanForeColor(currDgv, stat, rfseCoz); } else { currDgv.DataSource = new List<MatOrd>(); } } else { currDgv.DataSource = new List<MatOrd>(); MsgBox.Show(result.Message, "查询失败"); Common.LocalLog.Write(Common.LogLevel.important, "{0}:{1},{2}", "查询失败", result.Flag.ToString(), result.Message); } } #endregion 耗材 /// <summary> /// 刷新数据 /// </summary> /// <param name="list">高级查询条件集</param> /// <param name="workflowObject">流程对象</param> /// <param name="currDgv">当前列表控件</param> /// <param name="typCode">单号类型字段名称</param> /// <param name="fillDt">编制时间字段名称</param> /// <param name="stat">状态字段名称</param> /// <param name="rfseCoz">驳回理由字段名称</param> public static void RefreshEisaiLists(List<QueryCriteria> list, string workflowObject, MzGridControl currDgv, string typCode, string fillDt, string stat, string rfseCoz) { var obj = GetPlanObject(list, workflowObject, typCode, fillDt); //需要替换接口 var result = Client.QueryListByObject<List<EisaiOrd>>(ApiKey.ADMIN_EISAIORDHANDLER_GETEISAIORDINFO, obj); if (result.Flag == ResultFlag.SUCCESS) { var eisaiPurOrdList = result.Value ?? new List<EisaiOrd>(); if (eisaiPurOrdList.Count > 0) { eisaiPurOrdList = eisaiPurOrdList.OrderByDescending(m => m.EoFillDt).ToList(); currDgv.DataSource = eisaiPurOrdList; SetPlanForeColor(currDgv, stat, rfseCoz); } else { currDgv.DataSource = new List<EisaiOrd>(); } } else { currDgv.DataSource = new List<EisaiOrd>(); MsgBox.Show(result.Message, "查询失败"); Common.LocalLog.Write(Common.LogLevel.important, "{0}:{1},{2}", "查询失败", result.Flag.ToString(), result.Message); } } /// <summary> /// 刷新数据 /// </summary> /// <param name="list">高级查询条件集</param> /// <param name="workflowObject">流程对象</param> /// <param name="currDgv">当前列表控件</param> /// <param name="typCode">单号类型字段名称</param> /// <param name="fillDt">编制时间字段名称</param> /// <param name="stat">状态字段名称</param> /// <param name="rfseCoz">驳回理由字段名称</param> public static void RefreshAppLists(List<QueryCriteria> list, string workflowObject, MzGridControl currDgv, string typCode, string fillDt, string stat, string rfseCoz) { var obj = GetPlanObject(list, workflowObject, typCode, fillDt); //需要替换接口 var result = Client.QueryListByObject<List<AppOrd>>(ApiKey.ADMIN_APPORDHANDLER_GETAPPORDINFO, obj); if (result.Flag == ResultFlag.SUCCESS) { var purOrdList = result.Value ?? new List<AppOrd>(); if (purOrdList.Count > 0) { purOrdList = purOrdList.OrderByDescending(m => m.AoFillDt).ToList(); currDgv.DataSource = purOrdList; SetPlanForeColor(currDgv, stat, rfseCoz); } else { currDgv.DataSource = new List<AppOrd>(); } } else { currDgv.DataSource = new List<EisaiOrd>(); MsgBox.Show(result.Message, "查询失败"); Common.LocalLog.Write(Common.LogLevel.important, "{0}:{1},{2}", "查询失败", result.Flag.ToString(), result.Message); } } #endregion public static DataTable ListToDataTable<T>(List<T> entitys) { //检查实体集合不能为空 if (entitys == null || entitys.Count < 1) { throw new Exception("需转换的集合为空"); } //取出第一个实体的所有Propertie Type entityType = entitys[0].GetType(); PropertyInfo[] entityProperties = entityType.GetProperties(); //生成DataTable的structure //生产代码中,应将生成的DataTable结构Cache起来,此处略 DataTable dt = new DataTable(); for (int i = 0; i < entityProperties.Length; i++) { //dt.Columns.Add(entityProperties[i].Name, entityProperties[i].PropertyType); dt.Columns.Add(entityProperties[i].Name); } //将所有entity添加到DataTable中 foreach (object entity in entitys) { //检查所有的的实体都为同一类型 if (entity.GetType() != entityType) { throw new Exception("要转换的集合元素类型不一致"); } object[] entityValues = new object[entityProperties.Length]; for (int i = 0; i < entityProperties.Length; i++) { entityValues[i] = entityProperties[i].GetValue(entity, null); } dt.Rows.Add(entityValues); } return dt; } /// <summary> /// 获取本机所有IPV4地址列表e799bee5baa6e4b893e5b19e31333330343831 /// </summary> /// <returns>本机所有IPV4地址列表,以分号分隔</returns> public static string GetSelfIpv4List() { StringBuilder ips = new StringBuilder(); try { IPHostEntry IpEntry = Dns.GetHostEntry(Dns.GetHostName()); foreach (IPAddress ipa in IpEntry.AddressList) { if (ipa.AddressFamily == AddressFamily.InterNetwork) ips.AppendFormat("{0};", ipa.ToString()); } } catch (Exception) { // ignored } return ips.ToString(); } /// <summary> /// 设置实体中各属性值为空 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="entity"></param> public static void SetEntityNull<T>(T entity) { PropertyInfo[] propertys = entity.GetType().GetProperties(); foreach (PropertyInfo property in propertys) { //if (property.PropertyType == typeof(string)) //{ // property.SetValue(entity, null); //} property.SetValue(entity, null); } } /// <summary> /// 计算方法 /// </summary> /// <param name="decimalPoint">1:四舍五入,2:五舍六入</param> /// <param name="d">需要格式化参数</param> /// <param name="i">显示小数位后几位</param> /// <returns></returns> public static decimal? RoundMoney(string decimalPoint, double d, int i) { if (d == 0) { switch (i) { case 1: d = 0.0; break; case 2: d = 0.00; break; case 3: d = 0.000; break; case 4: d = 0.0000; break; } } else { if (d > 0) { if (decimalPoint == "2") { d += 4 * Math.Pow(10, -(i + 1)); } else { d += 5 * Math.Pow(10, -(i + 1)); } } else { if (decimalPoint == "2") { d += -4 * Math.Pow(10, -(i + 1)); } else { d += -5 * Math.Pow(10, -(i + 1)); } } } string str = d.ToString(); string[] strs = str.Split('.'); int idot = str.IndexOf('.'); string prestr = strs[0]; if (strs.Length >= 2) { string poststr = strs[1]; if (poststr.Length > i) { poststr = str.Substring(idot + 1, i); } string strd = prestr + "." + poststr; d = Double.Parse(strd); } return d.ToDecimal(); } /// <summary> /// 格式转换C4:0.0000;C3:0.000;C2:0.00 /// </summary> /// <param name="value">C4,C3,C2</param> /// <returns></returns> public static string GetFormatConversion(string value) { if (value == "C4") { return "0.0000"; } else if (value == "C3") { return "0.000"; } else if (value == "C2") { return "0.00"; } return null; } /// <summary> /// 获取所有的资产组织结构 /// </summary> /// <returns></returns> public static List<Dept> GetAssetsDept() { List<ObjectsRange> objectsRanges = new List<ObjectsRange>() { ObjectsRange.Sb }; var filter = ServiceData.GetSubDepts(new CustomQuery() { IncludeAuthority = Extensions.NO, SsuTypCode = new List<ServiceUnitType>() { ServiceUnitType.Cck }, SsuMatrngList = objectsRanges }); if (filter == null) { return new List<Dept>(); } List<Dept> depts = ResourceBus.Current[ResourceBus.DEPT_LIST] as List<Dept>; return depts.Where(m => filter.Exists(n => n.DeptCode == m.DeptCode)).ToList() ?? new List<Dept>(); } /// <summary> ///根据权限获取资产组织结构 /// </summary> /// <param name="usrId"></param> /// <param name="funcId"></param> /// <returns></returns> public static List<Dept> GetPersonalAssetsDept(string usrId,string funcId) { List<ObjectsRange> objectsRanges = new List<ObjectsRange>() { ObjectsRange.Sb }; var filter = ServiceData.GetSubDepts(new CustomQuery() { UserId = usrId, FuncId = funcId, IncludeAuthority = Extensions.YES, SsuTypCode = new List<ServiceUnitType>() { ServiceUnitType.Cck }, SsuMatrngList = objectsRanges }); if (filter == null) { return new List<Dept>(); } List<Dept> depts = ResourceBus.Current[ResourceBus.DEPT_LIST] as List<Dept>; return depts.Where(m => filter.Exists(n => n.DeptCode == m.DeptCode)).ToList() ?? new List<Dept>(); } public static List<User> GetAssetsUser() { List<ObjectsRange> objectsRanges = new List<ObjectsRange>() { ObjectsRange.Sb }; var filter = ServiceData.GetDoctorsByRole(new CustomQuery() { IncludeAuthority = Extensions.NO, SsuTypCode = new List<ServiceUnitType>() { ServiceUnitType.Cck }, SsuMatrngList = objectsRanges }); return filter; } }