/// <summary> /// 批量删除 /// </summary> /// <param name="rowsKeyValues"></param> /// <param name="loginUser"></param> /// <returns></returns> public bool BatchdeletingInfos(List <string> rowsKeyValues, string loginUser) { if (rowsKeyValues.Count == 0) { throw new Exception("MC:0x00000053");///请选中行数据 } List <KanbanPullOrderDetailInfo> kanbanPullOrderDetailInfos = dal.GetList("[ID] in (" + string.Join(",", rowsKeyValues.ToArray()) + ")", string.Empty); if (kanbanPullOrderDetailInfos.Count == 0) { throw new Exception("MC:0x00000053");///请选中行数据 } ///对应看板拉动单状态必须是10.已创建 int cnt = new KanbanPullOrderDAL().GetCounts("[FID] in ('" + string.Join("','", kanbanPullOrderDetailInfos.Select(d => d.OrderFid.GetValueOrDefault())) + "') and [STATUS] <> " + (int)PullOrderStatusConstants.Created + ""); if (cnt > 0) { throw new Exception("MC:0x00000037");///拉动单已创建状态才可以删除明细数据 } ///当同一张看板拉动单下所有明细都被删除时,更新拉动单状态为90.已作废 StringBuilder sqlBilder = new StringBuilder(); foreach (KanbanPullOrderDetailInfo kanbanPullOrderDetailInfo in kanbanPullOrderDetailInfos) { sqlBilder.AppendLine("IF NOT EXISTS (SELECT 1 FROM [LES].[TT_MPM_KANBAN_PULL_ORDER_DETAIL] with(nolock) WHERE [ID] <> " + kanbanPullOrderDetailInfo.Id + " and [VALID_FLAG] = 1 and [ORDER_FID] = N'" + kanbanPullOrderDetailInfo.OrderFid.GetValueOrDefault() + "')"); sqlBilder.AppendLine("BEGIN"); sqlBilder.AppendLine(" UPDATE [LES].[TT_MPM_KANBAN_PULL_ORDER] "); sqlBilder.AppendLine(" SET [STATUS] = " + (int)PullOrderStatusConstants.Invalid + ","); sqlBilder.AppendLine(" [MODIFY_USER] = N'" + loginUser + "',"); sqlBilder.AppendLine(" [MODIFY_DATE] = GETDATE() "); sqlBilder.AppendLine(" WHERE [FID] = '" + kanbanPullOrderDetailInfo.Fid.GetValueOrDefault() + "';"); sqlBilder.AppendLine("END"); sqlBilder.AppendLine("UPDATE [LES].[TT_MPM_KANBAN_PULL_ORDER_DETAIL] "); sqlBilder.AppendLine("SET [VALID_FLAG] = 0,"); sqlBilder.AppendLine(" [MODIFY_USER] = N'" + loginUser + "',"); sqlBilder.AppendLine(" [MODIFY_DATE] = GETDATE() "); sqlBilder.AppendLine("WHERE [ID] = " + kanbanPullOrderDetailInfo.Id + ";"); } using (TransactionScope trans = new TransactionScope()) { if (sqlBilder.Length > 0) { CommonDAL.ExecuteNonQueryBySql(sqlBilder.ToString()); } trans.Complete(); } return(true); }
public DataSet GetPrintDatas(List <string> rowsKeyValues, string loginUser) { //根据预设看板拉动单格式进行打印,格式等待业务部门提供 //打印成功后记录最后打印时间⑯、最后打印用户⑰、累计打印次数⑮ List <KanbanPullOrderInfo> list = new KanbanPullOrderDAL().GetList(string.Format("[ID] IN ({0})", string.Join(",", rowsKeyValues.ToArray())), string.Empty); if (list.Count == 0) { throw new Exception("MC:0x00000072");//没有打印文件生成 } string sql = "SELECT * FROM [LES].[TT_MPM_KANBAN_PULL_ORDER] WHERE [ID] IN({0}) AND VALID_FLAG = 1;"; sql = string.Format(sql, string.Join(",", rowsKeyValues.ToArray())); sql += string.Format("SELECT * FROM [LES].[TT_MPM_KANBAN_PULL_ORDER_DETAIL] WHERE [VALID_FLAG] = 1 AND [ORDER_FID] IN('{0}');", string.Join("','", list.Select(w => w.Fid).ToArray())); return(DAL.SYS.CommonDAL.ExecuteDataSetBySql(sql)); }