123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- 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.LJException;
- using JLHHJSvr.Tools;
- using LJLib.DAL.SQL;
- using LJLib.Net.SPI.Server;
- namespace JLHHJSvr.Excutor
- {
- internal sealed class DelMattressExcutor : ExcutorBase<DelMattressRequest, DelMattressResponse>
- {
- protected override void ExcuteInternal(DelMattressRequest request, object state, DelMattressResponse rslt)
- {
- var tokendata = BllHelper.GetToken(request.token);
- if (tokendata == null)
- {
- rslt.ErrMsg = "会话已经中断,请重新登录";
- return;
- }
- using (var con = new SqlConnection(GlobalVar.ConnectionString))
- using (var cmd = con.CreateCommand())
- {
- con.Open();
- // 初始化属性
- //AutoInit.AutoInitS(cmd, request.mattress);
- using (cmd.Transaction = con.BeginTransaction())
- {
- try
- {
- var power77 = UserHelper.CheckFuncPower(cmd, tokendata.empid, 77);
- if (!power77)
- {
- throw new LJCommonException("你没有删除权限");
- }
- foreach (int itemid in request.mattressids)
- {
- var mattressInfo = new u_mattress() { mattressid = itemid };
- if (DbSqlHelper.SelectOne(cmd, mattressInfo, "flag, js1_flag, mattresscode, parentid") != 1)
- {
- rslt.ErrMsg = "查找报价单据失败:" + itemid;
- return;
- }
- if (mattressInfo.flag == 1)
- {
- throw new LJCommonException("床垫已审核,不能删除!(" + mattressInfo.mattresscode + ")");
- }
- if (mattressInfo.js1_flag == 1)
- {
- throw new LJCommonException("资料已技术审核不能删除!(" + mattressInfo.mattresscode + ")");
- }
- if (mattressInfo.parentid == null || mattressInfo.parentid == 0)
- {
- var list = new List<u_mattress>();
- var outputFields = @"flag, js1_flag, mattresscode";
- var selectStr = @" SELECT flag, js1_flag, mattresscode, parentid FROM u_mattress";
- var whereList = new List<string>();
- whereList.Add("parentid = @parentid");
- DbSqlHelper.SelectJoin(cmd, selectStr, ListEx.GetWhereStr(whereList), new Dictionary<string, object>() { { "@parentid", mattressInfo.mattressid } }, "mattressid", outputFields, 0, 0, list);
- if (list.Count > 0)
- {
- foreach(var mtitem in list)
- {
- if (mtitem.flag == 1)
- {
- throw new LJCommonException("副规格床垫已审核,不能删除!(" + mtitem.mattresscode + ")");
- }
- if (mtitem.js1_flag == 1)
- {
- throw new LJCommonException("副规格床垫资料已技术审核不能删除!(" + mtitem.mattresscode + ")");
- }
- }
- }
- }
- if (DbSqlHelper.Delete(cmd, mattressInfo) <= 0)
- {
- throw new LJCommonException("因网络或其它原因,删除床垫报价操作失败!");
- }
- cmd.CommandText = @"DELETE u_mattress WHERE parentid = @parentid";
- cmd.Parameters.Clear();
- cmd.Parameters.AddWithValue("@parentid", itemid);
- cmd.ExecuteNonQuery();
- }
- cmd.Transaction.Commit();
- }
- catch (Exception e)
- {
- cmd.Transaction.Rollback();
- rslt.ErrMsg = e.ToString();
- }
- }
- }
- }
- }
- }
|