| | |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region 组织机构接口保存 |
| | | [Route("Xt_ORGANIZATIONS/SaveXt_ORGANIZATIONSAPI")] |
| | | [HttpPost] |
| | | public object SaveXt_ORGANIZATIONSAPI([FromBody] JObject oMain) |
| | | { |
| | | try |
| | | { |
| | | var model = oMain["model"].ToString(); |
| | | LogService.Write("1" + model); |
| | | //反序列化 |
| | | model = "[" + model + "]"; |
| | | List<Xt_ORGANIZATIONS> lsmain = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Xt_ORGANIZATIONS>>(model); |
| | | string sql = string.Empty; |
| | | oCN.BeginTran(); |
| | | foreach (var item in lsmain) |
| | | { |
| | | // 使用当前item的HItemID删除 |
| | | sql = $"delete from Xt_ORGANIZATIONS where HItemID = {item.HItemID}"; |
| | | oCN.RunProc(sql); |
| | | // 开启identity_insert |
| | | sql = "set identity_insert Xt_ORGANIZATIONS on"; |
| | | oCN.RunProc(sql); |
| | | |
| | | LogService.Write("组织机构" + @"Insert into Xt_ORGANIZATIONS (HItemID,HNumber,HName,HParentID,HStopflag,HMakeTime,HRemark)" + |
| | | " values('" + item.HItemID + "','" + item.HNumber + "','" + item.HName + "','" + item.HParentID + "','" + item.HStopflag + "'," + |
| | | ",getdate(),'" + item.HRemark + |
| | | "') "); |
| | | |
| | | // 插入当前item的记录 |
| | | sql = "Insert into Xt_ORGANIZATIONS (HItemID,HNumber,HName,HParentID,HStopflag,HMakeTime,HRemark)" + |
| | | " values('" + item.HItemID + "','" + item.HNumber + "','" + item.HName + "','" + item.HParentID + "','" + item.HStopflag + "'," + |
| | | ",getdate(),'" + item.HRemark + |
| | | "') "; |
| | | oCN.RunProc(sql); |
| | | // 关闭identity_insert |
| | | sql = "set identity_insert Xt_ORGANIZATIONS off"; |
| | | oCN.RunProc(sql); |
| | | |
| | | // 提交当前事务 |
| | | oCN.Commit(); |
| | | } |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "新增单据成功!"; |
| | | //objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exception!" + e.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | // |
| | | } |
| | | } |