private void DoBatchDelete()
        {
            int            index  = 0;
            IList <object> idList = RequestData.GetList <object>("IdList");

            if (idList != null && idList.Count > 0)
            {
                foreach (object obj in idList)
                {
                    Compressor compEnt = Compressor.Find(obj.ToString());
                    string     sql1    = @"from InWarehouseDetail  WHERE PATINDEX('%{0}%', SeriesArray) >0";
                    sql1 = string.Format(sql1, compEnt.SeriesNo);
                    IList <InWarehouseDetail> iwdEnts = InWarehouseDetail.FindAll(sql1);
                    if (iwdEnts.Count > 0)
                    {
                        index = iwdEnts[0].SeriesArray.IndexOf(compEnt.SeriesNo);
                        iwdEnts[0].SeriesArray = iwdEnts[0].SeriesArray.Remove(index, compEnt.SeriesNo.Length);
                        iwdEnts[0].DoUpdate();
                    }
                    string sql2 = @"from OtherInWarehouseDetail  WHERE PATINDEX('%{0}%', SeriesArray) > 0";
                    sql2 = string.Format(sql2, compEnt.SeriesNo);
                    IList <OtherInWarehouseDetail> oiwdEnts = OtherInWarehouseDetail.FindAll(sql2);
                    if (oiwdEnts.Count > 0)
                    {
                        index = oiwdEnts[0].SeriesArray.IndexOf(compEnt.SeriesNo);
                        oiwdEnts[0].SeriesArray = oiwdEnts[0].SeriesArray.Remove(index, compEnt.SeriesNo.Length);
                        oiwdEnts[0].DoUpdate();
                    }
                }
            }
            Compressor.DoBatchDelete(idList.ToArray());//不能仅仅删除压缩机记录 还得把InWarehouseDetail 或者OtherInWarehouseDetail 记录的压缩机序列号删除
        }
        private void ProcessPurchaseOrderAndDetail(InWarehouse iwEnt)
        {
            string purchaseOrderId            = string.Empty;
            IList <InWarehouseDetail> iwdEnts = InWarehouseDetail.FindAll("from InWarehouseDetail where InWarehouseId='" + iwEnt.Id + "'");
            PurchaseOrderDetail       podEnt  = null;
            ArrayList poIdArray      = new ArrayList();
            int       actuallyInQuan = 0;

            foreach (InWarehouseDetail iwdEnt in iwdEnts)
            {
                if (iwdEnt.InWarehouseState == "已入库")//只有入库单详细的状态是已入库 才去遍历采购详细
                {
                    podEnt = PurchaseOrderDetail.Find(iwdEnt.PurchaseOrderDetailId);
                    if (podEnt.PurchaseOrderId != purchaseOrderId)
                    {
                        purchaseOrderId = podEnt.PurchaseOrderId;
                        poIdArray.Add(podEnt.PurchaseOrderId);
                    }
                    actuallyInQuan = DataHelper.QueryValue <int>("select  SHHG_AimExamine.dbo.fun_ActuallyHaveInQuantityByPodId('" + podEnt.Id + "')");
                    if (podEnt.Quantity == actuallyInQuan)
                    {
                        podEnt.InWarehouseState = "已入库";
                        podEnt.DoUpdate();
                    }
                }
            }//循环完毕后 再根据记录的采购单ID集合。对采购单遍历
            for (int i = 0; i < poIdArray.Count; i++)
            {
                IList <PurchaseOrderDetail> podEnts = PurchaseOrderDetail.FindAll("from PurchaseOrderDetail where InWarehouseState='未入库' and PurchaseOrderId='" + poIdArray[i].ToString() + "'");
                if (podEnts.Count == 0)
                {
                    PurchaseOrder poEnt = PurchaseOrder.Find(poIdArray[i].ToString());
                    poEnt.InWarehouseState = "已入库";
                    poEnt.DoUpdate();
                    if (poEnt.InvoiceState == "已关联" && poEnt.PayState == "已付款")
                    {
                        poEnt.OrderState = "已结束";
                        poEnt.DoUpdate();
                    }
                }
            }
        }
        private void ProcessInWarehouse(InWarehouse tempEnt)
        {
            if (tempEnt.InWarehouseType == "采购入库")
            {
                //判断其下所有的入库详细状态都未已入库 则自己的状态改为已入库
                IList <InWarehouseDetail> iwdEnts = InWarehouseDetail.FindAll("from InWarehouseDetail where InWarehouseState='未入库' and InWarehouseId='" + tempEnt.Id + "'");
                if (iwdEnts.Count == 0)
                {
                    tempEnt.State = "已入库";
                    tempEnt.InWarehouseEndTime = System.DateTime.Now;
                    tempEnt.CheckUserId        = UserInfo.UserID;
                    tempEnt.CheckUserName      = UserInfo.Name;
                    tempEnt.DoUpdate();
                }
            }
            else
            {
                IList <OtherInWarehouseDetail> oiwdEnts = OtherInWarehouseDetail.FindAll("from OtherInWarehouseDetail where InWarehouseState='未入库' and InWarehouseId='" + tempEnt.Id + "'");
                if (oiwdEnts.Count == 0)//如果明细都入库了
                {
                    //add by cc
                    string db = ConfigurationManager.AppSettings["ExamineDB"];
                    if (tempEnt.InWarehouseType == "退货入库")
                    {
                        ReturnOrder rtnOrder = ReturnOrder.TryFind(tempEnt.PublicInterface);
                        if (rtnOrder != null)
                        {
                            rtnOrder.State = "已完成";
                            rtnOrder.DoSave();
                            //判断是否已经全部退货
                            //string DeliveryState = "";
                            //string tempId = DataHelper.QueryValue<string>("select top 1 Id from " + db + "..Saleorders where number='" + rtnOrder.OrderNumber + "'");
                            //if (!string.IsNullOrEmpty(tempId))
                            //{
                            //    DeliveryState = DataHelper.QueryValue<string>("select " + db + ".dbo.fun_getDeliveryState('" + tempId + "')");
                            //}

                            ////更新SaleOrder表出库状态
                            //if (DeliveryState == "已全部退货")
                            //{
                            //    DataHelper.ExecSql("update " + db + "..SaleOrders set DeState='已全部退货',DeliveryState='已全部退货' where Number='" + rtnOrder.OrderNumber + "'");
                            //}
                            //else
                            //{
                            //    DataHelper.ExecSql("update " + db + "..SaleOrders set DeState='" + DeliveryState + "' where Number='" + rtnOrder.OrderNumber + "'");
                            //    //DataHelper.ExecSql("update " + db + "..SaleOrders set DeState=" + db + ".dbo.fun_getDeliveryState(Id) where Number='" + rtnOrder.OrderNumber + "'");
                            //}
                        }
                    }
                    //else if (tempEnt.InWarehouseType == "换货入库")
                    //{
                    //    ChangeProduct dorder = ChangeProduct.TryFind(tempEnt.PublicInterface);
                    //    if (dorder != null)
                    //    {
                    //        if ((dorder.State + "").Contains("已出库"))
                    //        {
                    //            dorder.State = "已完成";
                    //        }
                    //        else
                    //        {
                    //            dorder.State += ",仓库已入库:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                    //        }
                    //        dorder.DoSave();

                    //        //更新SaleOrder表出库状态
                    //        DataHelper.ExecSql("update " + db + "..SaleOrders set DeState=" + db + ".dbo.fun_getDeliveryState(Id) where Number='" + dorder.OrderNumber + "'");
                    //    }
                    //}
                    //end add by cc
                    else if (tempEnt.InWarehouseType == "调拨入库")
                    {
                        WarehouseExchange weEnt = WarehouseExchange.TryFind(tempEnt.PublicInterface);
                        weEnt.InWarehouseState = "已入库";
                        weEnt.DoUpdate();
                        if (weEnt.OutWarehouseState == "已出库")
                        {
                            weEnt.ExchangeState = "已结束";
                            weEnt.EndTime       = System.DateTime.Now;
                            weEnt.DoUpdate();
                        }
                    }
                    tempEnt.State = "已入库";
                    tempEnt.InWarehouseEndTime = System.DateTime.Now;
                    tempEnt.CheckUserId        = UserInfo.UserID;
                    tempEnt.CheckUserName      = UserInfo.Name;
                    tempEnt.DoUpdate();
                }
            }
        }