1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- using System;
- using System.Collections.Generic;
- using System.Data.SqlClient;
- using System.Linq;
- using System.Text;
- using DirectService.Tools;
- using JLHHJSvr.BLL;
- using JLHHJSvr.Com;
- using JLHHJSvr.Com.Model;
- using JLHHJSvr.Helper;
- using JLHHJSvr.LJException;
- using JLHHJSvr.LJFramework.Tools;
- using JLHHJSvr.Tools;
- using LJLib.DAL.SQL;
- using LJLib.Net.SPI.Server;
- using Newtonsoft.Json.Linq;
- namespace JLHHJSvr.Excutor
- {
- internal sealed class DelMtrlPfExcutor : ExcutorBase<CreatMtrlPfRequest, CreatMtrlPfResponse>
- {
- Dictionary<string, object> replacements = new Dictionary<string, object>();
- protected override void ExcuteInternal(CreatMtrlPfRequest request, object state, CreatMtrlPfResponse rslt)
- {
- var tokendata = BllHelper.GetToken(request.token);
- if (tokendata == null)
- {
- rslt.ErrMsg = "会话已经中断,请重新登录";
- return;
- }
- if (request.mattressid <= 0)
- {
- rslt.ErrMsg = "床垫id参数为空!";
- return;
- }
- using (var con = new SqlConnection(GlobalVar.ConnectionString))
- using (var cmd = con.CreateCommand())
- {
- con.Open();
- var power91 = UserHelper.CheckFuncPower(cmd, tokendata.empid, 91);
- if (!power91)
- {
- throw new LJCommonException("你没有删除清单权限");
- }
- var mattress = new u_mattress();
- if (DbSqlHelper.SelectOne(cmd, "u_mattress", "mattressid = @mattressid", new Dictionary<string, object>() { { "mattressid", request.mattressid } }, mattress, "erp_mtrlid, creatmtrlqd_flag") != 1)
- {
- rslt.ErrMsg = "床垫报价单匹配失败";
- return;
- }
- if (mattress.erp_mtrlid <= 0)
- {
- rslt.ErrMsg = "床垫清单还没匹配L1成品";
- return;
- }
- if (mattress.creatmtrlqd_flag == 0)
- {
- rslt.ErrMsg = "床垫未生成erp清单,不能删除erp清单!";
- return;
- }
- using (var erp_con = new SqlConnection(BllHelper.GetERPConnectString(cmd)))
- using (var erp_cmd = erp_con.CreateCommand())
- {
- erp_con.Open();
- try
- {
- //删除原来的清单主表
- erp_cmd.CommandText = @"DELETE u_mtrl_pf WHERE mtrlid = @arg_mtrlid";
- erp_cmd.Parameters.Clear();
- erp_cmd.Parameters.AddWithValue("@arg_mtrlid", mattress.erp_mtrlid);
- erp_cmd.ExecuteNonQuery();
- //删除原来的清单明细表
- erp_cmd.CommandText = @"DELETE u_PrdPF WHERE mtrlid = @arg_mtrlid";
- erp_cmd.Parameters.Clear();
- erp_cmd.Parameters.AddWithValue("@arg_mtrlid", mattress.erp_mtrlid);
- erp_cmd.ExecuteNonQuery();
- erp_cmd.Transaction.Commit();
- }
- catch (Exception e)
- {
- erp_cmd.Transaction.Rollback();
- rslt.ErrMsg = e.ToString();
- }
- }
- }
- }
- }
- }
|