llj
2026-04-15 6fda811163c017da43817435e06b76040d90ac32
增加批量删除功能
1个文件已修改
106 ■■■■■ 已修改文件
WebAPI/Controllers/基础资料/基础资料/Cb_OtherOutBill_CostSubjectDetailController.cs 106 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/»ù´¡×ÊÁÏ/»ù´¡×ÊÁÏ/Cb_OtherOutBill_CostSubjectDetailController.cs
@@ -297,7 +297,12 @@
                    {
                        continue;
                    }
                    if(!string.IsNullOrEmpty(item["日期"]) )
                    {
                        item["年份"]=item["日期"].Split('-')[0];
                        item["月份"] =item["日期"].Split('-')[1];
                    }
                    insertSql.AppendLine($"INSERT INTO [Cb_OtherOutBill_CostSubjectDetail] ([HYear], [HPeriod], [HBillType], [HBillSubType], [HDate], [HBillNo], [HBillStatus], [HCheckItemNowID], [HCheckItemNextID], [HCheckFlowID], [HRemark], [HBacker], [HBackDate], [HChecker], [HCheckDate], [HMaker], [HMakeDate], [HUpDater], [HUpDateDate], [HCloseMan], [HCloseDate], [HCloseType], [HDeleteMan], [HDeleteDate], [HWareHouse], [HStockPlace], [HUseType], [HUseDepartment], [HCostSubject], [HCostSubjectSon], [HSubjectProc], [HMaterNumber], [HMaterName], [HModel], [HUnit], [HQty], [HCostPrice], [HTotalPrice], [HLOT], [HRemark2], [HUsePerson], [HWareHousePerson], [HAssetName], [HAssetNumber], [HSearchProject], [HVerify])  VALUES (");
                    insertSql.AppendLine($" {item["年份"]}, {item["月份"]}, {1}, '{1}', '{item["日期"]}',  '{item["单据编号"]}', '{1}', '{1}', '{1}', '{1}', '{item["备注"]}', '{""}', '{DateTime.Now}', '{""}', '{DateTime.Now}', '{""}', '{DateTime.Now}', '{""}', '{DateTime.Now}', '{""}', '{DateTime.Now}', '{"0"}', '{""}', '{DateTime.Now}', '{item["发货仓库"]}', '{item["仓位"]}', '{item["领料类型"]}', '{item["领料部门"]}', '{item["成本科目"]}', '{item["成本科目二级"]}', '{item["科目+工序"]}', '{item["物料编码"]}', '{item["物料名称"]}', '{item["规格型号"]}', '{item["单位"]}', '{item["实发数量"]}', '{item["成本价"]}', '{item["总成本"]}', '{item["批号"]}', '{"excel导入"}', '{item["领料人"]}', '{item["仓管员"]}', '{item["资产名称"]}', '{item["资产编号"]}', '{item["研发项目"]}', '{item["核对"]}');");
@@ -355,5 +360,106 @@
            }
        }
        #endregion 
        #region åˆ é™¤
        [Route("Cb_OtherOutBill_CostSubjectDetail/DeltetCb_OtherOutBill_CostSubjectDetail")]
        [HttpGet]
        public object DeltetCb_OtherOutBill_CostSubjectDetail(string HItemIDs, string user)
        {
            DataSet ds;
            try
            {
                //删除权限
                if (!DBUtility.ClsPub.Security_Log("Gy_CostAverageType_Drop", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无删除权限";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                if (string.IsNullOrWhiteSpace(HItemIDs))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HItemID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.BeginTran();//开始事务
                ds = oCN.RunProcReturn("select * from Cb_OtherOutBill_CostSubjectDetail where HInterID in (" + HItemIDs+" )", "Cb_OtherOutBill_CostSubjectDetail");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有数据,无法删除!";
                    objJsonResult.data = null;
                    return objJsonResult; ;
                }
                else if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "已经审核不能删除!";
                    objJsonResult.data = null;
                    return objJsonResult; ;
                }
                else
                {
                }
                //var HStopflag = Convert.ToBoolean(ds.Tables[0].Rows[0]["HStopflag"]);
                //if (HStopflag)
                //{
                //    oCN.RollBack();//回滚事务
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "数据已被禁用无法再次删除!";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                oCN.RunProc("delete from Cb_OtherOutBill_CostSubjectDetail where HInterID in (" + HItemIDs + ")");
                ////写入日志
                //string Operation = "删除";                                          //操作
                //string ComputerName = System.Net.Dns.GetHostName();                 //设备名称
                //string WorkList = Operation + "成本分配类型,成本分配类型代码:" + HNumber + ";成本分配类型名称:" + HName;         //操作详情
                //string MvarReportTitle = "成本分配类型列表";                                //操作模块
                //string SystemName = "LMES-" + MvarReportTitle + "模块";             //操作模块
                //string IPAddress = "";
                ////string IPAddress = Dns.GetHostEntry(Dns.GetHostName()).AddressList[0].ToString();   //IP地址
                ////string IPAddress = System.Web.HttpContext.Current.Request.UserHostAddress;
                //oCN.RunProc("Insert into  System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State) values " +
                //    "(getdate(),'" + user + "','" + ComputerName + "','" + WorkList + "','" + SystemName + "','" + IPAddress + "','" + Operation + "')"
                //    );
                oCN.Commit();//提交事务
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "* æ•°æ®åˆ é™¤æˆåŠŸï¼";
                objJsonResult.data = null;
                return objJsonResult; ;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "删除失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }
}