Exemple #1
0
        string type = String.Empty; // 对象类型

        protected void Page_Load(object sender, EventArgs e)
        {
            op   = RequestData.Get <string>("op");
            id   = RequestData.Get <string>("id");
            type = RequestData.Get <string>("type");
            IList <string> entStrList = RequestData.GetList <string>("data");
            InWarehouse    ent        = null;

            switch (RequestActionString)
            {
            case "create":
                ent               = this.GetPostedData <InWarehouse>();
                ent.State         = "未入库";
                ent.InWarehouseNo = DataHelper.QueryValue("select  SHHG_AimExamine.dbo.fun_getInWarehouseNo()").ToString();
                ent.CreateId      = UserInfo.UserID;
                ent.CreateName    = UserInfo.Name;
                ent.CreateTime    = System.DateTime.Now;
                ent.DoCreate();
                ProcessDetail(entStrList, ent);    //添加其他入库详情
                break;

            case "update":
                ent = this.GetMergedData <InWarehouse>();
                ent.DoUpdate();
                OtherInWarehouseDetail.DeleteAll("InWarehouseId='" + ent.Id + "'");
                ProcessDetail(entStrList, ent);    //添加其他入库详情
                break;

            case "batchdelete":
                DoBatchDelete();
                break;

            default:
                DoSelect();
                break;
            }
            if (op != "c" && op != "cs")
            {
                if (!String.IsNullOrEmpty(id))
                {
                    string sql = @"select A.*,C.Name from SHHG_AimExamine..InWarehouse as A 
                    left join SHHG_AimExamine..Warehouse as C on A.WarehouseId=C.Id where A.Id='{0}'";
                    sql = string.Format(sql, id);
                    IList <EasyDictionary> Dics = DataHelper.QueryDictList(sql);
                    if (Dics.Count > 0)
                    {
                        this.SetFormData(Dics[0]);
                    }
                }
            }
            else
            {
                //添加的时候自动生成入库单流水号
                PageState.Add("InWarehouseNo", DataHelper.QueryValue("select  SHHG_AimExamine.dbo.fun_getInWarehouseNo()"));
            }
        }
        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();
                }
            }
        }