| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- using Newtonsoft.Json.Linq;
- using PTMedicalInsurance.Business;
- using PTMedicalInsurance.Helper;
- using Sunny.UI.Win32;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace PTMedicalInsurance.Forms.BasicDatas.services
- {
- /// <summary>
- /// 手工维护目录服务类
- /// 提供新增,修改等目录操作
- /// </summary>
- class HandMaintainedDirectoryService
- {
- MIIrisServices mIS = new MIIrisServices();
- public int Add(DirectoryTypeEnum category, out string errMsg)
- {
- if ((int)category > 9)
- {
- errMsg = "当前类别不支持新增!";
- return -1;
- }
- if ((int)category == 9)
- {
- AddSingleDictionary addDictionary = new AddSingleDictionary();
- if (addDictionary.ShowDialog() == DialogResult.OK)
- {
- if (UpdateDictionaryBySelf(addDictionary, out errMsg) != 0)
- {
- return -1;
- }
- else
- {
- return 0;
- }
- }
- else
- {
- errMsg = "取消操作";
- return -1;
- }
- }
- else
- {
- AddSingleDirectory addDirectory = new AddSingleDirectory((int)category - 1);
- addDirectory.StartPosition = FormStartPosition.CenterParent;
- if (addDirectory.ShowDialog() == DialogResult.OK)
- {
- JObject joRtn = mIS.UpdateDirectoryBySelf(addDirectory.joPamam);
- return JsonHelper.parseIrisRtnValue(joRtn, out errMsg);
- }
- else
- {
- errMsg = "取消目录新增操作!";
- return -1;
- }
- }
- }
- public int Update(DirectoryTypeEnum category, DataGridView dgvDirectoy, out string errMsg)
- {
- if ((int)category > 9)
- {
- errMsg = "当前类别不支持修改!";
- return -1;
- }
- DataTable dt = (DataTable)dgvDirectoy.DataSource;
- if ((dt == null) || (dt.Rows.Count < 1))
- {
- errMsg = "表中无数据,请检查!";
- return -1;
- }
- DataRow dr = dt.Rows[dgvDirectoy.CurrentRow.Index];
- if ((int)category == 9)
- {
- AddSingleDictionary addDictionary = new AddSingleDictionary(dr);
- if (addDictionary.ShowDialog() == DialogResult.OK)
- {
- if (UpdateDictionaryBySelf(addDictionary, out errMsg) != 0)
- {
- return -1;
- }
- else
- {
- return 0;
- }
- }
- else
- {
- errMsg = "取消操作";
- return -1;
- }
- }
- else
- {
- AddSingleDirectory addDirectory = new AddSingleDirectory((int)category - 1, dr);
- addDirectory.StartPosition = FormStartPosition.CenterParent;
- if (addDirectory.ShowDialog() == DialogResult.OK)
- {
- JObject joRtn = mIS.UpdateDirectoryBySelf(addDirectory.joPamam);
- return JsonHelper.parseIrisRtnValue(joRtn, out errMsg);
- }
- else
- {
- errMsg = "取消目录修改操作!";
- return -1;
- }
- }
- }
- public int UpdateDictionaryBySelf(AddSingleDictionary addDic, out string errMsg)
- {
- string outParam = "", HBDictionaryDr = "";
- JObject joRtn;
- JObject jo = addDic.joPamam;
- try
- {
- //if (JsonHelper.getDestValue(jo, "operateType") == "0")
- //{
- //插入并获取字典主表的DR
- JObject joDic = JObject.FromObject(jo["dicObj"]);
- joRtn = mIS.insertDictionary(joDic);
- if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
- {
- return -1;
- }
- else
- {
- HBDictionaryDr = JsonHelper.getDestValue(joRtn, "data.HBDictionaryDr");
- if (HBDictionaryDr == "")
- {
- errMsg = "HBDictionaryDr返回值为空";
- return -1;
- }
- }
- //}
- //else
- //{
- // if (addDic.dr != null)
- // {
- // HBDictionaryDr = addDic.dr["hBDictionaryID"].ToString();
- // }
- // else
- // {
- // errMsg = "修改状态下未获得字典主表ID!请联系管理员";
- // return -1;
- // }
- //}
- //插入明细表
- JObject joDicDetail = JObject.FromObject(jo["detailObj"]);
- joDicDetail.Add("HBDictionaryDr", HBDictionaryDr);
- JArray jaParams = new JArray();
- jaParams.Add(joDicDetail);
- joRtn = mIS.insertDictionaryDataDetail(jaParams);
- if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
- {
- return -1;
- }
- else
- {
- return 0;
- }
- }
- catch (Exception ex)
- {
- errMsg = ex.Message;
- return -1;
- }
- }
- }
- }
|