Ejemplo n.º 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)
            {
            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]);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         Aim.Portal.Web.WebPortalService.CheckLogon();
     }
     catch
     {
         Response.Write("<script> window.location.href = '/Login.aspx';</script>");
         Response.End();
     }
     string action = Request["action"];
     string where = "";
     DataTable dt = null;
     string id = Request["id"];
     InWarehouse iwEnt = null;
     IList<InWarehouseDetail> iwdEnts = null;
     switch (action)
     {
         case "load":
             if (!string.IsNullOrEmpty(Request["InWarehouseNo"]))
             {
                 where += " and InWarehouseNo like '%" + Request["InWarehouseNo"].Trim() + "%'";
             }
             if (!string.IsNullOrEmpty(Request["SupplierName"]))
             {
                 where += " and SupplierName like '%" + Request["SupplierName"].Trim() + "%'";
             }
             if (!string.IsNullOrEmpty(Request["State"]))
             {
                 where += " and State = '" + Request["State"] + "'";
             }
             if (!string.IsNullOrEmpty(Request["ProductCode"]))
             {
                 where += " and Id in (select distinct InWarehouseId from SHHG_AimExamine..InWarehouseDetail where  ProductCode like '%" + Request["ProductCode"] + "%')";
             }
             sql = "select * from SHHG_AimExamine..InWarehouse where InWarehouseType ='采购入库' " + where;
             dt = DataHelper.QueryDataTable(GetPageSql(sql));
             Response.Write("{total:" + totalProperty + ",rows:" + JsonHelper.GetJsonStringFromDataTable(dt) + "}");
             Response.End();
             break;  
         case "delete":
             if (!string.IsNullOrEmpty(id))
             {
                 iwEnt = InWarehouse.Find(id);
                 iwdEnts = InWarehouseDetail.FindAllByProperty("InWarehouseId", id);
                 foreach (InWarehouseDetail tempEnt in iwdEnts)
                 {
                     sql = "select sum(isnull(IQuantity,0)) from SHHG_AimExamine..InWarehouseDetail where PurchaseOrderDetailId='" + tempEnt.PurchaseOrderDetailId + "'";
                     tempEnt.DoDelete();
                    //删除完入库单明细后更新采购单明细的生成入库单数量
                     PurchaseOrderDetail podEnt = PurchaseOrderDetail.Find(tempEnt.PurchaseOrderDetailId);
                     podEnt.RuKuDanQuan = DataHelper.QueryValue<Int32>(sql);
                     podEnt.DoUpdate();
                 }
                 iwEnt.DoDelete();
             }
             break;
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 审核表单
        /// </summary>
        /// <param name="TransferBillId"></param>
        /// <returns></returns>
        public string Examine(Guid BackInputId, string UserName)
        {
            string        result = "";
            BackInput     bill   = CurrentDal.LoadEntities(a => a.Id == BackInputId).FirstOrDefault();
            List <Record> list   = bill.Record.ToList();

            foreach (Record item in list)
            {
                item.State       = 2;
                item.ExamineDate = DateTime.Now;
                InWarehouse inWarehouse = CurrentDBSession.InWarehouseDal.LoadEntities(i => i.ItemCode == item.ItemCode && i.ItemLocationId == item.ItemLocationId && i.ItemBatch == item.ItemBatch).FirstOrDefault();
                if (inWarehouse == null || inWarehouse.Count < item.Count) //当前库存不够 ,不允许做弃审操作
                {
                    result = "物料编号:" + item.ItemCode + "物料名称:" + item.ItemName + "库存不足,审核失败";
                    return(result);
                }
                else if (inWarehouse.Count == item.Count)
                {
                    CurrentDBSession.InWarehouseDal.DeleteEntity(inWarehouse);
                }
                else //有库存
                {
                    inWarehouse.Count -= item.Count;
                    CurrentDBSession.InWarehouseDal.EditEntity(inWarehouse);
                }
            }
            bill.BillState     = 2;        //改成已审核状态
            bill.ExaminePerson = UserName; //审核人
            bill.ExamineDate   = DateTime.Now;
            CurrentDal.EditEntity(bill);
            result = CurrentDBSession.SaveChanges() ? "审核成功!" : "审核失败!";
            return(result);
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            switch (RequestActionString)
            {
            case "batchdelete":
                IList <object> idList = RequestData.GetList <object>("IdList");
                if (idList != null && idList.Count > 0)
                {
                    foreach (object obj in idList)
                    {
                        InWarehouse[] iwEnts = InWarehouse.FindAllByProperties("PublicInterface", obj.ToString());
                        if (iwEnts.Length > 0)
                        {
                            OtherInWarehouseDetail.DeleteAll("InWarehouseId='" + iwEnts[0].Id + "'");
                            InWarehouse.DeleteAll("PublicInterface='" + obj.ToString() + "'");
                        }
                        DeliveryOrder[] doEnts = DeliveryOrder.FindAllByProperties("PId", obj.ToString());
                        if (doEnts.Length > 0)
                        {
                            DelieryOrderPart.DeleteAll("DId='" + doEnts[0].Id + "'");
                            DeliveryOrder.DeleteAll("PId='" + obj.ToString() + "'");
                        }
                        DataHelper.ExecSql("delete SHHG_AimExamine..WarehouseExchange where Id='" + obj.ToString() + "'");
                        DataHelper.ExecSql("delete SHHG_AimExamine..WarehouseExchangeDetail where WarehouseExchangeId='" + obj.ToString() + "'");
                        PageState.Add("Message", "删除成功!");
                    }
                }
                break;

            default:
                DoSelect();
                break;
            }
        }
Ejemplo n.º 5
0
        private void ProcessDetail(InWarehouse iwEnt)
        {
            ropEnts = ReturnOrderPart.FindAllByProperty(ReturnOrderPart.Prop_ReturnOrderId, id);
            foreach (ReturnOrderPart ropEnt in ropEnts)
            {
                ropEnt.DoDelete();
            }
            IList <string> entStrList = RequestData.GetList <string>("data");

            ropEnts = entStrList.Select(tent => JsonHelper.GetObject <ReturnOrderPart>(tent) as ReturnOrderPart).ToList();
            foreach (ReturnOrderPart ropEnt in ropEnts)
            {
                ropEnt.ReturnOrderId = ent.Id;
                ropEnt.DoCreate();
                OrdersPart opEnt = OrdersPart.Find(ropEnt.OrderPartId);//更新销售单明细的退货数量
                opEnt.ReturnCount = (opEnt.ReturnCount.HasValue ? opEnt.ReturnCount : 0) + ropEnt.Count;
                opEnt.DoUpdate();
                OtherInWarehouseDetail oidEnt = new OtherInWarehouseDetail();//创建入库单明细
                oidEnt.InWarehouseId    = iwEnt.Id;
                oidEnt.ProductId        = ropEnt.ProductId;
                oidEnt.ProductName      = ropEnt.ProductName;
                oidEnt.ProductCode      = ropEnt.ProductCode;
                oidEnt.ProductISBN      = ropEnt.Isbn;
                oidEnt.ProductType      = Product.Find(ropEnt.ProductId).ProductType;
                oidEnt.Quantity         = ropEnt.Count;
                oidEnt.InWarehouseState = "未入库";
                oidEnt.Remark           = ropEnt.Remark;
                oidEnt.DoCreate();
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 审核表单
        /// </summary>
        /// <param name="TransferBillId"></param>
        /// <returns></returns>
        public string Examine(Guid OtherInputId, string UserName)
        {
            OtherInput         bill    = CurrentDal.LoadEntities(a => a.Id == OtherInputId).FirstOrDefault();
            List <Record>      list    = bill.Record.ToList();
            List <InWarehouse> listAdd = new List <InWarehouse>();//新增列表

            foreach (Record item in list)
            {
                item.State       = 2;
                item.ExamineDate = DateTime.Now;
                InWarehouse inWarehouse = CurrentDBSession.InWarehouseDal.LoadEntities(i => i.ItemCode == item.ItemCode && i.ItemLocationId == item.ItemLocationId && i.ItemBatch == item.ItemBatch).FirstOrDefault();
                //查暂存
                InWarehouse temp = listAdd.Where(p => p.ItemCode == item.ItemCode && p.ItemLocationId == item.ItemLocationId && p.ItemBatch == item.ItemBatch).FirstOrDefault();
                if (inWarehouse == null && temp == null)//如果都没有库存  新建一条记录
                {
                    inWarehouse = new InWarehouse()
                    {
                        Id                 = Guid.NewGuid(),
                        ItemBatch          = item.ItemBatch,
                        ItemCode           = item.ItemCode,
                        ItemLine           = item.ItemLine,
                        ItemLocation       = item.ItemLocation,
                        ItemLocationId     = item.ItemLocationId,
                        Warehouse          = item.Warehouse,
                        WarehouseId        = item.WarehouseId,
                        ItemName           = item.ItemName,
                        ItemSpecifications = item.ItemSpecifications,
                        ItemUnit           = item.ItemUnit,
                        Count              = item.Count,
                        Company            = bill.Company,
                        CompanyId          = bill.CompanyId,
                        Department         = bill.Department,
                        DepartmentId       = bill.DepartmentId
                    };
                    item.CurrentCount = item.Count;
                    listAdd.Add(inWarehouse);                 //添加到暂存区
                }
                else if (inWarehouse == null && temp != null) //只有暂存区有库存
                {
                    temp.Count       += item.Count;
                    item.CurrentCount = temp.Count;
                }
                else //数据库有库存
                {
                    inWarehouse.Count += item.Count;
                    CurrentDBSession.InWarehouseDal.EditEntity(inWarehouse);
                    item.CurrentCount = inWarehouse.Count;
                }
            }
            //最后添加新增列表中数据
            foreach (var item in listAdd)
            {
                CurrentDBSession.InWarehouseDal.AddEntity(item);
            }
            bill.BillState     = 2;        //改成已审核状态
            bill.ExaminePerson = UserName; //审核人
            bill.ExamineDate   = DateTime.Now;
            CurrentDal.EditEntity(bill);
            return(CurrentDBSession.SaveChanges() ? "操作成功" : "操作失败");
        }
Ejemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            switch (RequestActionString)
            {
            case "Judge":
                string id = RequestData.Get <string>("id");
                if (!string.IsNullOrEmpty(id))
                {
                    InWarehouse       iwEnt = InWarehouse.Find(id);
                    WarehouseExchange weEnt = WarehouseExchange.Find(iwEnt.PublicInterface);
                    if (weEnt.OutWarehouseState == "已出库")
                    {
                        PageState.Add("Allow", true);
                    }
                    else
                    {
                        PageState.Add("Allow", false);
                    }
                }
                break;

            default:
                DoSelect();
                break;
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 审核表单
        /// </summary>
        /// <param name="TransferBillId"></param>
        /// <returns></returns>
        public string Examine(Guid GiveBillId, string UserName)
        {
            string        result = "";
            GiveBill      bill   = CurrentDal.LoadEntities(a => a.Id == GiveBillId).FirstOrDefault();
            List <Record> list   = bill.Record.ToList();

            foreach (Record item in list)
            {
                InWarehouse inWarehouse = CurrentDBSession.InWarehouseDal.LoadEntities(i => i.ItemCode == item.ItemCode && i.ItemLocationId == item.ItemLocationId && i.ItemBatch == item.ItemBatch).FirstOrDefault();
                if (inWarehouse == null || inWarehouse.Count < item.Count)//如果没有库存  新建一条记录
                {
                    result = "物料编号:" + item.ItemCode + "物料名称:" + item.ItemName + "库存不足,弃审失败";
                    return(result);
                }
                else if (inWarehouse.Count == item.Count) // 库存正好相等  删除这条记录
                {
                    CurrentDBSession.InWarehouseDal.DeleteEntity(inWarehouse);
                    item.State = 2;
                }
                else if (inWarehouse.Count > item.Count)//库存大于记录  相减
                {
                    inWarehouse.Count = inWarehouse.Count - item.Count;
                    CurrentDBSession.InWarehouseDal.EditEntity(inWarehouse);
                    item.State = 2;
                }
            }
            bill.BillState     = 2;        //改成已审核状态
            bill.ExaminePerson = UserName; //审核人
            bill.ExamineDate   = DateTime.Now;
            CurrentDal.EditEntity(bill);
            result = CurrentDBSession.SaveChanges() ? "审核成功!" : "审核失败!";
            return(result);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 审核表单
        /// </summary>
        /// <param name="TransferBillId"></param>
        /// <returns></returns>
        public string Examine(Guid BackInputId, string UserName)
        {
            string             res     = "";
            BackInput          bill    = CurrentDal.LoadEntities(a => a.Id == BackInputId).FirstOrDefault();
            List <Record>      list    = bill.Record.ToList();
            List <InWarehouse> listDel = new List <InWarehouse>();//暂存区

            foreach (Record item in list)
            {
                item.State       = 2;
                item.ExamineDate = DateTime.Now;
                InWarehouse inWarehouse = CurrentDBSession.InWarehouseDal.LoadEntities(i => i.ItemCode == item.ItemCode && i.ItemLocationId == item.ItemLocationId && i.ItemBatch == item.ItemBatch).FirstOrDefault();
                InWarehouse temp        = listDel.Where(i => i.ItemCode == item.ItemCode && i.ItemLocationId == item.ItemLocationId && i.ItemBatch == item.ItemBatch).FirstOrDefault(); //缓存区
                if (temp != null)                                                                                                                                                       //缓存区有  说明数量不足
                {
                    res += "物料编号:" + item.ItemCode + ",物料名称:" + item.ItemName + ",批次:" + item.ItemBatch + ",库存不足,审核失败";
                    continue;
                }
                if (inWarehouse == null || inWarehouse.Count < item.Count)//缓存区没有   数量为空或者小于
                {
                    res += "物料编号:" + item.ItemCode + ",物料名称:" + item.ItemName + ",批次:" + item.ItemBatch + ",库存不足,审核失败";
                    continue;
                }

                //缓存区没有  数量相等 应该删除 加入缓存区
                if (inWarehouse.Count == item.Count) // 暂存区中没有 库存正好相等  删除这条记录
                {
                    listDel.Add(inWarehouse);        //添加到删除暂存区
                    item.CurrentCount = 0;           //当前库存量
                    continue;
                }
                if (inWarehouse.Count > item.Count)//库存大于记录 暂存区中没有 则相减
                {
                    inWarehouse.Count = inWarehouse.Count - item.Count;
                    item.CurrentCount = inWarehouse.Count;//当前库存量
                    CurrentDBSession.InWarehouseDal.EditEntity(inWarehouse);
                }
                else //数据异常了  应该进不来 记录错误
                {
                    res += "物料编号:" + item.ItemCode + ",数量:" + item.Count + "数据异常!请记下物料编号联系管理员检查!";
                }
            }
            if (res != "")
            {
                return(res);
            }
            //删除缓存区数据
            foreach (var item in listDel)
            {
                CurrentDBSession.InWarehouseDal.DeleteEntity(item);
            }
            bill.BillState     = 2;        //改成已审核状态
            bill.ExaminePerson = UserName; //审核人
            bill.ExamineDate   = DateTime.Now;
            CurrentDal.EditEntity(bill);
            res = CurrentDBSession.SaveChanges() ? "审核成功!" : "审核失败!";
            return(res);
        }
Ejemplo n.º 10
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()"));
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 弃审
        /// </summary>
        /// <param name="TransferBillId">单据Id</param>
        /// <param name="UserName">用户名</param>
        /// <returns></returns>
        public string GiveupExamine(Guid BackInputId, string UserName)
        {
            BackInput     bill = CurrentDal.LoadEntities(a => a.Id == BackInputId).FirstOrDefault();
            List <Record> list = bill.Record.ToList();
            string        res  = "";

            if (bill.BillState != 2)
            {
                res = "单据状态不对,无法弃审!";
                return(res);
            }
            //对每一条记录做逆操作
            foreach (Record item in list)
            {
                item.State       = 1;    //修改记录状态
                item.ExamineDate = null; //清空审核时间
                InWarehouse inWarehouse = CurrentDBSession.InWarehouseDal.LoadEntities(i => i.ItemCode == item.ItemCode && i.ItemLocationId == item.ItemLocationId && i.ItemBatch == item.ItemBatch).FirstOrDefault();
                if (inWarehouse == null) //如果没有库存  新建一条记录
                {
                    inWarehouse = new InWarehouse()
                    {
                        Id                 = Guid.NewGuid(),
                        ItemBatch          = item.ItemBatch,
                        ItemCode           = item.ItemCode,
                        ItemLine           = item.ItemLine,
                        ItemLocation       = item.ItemLocation,
                        ItemLocationId     = item.ItemLocationId,
                        Warehouse          = item.Warehouse,
                        WarehouseId        = item.WarehouseId,
                        ItemName           = item.ItemName,
                        ItemSpecifications = item.ItemSpecifications,
                        ItemUnit           = item.ItemUnit,
                        Count              = item.Count,
                        Department         = item.Department,
                        DepartmentId       = item.DepartmentId,
                        Company            = bill.Company,
                        CompanyId          = bill.CompanyId
                    };
                    CurrentDBSession.InWarehouseDal.AddEntity(inWarehouse);
                }
                else//库存有记录  相加
                {
                    inWarehouse.Count = inWarehouse.Count + item.Count;
                    CurrentDBSession.InWarehouseDal.EditEntity(inWarehouse);
                }
            }
            bill.BillState     = 1;    //改成编辑状态
            bill.ExaminePerson = null; //清除审核人
            bill.ExamineDate   = null; //清除审核时间
            CurrentDal.EditEntity(bill);
            return(CurrentDBSession.SaveChanges() ? "操作成功" : "操作失败");
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 审核表单
        /// </summary>
        /// <param name="TransferBillId"></param>
        /// <returns></returns>
        public string Examine(Guid OtherInputId, string UserName)
        {
            string        result = "";
            OtherInput    bill   = CurrentDal.LoadEntities(a => a.Id == OtherInputId).FirstOrDefault();
            List <Record> list   = bill.Record.ToList();

            foreach (Record item in list)
            {
                item.State       = 2;
                item.ExamineDate = DateTime.Now;
                InWarehouse inWarehouse = CurrentDBSession.InWarehouseDal.LoadEntities(i => i.ItemCode == item.ItemCode && i.ItemLocationId == item.ItemLocationId && i.ItemBatch == item.ItemBatch).FirstOrDefault();
                if (inWarehouse == null)//如果没有库存  新建一条记录
                {
                    InWarehouse newInWarehouse = new InWarehouse();
                    newInWarehouse.Id                 = Guid.NewGuid();
                    newInWarehouse.ItemCode           = item.ItemCode;
                    newInWarehouse.ItemLine           = item.ItemLine;
                    newInWarehouse.ItemName           = item.ItemName;
                    newInWarehouse.ItemSpecifications = item.ItemSpecifications;
                    newInWarehouse.ItemLocation       = item.ItemLocation;
                    newInWarehouse.ItemLocationId     = item.ItemLocationId;
                    newInWarehouse.Warehouse          = item.Warehouse;
                    newInWarehouse.WarehouseId        = item.WarehouseId;
                    newInWarehouse.ItemBatch          = item.ItemBatch;
                    newInWarehouse.ItemUnit           = item.ItemUnit;
                    newInWarehouse.Count              = item.Count;
                    newInWarehouse.Department         = bill.Department;
                    newInWarehouse.DepartmentId       = bill.DepartmentId;
                    newInWarehouse.Company            = bill.Company;
                    newInWarehouse.CompanyId          = bill.CompanyId;
                    CurrentDBSession.InWarehouseDal.AddEntity(newInWarehouse);
                }
                else //有库存
                {
                    inWarehouse.Count += item.Count;
                    CurrentDBSession.InWarehouseDal.EditEntity(inWarehouse);
                }
            }
            bill.BillState     = 2;        //改成已审核状态
            bill.ExaminePerson = UserName; //审核人
            bill.ExamineDate   = DateTime.Now;
            CurrentDal.EditEntity(bill);
            if (CurrentDBSession.SaveChanges())
            {
                result = "1";
            }
            else
            {
                result = "-1";
            }
            return(result);
        }
Ejemplo n.º 13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            op = RequestData.Get <string>("op");
            id = RequestData.Get <string>("id");
            if (!string.IsNullOrEmpty(id))
            {
                ent = ReturnOrder.Find(id);
            }
            switch (RequestActionString)
            {
            case "update":
                ent = GetMergedData <ReturnOrder>();
                ent.DoUpdate();
                break;

            case "create":
                ent        = this.GetPostedData <ReturnOrder>();
                ent.Number = DataHelper.QueryValue("select SHHG_AimExamine.dbo.fun_getReturnOrderNumber()") + "";     //自动生成流水号
                ent.State  = "已生成";
                ent.DoCreate();
                soent = SaleOrder.FindAllByProperty("Number", ent.OrderNumber).FirstOrDefault <SaleOrder>();
                soent.ReturnAmount = (soent.ReturnAmount.HasValue ? soent.ReturnAmount.Value : 0) + ent.ReturnMoney;
                soent.DoUpdate();    //将退货金额反写到销售单
                if (soent.InvoiceState == "已全部开发票")
                {
                    ent.IsDiscount = "T";
                    ent.DoUpdate();
                }
                InWarehouse inwh = new InWarehouse
                {
                    PublicInterface = ent.Id,                   //退货单Id
                    InWarehouseNo   = DataHelper.QueryValue("select SHHG_AimExamine.dbo.fun_getInWarehouseNo()").ToString(),
                    InWarehouseType = "退货入库",
                    WarehouseId     = ent.WarehouseId,
                    WarehouseName   = ent.WarehouseName,
                    State           = "未入库"
                };
                inwh.DoCreate();
                ProcessDetail(inwh);
                break;

            case "GetSaleOrderPart":
                string orderNumber = RequestData.Get <string>("OrderNumber");
                soent = SaleOrder.FindAllByProperty("Number", orderNumber).FirstOrDefault <SaleOrder>();
                PageState.Add("Result", OrdersPart.FindAllByProperty(OrdersPart.Prop_OId, soent.Id));
                break;

            default:
                DoSelect();
                break;
            }
        }
Ejemplo n.º 14
0
        private bool AllowDelete(string supplierId)
        {
            bool result = true;

            if (!string.IsNullOrEmpty(supplierId))
            {
                IList <Product>       proEnts = Product.FindAll("from Product where SupplierId='" + supplierId + "'");             //有产品的供应商不允许删除
                IList <PurchaseOrder> poEnts  = PurchaseOrder.FindAll("from PurchaseOrder where SupplierId='" + supplierId + "'"); //有没有做采购单
                IList <InWarehouse>   iwEnts  = InWarehouse.FindAll("from InWarehouse where SupplierId='" + supplierId + "'");     //有没有做入库单
                if (poEnts.Count > 0 || iwEnts.Count > 0 || proEnts.Count > 0)
                {
                    result = false;
                }
            }
            return(result);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 审核表单
        /// </summary>
        /// <param name="TransferBillId"></param>
        /// <returns></returns>
        public string Examine(Guid OtherOutputId, string UserName)
        {
            string        result = "";
            OtherOutput   bill   = CurrentDal.LoadEntities(a => a.Id == OtherOutputId).FirstOrDefault();
            List <Record> list   = bill.Record.ToList();

            foreach (Record item in list)
            {
                InWarehouse inWarehouse = CurrentDBSession.InWarehouseDal.LoadEntities(i => i.ItemCode == item.ItemCode && i.ItemLocationId == item.ItemLocationId && i.ItemBatch == item.ItemBatch).FirstOrDefault();
                if (inWarehouse == null || inWarehouse.Count < item.Count)//如果没有库存
                {
                    result = "物料编号:" + item.ItemCode + "物料名称:" + item.ItemName + "库存不足,弃审失败";
                    return(result);
                }
                else //有库存
                {
                    if (inWarehouse.Count > item.Count)
                    {
                        inWarehouse.Count -= item.Count;
                        CurrentDBSession.InWarehouseDal.EditEntity(inWarehouse);
                        bill.BillState     = 2;        //改成已审核状态
                        bill.ExaminePerson = UserName; //审核人
                        bill.ExamineDate   = DateTime.Now;
                        item.State         = 2;
                        CurrentDal.EditEntity(bill);
                    }
                    else if (inWarehouse.Count == item.Count)
                    {
                        CurrentDBSession.InWarehouseDal.DeleteEntity(inWarehouse);
                        bill.BillState     = 2;        //改成已审核状态
                        bill.ExaminePerson = UserName; //审核人
                        bill.ExamineDate   = DateTime.Now;
                        item.State         = 2;
                        CurrentDal.EditEntity(bill);
                    }
                }
            }
            if (CurrentDBSession.SaveChanges())
            {
                result = "1";
            }
            else
            {
                result = "-1";
            }
            return(result);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 审核表单
        /// </summary>
        /// <param name="TransferBillId"></param>
        /// <returns></returns>
        public string Examine(Guid BackOutputId, string UserName)
        {
            string        result = "";
            BackOutput    bill   = CurrentDal.LoadEntities(a => a.Id == BackOutputId).FirstOrDefault();
            List <Record> list   = bill.Record.ToList();

            foreach (Record item in list)
            {
                item.State       = 2;
                item.ExamineDate = DateTime.Now;
                InWarehouse inWarehouse = CurrentDBSession.InWarehouseDal.LoadEntities(i => i.ItemCode == item.ItemCode && i.ItemLocationId == item.ItemLocationId && i.ItemBatch == item.ItemBatch).FirstOrDefault();
                if (inWarehouse == null) //当前库存不够 ,不允许做弃审操作
                {
                    inWarehouse = new InWarehouse()
                    {
                        Id                 = Guid.NewGuid(),
                        ItemBatch          = item.ItemBatch,
                        ItemCode           = item.ItemCode,
                        ItemLine           = item.ItemLine,
                        ItemLocation       = item.ItemLocation,
                        ItemLocationId     = item.ItemLocationId,
                        Warehouse          = item.Warehouse,
                        WarehouseId        = item.WarehouseId,
                        ItemName           = item.ItemName,
                        ItemSpecifications = item.ItemSpecifications,
                        ItemUnit           = item.ItemUnit,
                        Count              = item.Count,
                        Department         = item.Department,
                        DepartmentId       = item.DepartmentId,
                        Company            = bill.Company,
                        CompanyId          = bill.CompanyId
                    };
                    CurrentDBSession.InWarehouseDal.AddEntity(inWarehouse);
                }
                else //有库存
                {
                    inWarehouse.Count += item.Count;
                    CurrentDBSession.InWarehouseDal.EditEntity(inWarehouse);
                }
            }
            bill.BillState     = 2;        //改成已审核状态
            bill.ExaminePerson = UserName; //审核人
            bill.ExamineDate   = DateTime.Now;
            CurrentDal.EditEntity(bill);
            result = CurrentDBSession.SaveChanges() ? "审核成功!" : "审核失败!";
            return(result);
        }
Ejemplo n.º 17
0
        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();
                    }
                }
            }
        }
Ejemplo n.º 18
0
 private void ProcessInWarehouseDetail(IList <string> entStrList, InWarehouse iwEnt)
 {
     if (entStrList != null && entStrList.Count > 0)
     {
         for (int j = 0; j < entStrList.Count; j++)
         {
             JObject json = JsonHelper.GetObject <JObject>(entStrList[j]);
             OtherInWarehouseDetail oiwdEnt = new OtherInWarehouseDetail();
             oiwdEnt.InWarehouseId    = iwEnt.Id;
             oiwdEnt.ProductId        = json.Value <string>("ProductId");
             oiwdEnt.ProductName      = json.Value <string>("ProductName");
             oiwdEnt.ProductCode      = json.Value <string>("ProductCode");
             oiwdEnt.ProductPCN       = json.Value <string>("ProductPcn");
             oiwdEnt.ProductISBN      = json.Value <string>("ProductIsbn");
             oiwdEnt.InWarehouseState = "未入库";
             oiwdEnt.Quantity         = json.Value <int>("ExchangeQuantity");
             oiwdEnt.DoCreate();
         }
     }
 }
Ejemplo n.º 19
0
        /// <summary>
        /// 审核表单
        /// </summary>
        /// <param name="TransferBillId"></param>
        /// <returns></returns>
        public bool Examine(Guid TransferBillId, string UserName)
        {
            TransferBill  bill = CurrentDal.LoadEntities(a => a.Id == TransferBillId).FirstOrDefault();
            List <Record> list = bill.Record.ToList();

            foreach (Record item in list)
            {
                item.State       = 2;
                item.ExamineDate = DateTime.Now;
                InWarehouse inWarehouse = CurrentDBSession.InWarehouseDal.LoadEntities(i => i.ItemCode == item.ItemCode && i.ItemLocationId == item.ItemLocationId && i.ItemBatch == item.ItemBatch).FirstOrDefault();
                if (inWarehouse == null)//如果没有库存  新建一条记录
                {
                    inWarehouse = new InWarehouse()
                    {
                        Id                 = Guid.NewGuid(),
                        ItemBatch          = item.ItemBatch,
                        ItemCode           = item.ItemCode,
                        ItemLine           = item.ItemLine,
                        ItemLocation       = item.ItemLocation,
                        Warehouse          = item.Warehouse,
                        WarehouseId        = item.WarehouseId,
                        ItemName           = item.ItemName,
                        ItemSpecifications = item.ItemSpecifications,
                        ItemUnit           = item.ItemUnit,
                        Count              = item.Count,
                        ItemLocationId     = item.ItemLocationId
                    };
                    CurrentDBSession.InWarehouseDal.AddEntity(inWarehouse);
                }
                else //有库存
                {
                    inWarehouse.Count += item.Count;
                    CurrentDBSession.InWarehouseDal.EditEntity(inWarehouse);
                }
            }
            bill.BillState     = 2;            //改成已审核状态
            bill.ExaminePerson = UserName;     //审核人
            bill.ExamineDate   = DateTime.Now; //审核时间
            CurrentDal.EditEntity(bill);
            return(CurrentDBSession.SaveChanges());
        }
Ejemplo n.º 20
0
 private void DoSelect()
 {
     if (!string.IsNullOrEmpty(id))
     {
         InWarehouse            ent             = InWarehouse.Find(id);
         string                 tempsql         = @"select A.* ,B.Name from SHHG_AimExamine..InWarehouse as A 
         left join SHHG_AimExamine..Warehouse as B on A.WarehouseId=B.Id where A.Id='" + id + "'";
         IList <EasyDictionary> dicsInWarehouse = DataHelper.QueryDictList(tempsql);
         if (dicsInWarehouse.Count > 0)
         {
             this.SetFormData(dicsInWarehouse[0]);
         }
         string sql = string.Empty;
         if (ent.InWarehouseType == "采购入库")
         {
             sql = @"select A.Id,A.ProductId, A.IQuantity as Quantity,A.InWarehouseId,A.InWarehouseState,
             A.Remark,A.SkinArray,A.SeriesArray,A.PurchaseOrderDetailId,
             UPPER(rtrim(ltrim(B.Isbn))) as ISBN,B.Name,UPPER(B.Code) as Code,B.ProductType,
             SHHG_AimExamine.dbo.fun_ActuallyHaveInQuantity(A.Id,'{0}') as HaveIn,                   
             (A.IQuantity-SHHG_AimExamine.dbo.fun_ActuallyHaveInQuantity(A.Id,'{1}')) as NoIn
             from SHHG_AimExamine..InWarehouseDetail as A 
             left join SHHG_AimExamine..Products as B on A.ProductId=B.Id
             where A.InWarehouseId='{2}'";
             sql = string.Format(sql, ent.InWarehouseType, ent.InWarehouseType, ent.Id);
         }
         else
         {
             sql = @"select A.Id,A.ProductId,A.Quantity,A.InWarehouseId,A.InWarehouseState,A.Remark,A.SkinArray,A.SeriesArray,
             UPPER(B.Code) as Code , B.Name,UPPER(rtrim(ltrim(B.Isbn))) as ISBN,B.ProductType,
             SHHG_AimExamine.dbo.fun_ActuallyHaveInQuantity(A.Id,'{0}') as HaveIn,
             (A.Quantity-SHHG_AimExamine.dbo.fun_ActuallyHaveInQuantity(A.Id,'{1}')) as NoIn
             from SHHG_AimExamine..OtherInWarehouseDetail as A 
             left join SHHG_AimExamine..Products as B on A.ProductId=B.Id  where A.InWarehouseId='{2}'";
             sql = string.Format(sql, ent.InWarehouseType, ent.InWarehouseType, ent.Id);
         }
         IList <EasyDictionary> dics = DataHelper.QueryDictList(sql);
         PageState.Add("DetailList", dics);
     }
 }
Ejemplo n.º 21
0
 private void ProcessDetail(IList <string> entStrList, InWarehouse iwEnt)
 {
     if (entStrList != null && entStrList.Count > 0)
     {
         for (int j = 0; j < entStrList.Count; j++)
         {
             Newtonsoft.Json.Linq.JObject objL   = JsonHelper.GetObject <Newtonsoft.Json.Linq.JObject>(entStrList[j]);
             OtherInWarehouseDetail       oidEnt = new OtherInWarehouseDetail();
             oidEnt.InWarehouseId    = iwEnt.Id;
             oidEnt.ProductId        = objL.Value <string>("ProductId");
             oidEnt.ProductName      = objL.Value <string>("ProductName");
             oidEnt.ProductCode      = objL.Value <string>("ProductCode");
             oidEnt.ProductPCN       = objL.Value <string>("ProductPCN");
             oidEnt.ProductISBN      = objL.Value <string>("ProductISBN");
             oidEnt.ProductType      = objL.Value <string>("ProductType");
             oidEnt.Quantity         = objL.Value <int>("Quantity");
             oidEnt.InWarehouseState = "未入库";
             oidEnt.Remark           = objL.Value <string>("Remark");
             oidEnt.DoCreate();
         }
     }
 }
Ejemplo n.º 22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            id = RequestData.Get <string>("id");
            if (!string.IsNullOrEmpty(id))
            {
                roEnt = ReturnOrder.Find(id);
            }
            switch (RequestActionString)
            {
            case "delete":
                //先删除入库单及入库明细
                InWarehouse iwEnt = InWarehouse.FindAllByProperty(InWarehouse.Prop_PublicInterface, roEnt.Id).FirstOrDefault <InWarehouse>();
                IList <OtherInWarehouseDetail> oiwdEnts = OtherInWarehouseDetail.FindAllByProperty(OtherInWarehouseDetail.Prop_InWarehouseId, iwEnt.Id);
                foreach (OtherInWarehouseDetail oiwdEnt in oiwdEnts)
                {
                    oiwdEnt.DoDelete();
                }
                iwEnt.DoDelete();
                //更新销售单及销售明细
                SaleOrder soEnt = SaleOrder.FindAllByProperty(SaleOrder.Prop_Number, roEnt.OrderNumber).FirstOrDefault <SaleOrder>();
                soEnt.ReturnAmount = (soEnt.ReturnAmount.HasValue ? soEnt.ReturnAmount.Value : 0) - (roEnt.ReturnMoney.HasValue ? roEnt.ReturnMoney.Value : 0);
                soEnt.DoUpdate();
                IList <ReturnOrderPart> ropEnts = ReturnOrderPart.FindAllByProperty(ReturnOrderPart.Prop_ReturnOrderId, roEnt.Id);
                foreach (ReturnOrderPart ropEnt in ropEnts)
                {
                    OrdersPart opEnt = OrdersPart.Find(ropEnt.OrderPartId);
                    opEnt.ReturnCount = (opEnt.ReturnCount.HasValue ? opEnt.ReturnCount.Value : 0) - ropEnt.Count;
                    opEnt.DoUpdate();
                    ropEnt.DoDelete();
                }
                roEnt.DoDelete();
                break;

            default:
                DoSelect();
                break;
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 弃审
        /// </summary>
        /// <param name="TransferBillId">单据Id</param>
        /// <param name="UserName">用户名</param>
        /// <returns></returns>
        public string GiveupExamine(Guid BackOutputId, string UserName)
        {
            BackOutput    bill = CurrentDal.LoadEntities(a => a.Id == BackOutputId).FirstOrDefault();
            List <Record> list = bill.Record.ToList();
            string        res  = "";

            if (bill.BillState != 2)
            {
                res = "单据状态不对,无法弃审!";
                return(res);
            }
            //对每一条记录做逆操作
            foreach (Record item in list)
            {
                item.State       = 1;                                      //修改记录状态
                item.ExamineDate = null;                                   //清空审核时间
                InWarehouse inWarehouse = CurrentDBSession.InWarehouseDal.LoadEntities(i => i.ItemCode == item.ItemCode && i.ItemLocationId == item.ItemLocationId && i.ItemBatch == item.ItemBatch).FirstOrDefault();
                if (inWarehouse == null || inWarehouse.Count < item.Count) //如果没有库存  新建一条记录
                {
                    res = "物料编号:" + item.ItemCode + "物料名称:" + item.ItemName + "库存不足,弃审失败";
                    return(res);
                }
                else if (inWarehouse.Count == item.Count) // 库存正好相等  删除这条记录
                {
                    CurrentDBSession.InWarehouseDal.DeleteEntity(inWarehouse);
                }
                else if (inWarehouse.Count > item.Count)//库存大于记录  相减
                {
                    inWarehouse.Count = inWarehouse.Count - item.Count;
                    CurrentDBSession.InWarehouseDal.EditEntity(inWarehouse);
                }
            }
            bill.BillState     = 1;    //改成编辑状态
            bill.ExaminePerson = null; //清除审核人
            bill.ExamineDate   = null; //清除审核时间
            CurrentDal.EditEntity(bill);
            return(CurrentDBSession.SaveChanges() ? "操作成功" : "操作失败");
        }
Ejemplo n.º 24
0
        protected void Page_Load(object sender, EventArgs e)
        {
            op = RequestData.Get <string>("op");
            id = RequestData.Get <string>("id");
            switch (RequestActionString)
            {
            case "IsIsbn":
                string          val     = RequestData.Get <string>("Value");
                IList <Product> proEnts = Product.FindAll("from Product where Isbn='" + val + "'");
                if (proEnts.Count > 0)
                {
                    PageState.Add("IsIsbn", true);
                }
                else
                {
                    PageState.Add("IsIsbn", false);
                }
                break;

            case "GetPackageInfo":
                string Isbn = RequestData.Get <string>("Isbn");
                sql = "select * from SHHG_AimExamine..Products where FirstSkinIsbn='" + Isbn + "' and FirstSkinCapacity is not null";
                IList <EasyDictionary> dics = DataHelper.QueryDictList(sql);
                if (dics.Count > 0)
                {
                    PageState.Add("ProductIsbn", dics[0].Get <string>("Isbn").ToUpper());
                    PageState.Add("ProductQuan", dics[0].Get <int>("FirstSkinCapacity"));
                }
                sql  = "select * from SHHG_AimExamine..Products where SecondSkinIsbn='" + Isbn + "' and SecondSkinCapacity is not null";
                dics = DataHelper.QueryDictList(sql);
                if (dics.Count > 0)
                {
                    PageState.Add("ProductIsbn", dics[0].Get <string>("Isbn").ToUpper());
                    PageState.Add("ProductQuan", dics[0].Get <int>("SecondSkinCapacity"));
                }
                break;

            case "ScanSkin":    //判断包装编号是否存在
                string       skinNo = RequestData.Get <string>("SkinNo");
                IList <Skin> sEnts  = Skin.FindAll("from Skin where SkinNo='" + skinNo + "'");
                if (sEnts.Count > 0)    //如果该包装的记录不存在
                {
                    PageState.Add("SkinExist", true);
                }
                else
                {
                    PageState.Add("SkinExist", false);
                }
                break;

            case "ScanCompressor":
                string             seriesNo = RequestData.Get <string>("SeriesNo");
                IList <Compressor> cEnts    = Compressor.FindAll("from Compressor where SeriesNo='" + seriesNo + "'");
                if (cEnts.Count == 0)
                {
                    PageState.Add("CompressorExist", false);
                }
                else
                {
                    PageState.Add("CompressorExist", true);
                }
                break;

            case "InWarehouse":
                InWarehouse    iwEnt      = InWarehouse.TryFind(id);
                IList <string> entStrList = RequestData.GetList <string>("data");
                if (entStrList != null && entStrList.Count > 0)
                {
                    for (int j = 0; j < entStrList.Count; j++)
                    {
                        Newtonsoft.Json.Linq.JObject objL = JsonHelper.GetObject <Newtonsoft.Json.Linq.JObject>(entStrList[j]);
                        if (Convert.ToInt32(objL.Value <string>("ActuallyQuantity")) > 0)    //只有输入了入库数量才会增加实际入库记录
                        {
                            InWarehouseDetailDetail iwddEnt = new InWarehouseDetailDetail(); //新建一个实际入库详细信息
                            if (iwEnt.InWarehouseType == "采购入库")
                            {
                                iwddEnt.InWarehouseDetailId   = objL.Value <string>("Id");
                                iwddEnt.PurchaseOrderDetailId = objL.Value <string>("PurchaseOrderDetailId");
                            }
                            else    //其他入库的情形
                            {
                                iwddEnt.OtherInWarehouseDetailId = objL.Value <string>("Id");
                            }
                            iwddEnt.Quantity  = Convert.ToInt32(objL.Value <string>("ActuallyQuantity"));
                            iwddEnt.ProductId = objL.Value <string>("ProductId");
                            iwddEnt.Remark    = objL.Value <string>("Remark");
                            iwddEnt.DoCreate();

                            StockLog slEnt = new StockLog();    //创建库存变更日志
                            slEnt.InOrOutDetailId = objL.Value <string>("Id");
                            slEnt.InOrOutBillNo   = iwEnt.InWarehouseNo;
                            slEnt.OperateType     = "产品入库";
                            slEnt.WarehouseId     = iwEnt.WarehouseId;
                            slEnt.WarehouseName   = iwEnt.WarehouseName;
                            IList <StockInfo> siEnts = StockInfo.FindAllByProperties(StockInfo.Prop_ProductId, objL.Value <string>("ProductId"), StockInfo.Prop_WarehouseId, iwEnt.WarehouseId);
                            if (siEnts.Count > 0)
                            {
                                slEnt.StockQuantity = siEnts[0].StockQuantity;
                            }
                            slEnt.Quantity  = Convert.ToInt32(objL.Value <string>("ActuallyQuantity"));
                            slEnt.ProductId = objL.Value <string>("ProductId");
                            Product pEnt = Product.Find(objL.Value <string>("ProductId"));
                            slEnt.ProductName = pEnt.Name;
                            slEnt.ProductCode = pEnt.Code;
                            slEnt.ProductIsbn = pEnt.Isbn;
                            slEnt.ProductPcn  = pEnt.Pcn;
                            slEnt.DoCreate();

                            ProcessSkin(objL.Value <string>("SkinArray"), objL.Value <string>("ISBN"), iwEnt.Id);
                            ProcessCompressor(objL.Value <string>("SeriesArray"), objL.Value <string>("ISBN"), iwEnt.Id);
                            processremark(objL.Value <string>("Remark"), pEnt, iwEnt.Id);

                            //如果实际入库数量和未入库的数量相等 则入库状态为已入库
                            if (objL.Value <string>("ActuallyQuantity") == objL.Value <string>("NoIn"))
                            {
                                if (iwEnt.InWarehouseType == "采购入库")
                                {
                                    InWarehouseDetail iwdEnt = InWarehouseDetail.Find(objL.Value <string>("Id"));
                                    if (!string.IsNullOrEmpty(objL.Value <string>("SkinArray")))
                                    {
                                        iwdEnt.SkinArray = objL.Value <string>("SkinArray").ToString();
                                    }
                                    if (!string.IsNullOrEmpty(objL.Value <string>("SeriesArray")))
                                    {
                                        iwdEnt.SeriesArray = objL.Value <string>("SeriesArray").ToString();
                                    }
                                    iwdEnt.InWarehouseState = "已入库";
                                    iwdEnt.DoUpdate();
                                }
                                else
                                {
                                    OtherInWarehouseDetail oiwdEnt = OtherInWarehouseDetail.Find(objL.Value <string>("Id"));
                                    oiwdEnt.InWarehouseState = "已入库";
                                    if (!string.IsNullOrEmpty(objL.Value <string>("SkinArray")))
                                    {
                                        oiwdEnt.SkinArray = objL.Value <string>("SkinArray").ToString();
                                    }
                                    if (!string.IsNullOrEmpty(objL.Value <string>("SeriesArray")))
                                    {
                                        oiwdEnt.SeriesArray = objL.Value <string>("SeriesArray").ToString();
                                    }
                                    oiwdEnt.DoUpdate();
                                }
                            }
                            else    //如果未入库的数量不等于现在输入的数量。只更新包装和压缩机序列号集合
                            {
                                if (iwEnt.InWarehouseType == "采购入库")
                                {
                                    InWarehouseDetail iwdEnt = InWarehouseDetail.Find(objL.Value <string>("Id"));
                                    iwdEnt.Remark = objL.Value <string>("Remark");
                                    if (!string.IsNullOrEmpty(objL.Value <string>("SkinArray")))
                                    {
                                        iwdEnt.SkinArray = objL.Value <string>("SkinArray").ToString();
                                    }
                                    if (!string.IsNullOrEmpty(objL.Value <string>("SeriesArray")))
                                    {
                                        iwdEnt.SeriesArray = objL.Value <string>("SeriesArray").ToString();
                                    }
                                    iwdEnt.DoUpdate();
                                }
                                else
                                {
                                    OtherInWarehouseDetail oiwdEnt = OtherInWarehouseDetail.Find(objL.Value <string>("Id"));
                                    oiwdEnt.Remark = objL.Value <string>("Remark");
                                    if (!string.IsNullOrEmpty(objL.Value <string>("SkinArray")))
                                    {
                                        oiwdEnt.SkinArray = objL.Value <string>("SkinArray").ToString();
                                    }
                                    if (!string.IsNullOrEmpty(objL.Value <string>("SeriesArray")))
                                    {
                                        oiwdEnt.SeriesArray = objL.Value <string>("SeriesArray").ToString();
                                    }
                                    oiwdEnt.DoUpdate();
                                }
                            }
                            //修改库存
                            InStorage(iwddEnt.ProductId, iwddEnt.Quantity.Value, iwEnt.WarehouseId);
                        }
                    }
                }
                ProcessInWarehouse(iwEnt);
                if (iwEnt.InWarehouseType == "采购入库")    //处理采购单和采购单详细
                {
                    ProcessPurchaseOrderAndDetail(iwEnt);
                }
                break;

            default:
                DoSelect();
                break;
            }
        }
Ejemplo n.º 25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Aim.Portal.Web.WebPortalService.CheckLogon();
            }
            catch
            {
                Response.Write("<script> window.location.href = '/Login.aspx';</script>");
                Response.End();
            }
            string      action = Request["action"];
            string      sql    = "";
            DataTable   dt     = null;
            InWarehouse iwEnt  = null;
            IList <InWarehouseDetail> iwdEnts = null;
            PurchaseOrderDetail       podEnt  = null;
            string PurchaseOrderIds           = Request["PurchaseOrderIds"];
            string id = Request["id"];

            if (!string.IsNullOrEmpty(id))
            {
                iwEnt = InWarehouse.Find(id);
            }
            switch (action)
            {
            case "loaddetail":
                if (!string.IsNullOrEmpty(PurchaseOrderIds))
                {
                    sql = @"select a.Id as PurchaseOrderDetailId, a.ProductId,a.Code as ProductCode,                                            
                        (a.Quantity-isnull(a.RuKuDanQuan,0)) as IQuantity, (a.Quantity-isnull(a.RuKuDanQuan,0)) as MaxQuan,b.PurchaseOrderNo
                        from SHHG_AimExamine..PurchaseOrderDetail a left join SHHG_AimExamine..PurchaseOrder b on a.PurchaseOrderId=b.Id 
                        where '" + PurchaseOrderIds + "' like '%'+PurchaseOrderId+'%' and  (a.Quantity-isnull(a.RuKuDanQuan,0))>0 order by a.Code asc";
                }
                if (!string.IsNullOrEmpty(id))
                {
                    sql = @"select a.Id,a.PurchaseOrderDetailId, a.ProductId,a.ProductCode,a.IQuantity, a.YiRuQuan, 
                        c.PurchaseOrderNo,a.InWarehouseState, a.Remark,(b.Quantity-isnull(b.RuKuDanQuan,0)+a.IQuantity) as MaxQuan   
                        from SHHG_AimExamine..InWarehouseDetail a left join SHHG_AimExamine..PurchaseOrderDetail b
                        on a.PurchaseOrderDetailId=b.Id left join SHHG_AimExamine..PurchaseOrder c on c.Id=b.PurchaseOrderId  
                        where a.InWarehouseId='" + id + "' order by a.ProductCode asc";
                }
                dt = DataHelper.QueryDataTable(sql);
                Response.Write("{rows:" + JsonHelper.GetJsonStringFromDataTable(dt) + "}");
                Response.End();
                break;

            case "loadform":
                if (!string.IsNullOrEmpty(PurchaseOrderIds))
                {
                    iwEnt = new InWarehouse();
                    iwEnt.InWarehouseNo   = DataHelper.QueryValue("select SHHG_AimExamine.dbo.fun_getInWarehouseNo()").ToString();
                    iwEnt.InWarehouseType = "采购入库";
                    string[]      idarray = PurchaseOrderIds.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    PurchaseOrder poEnt   = PurchaseOrder.Find(idarray[0]);
                    iwEnt.SupplierId   = poEnt.SupplierId;
                    iwEnt.SupplierName = poEnt.SupplierName;
                    Response.Write("{success:true,data:" + JsonHelper.GetJsonString(iwEnt) + "}");
                }
                if (!string.IsNullOrEmpty(id))
                {
                    Response.Write("{success:true,data:" + JsonHelper.GetJsonString(iwEnt) + "}");
                }
                Response.End();
                break;

            case "create":
                string formdata   = Request["formdata"];
                string detaildata = Request["detaildata"];
                iwEnt            = JsonHelper.GetObject <InWarehouse>(Request["formdata"]);
                iwEnt.CreateId   = Aim.Portal.Web.WebPortalService.CurrentUserInfo.UserID;
                iwEnt.CreateName = Aim.Portal.Web.WebPortalService.CurrentUserInfo.Name;
                iwEnt.CreateTime = DateTime.Now;
                iwEnt.State      = "未入库";
                iwEnt.DoCreate();
                iwdEnts = JsonHelper.GetObject <IList <InWarehouseDetail> >(Request["detaildata"]);
                foreach (InWarehouseDetail iwdEnt in iwdEnts)
                {
                    iwdEnt.InWarehouseId    = iwEnt.Id;
                    iwdEnt.InWarehouseState = "未入库";
                    iwdEnt.DoCreate();
                    //创建完入库单明细后更新采购单明细的生成入库单数量
                    sql                = "select sum(isnull(IQuantity,0)) from SHHG_AimExamine..InWarehouseDetail where PurchaseOrderDetailId='" + iwdEnt.PurchaseOrderDetailId + "'";
                    podEnt             = PurchaseOrderDetail.Find(iwdEnt.PurchaseOrderDetailId);
                    podEnt.RuKuDanQuan = DataHelper.QueryValue <Int32>(sql);
                    podEnt.DoUpdate();
                }
                Response.Write("{success:true}");
                Response.End();
                break;

            case "update":
                InWarehouse    tempEnt = JsonHelper.GetObject <InWarehouse>(Request["formdata"]);
                EasyDictionary dic     = JsonHelper.GetObject <EasyDictionary>(Request["formdata"]);
                iwEnt = DataHelper.MergeData <InWarehouse>(iwEnt, tempEnt, dic.Keys);
                iwEnt.DoUpdate();
                sql = "delete SHHG_AimExamine..InWarehouseDetail where InWarehouseId='" + iwEnt.Id + "'";
                DataHelper.ExecSql(sql);
                iwdEnts = JsonHelper.GetObject <IList <InWarehouseDetail> >(Request["detaildata"]);
                foreach (InWarehouseDetail iwdEnt in iwdEnts)
                {
                    iwdEnt.InWarehouseId    = iwEnt.Id;
                    iwdEnt.InWarehouseState = "未入库";
                    iwdEnt.DoCreate();
                    //创建完入库单明细后更新采购单明细的生成入库单数量
                    sql                = "select sum(isnull(IQuantity,0)) from SHHG_AimExamine..InWarehouseDetail where PurchaseOrderDetailId='" + iwdEnt.PurchaseOrderDetailId + "'";
                    podEnt             = PurchaseOrderDetail.Find(iwdEnt.PurchaseOrderDetailId);
                    podEnt.RuKuDanQuan = DataHelper.QueryValue <Int32>(sql);
                    podEnt.DoUpdate();
                }
                break;
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// 弃审
        /// </summary>
        /// <param name="TransferBillId">单据Id</param>
        /// <param name="UserName">用户名</param>
        /// <returns></returns>
        public string GiveupExamine(Guid DIYBillId, string UserName)
        {
            DIYBill       bill  = CurrentDal.LoadEntities(a => a.Id == DIYBillId).FirstOrDefault();
            List <Record> list1 = CurrentDBSession.RecordDal.LoadEntities(b => b.MainTableId == bill.Id && b.InOrOut == 1).ToList();
            List <Record> list0 = CurrentDBSession.RecordDal.LoadEntities(b => b.MainTableId == bill.Id && b.InOrOut == 0).ToList();
            string        res   = "";

            if (bill.BillState != 2)
            {
                res = "单据状态不对,无法弃审!";
                return(res);
            }
            List <InWarehouse> listAdd = new List <InWarehouse>(); //新增列表
            List <InWarehouse> listDel = new List <InWarehouse>(); //删除列表

            //对每一条记录做逆操作
            foreach (Record item in list0)
            {
                item.State       = 1;
                item.ExamineDate = null;
                InWarehouse inWarehouse = CurrentDBSession.InWarehouseDal.LoadEntities(i => i.ItemCode == item.ItemCode && i.ItemLocation == item.ItemLocation && i.ItemBatch == item.ItemBatch).FirstOrDefault();
                InWarehouse tempAdd     = listAdd.Where(i => i.ItemCode == item.ItemCode && i.ItemLocationId == item.ItemLocationId && i.ItemBatch == item.ItemBatch).FirstOrDefault(); //缓存加
                if (inWarehouse == null && tempAdd == null)                                                                                                                             // 都没有
                {
                    inWarehouse = new InWarehouse()
                    {
                        Id                 = Guid.NewGuid(),
                        ItemBatch          = item.ItemBatch,
                        ItemCode           = item.ItemCode,
                        ItemLine           = item.ItemLine,
                        ItemLocation       = item.ItemLocation,
                        ItemLocationId     = item.ItemLocationId,
                        Warehouse          = item.Warehouse,
                        WarehouseId        = item.WarehouseId,
                        ItemName           = item.ItemName,
                        ItemSpecifications = item.ItemSpecifications,
                        ItemUnit           = item.ItemUnit,
                        Count              = item.Count,
                        Company            = bill.Company,
                        CompanyId          = bill.CompanyId,
                        Department         = bill.Department,
                        DepartmentId       = bill.DepartmentId
                    };
                    item.CurrentCount = item.Count;
                    listAdd.Add(inWarehouse);                    //添加到暂存区
                }
                else if (inWarehouse == null && tempAdd != null) //只有缓存加有
                {
                    tempAdd.Count    += item.Count;
                    item.CurrentCount = tempAdd.Count;
                }
                else if (inWarehouse != null && tempAdd == null)//只有库存有
                {
                    inWarehouse.Count += item.Count;
                    item.CurrentCount  = inWarehouse.Count;
                }
                else //有库存
                {
                    return("入库记录有问题(" + item.ItemCode + "-" + item.ItemBatch + "-" + item.ItemLocationId + "),请联系管理员检查!");
                }
            }
            foreach (Record item in list1)
            {
                item.State       = 1;
                item.ExamineDate = null;
                InWarehouse inWarehouse = CurrentDBSession.InWarehouseDal.LoadEntities(i => i.ItemCode == item.ItemCode && i.ItemLocation == item.ItemLocation && i.ItemBatch == item.ItemBatch).FirstOrDefault();
                InWarehouse tempAdd     = listAdd.Where(i => i.ItemCode == item.ItemCode && i.ItemLocationId == item.ItemLocationId && i.ItemBatch == item.ItemBatch).FirstOrDefault(); //缓存加
                InWarehouse tempDel     = listDel.Where(i => i.ItemCode == item.ItemCode && i.ItemLocationId == item.ItemLocationId && i.ItemBatch == item.ItemBatch).FirstOrDefault(); //缓存删
                //报库存不足的几种情况
                if ((inWarehouse == null && tempAdd == null && tempDel == null) || (tempAdd == null && tempDel != null && inWarehouse != null) || (inWarehouse != null && tempAdd == null && tempDel == null && item.Count > inWarehouse.Count) || (tempAdd != null && tempDel == null && inWarehouse == null && item.Count > tempAdd.Count))
                {
                    res += "物料编号:" + item.ItemCode + ",物料名称:" + item.ItemName + ",批次:" + item.ItemBatch + ",库存不足,审核失败";
                }
                //增加到删除项缓存中
                else if (tempAdd == null && tempDel == null && inWarehouse != null && item.Count == inWarehouse.Count)
                {
                    listDel.Add(inWarehouse);
                    item.CurrentCount = 0;
                }
                //从库存中减
                else if (tempAdd == null && tempDel == null && inWarehouse != null && item.Count < inWarehouse.Count)
                {
                    inWarehouse.Count -= item.Count;
                    CurrentDBSession.InWarehouseDal.EditEntity(inWarehouse);
                    item.CurrentCount = inWarehouse.Count;
                }
                //从缓存加中删除
                else if (tempAdd != null && tempDel == null && inWarehouse == null && tempAdd.Count == item.Count)
                {
                    listAdd.Remove(tempAdd);
                    item.CurrentCount = 0;
                }
                //改缓存加中数据
                else if (tempAdd != null && tempDel == null && inWarehouse == null && tempAdd.Count > item.Count)
                {
                    tempAdd.Count    -= item.Count;
                    item.CurrentCount = tempAdd.Count;
                }
                //其他异常情况
                else
                {
                    return("出库记录有问题(" + item.ItemCode + "-" + item.ItemBatch + "-" + item.ItemLocationId + "),请联系管理员检查!");
                }
            }
            if (res != "")
            {
                return(res);
            }
            foreach (var item in listAdd)
            {
                CurrentDBSession.InWarehouseDal.AddEntity(item);
            }
            foreach (var item in listDel)
            {
                CurrentDBSession.InWarehouseDal.DeleteEntity(item);
            }
            bill.BillState     = 1;    //改成编辑状态
            bill.ExaminePerson = null; //清除审核人
            bill.ExamineDate   = null; //清除审核时间
            CurrentDal.EditEntity(bill);
            return(CurrentDBSession.SaveChanges() ? "操作成功" : "操作失败");
        }
Ejemplo n.º 27
0
        /// <summary>
        /// 审核表单
        /// </summary>
        /// <param name="DIYBillId"></param>
        /// <returns></returns>
        public string Examine(Guid DIYBillId, string UserName)
        {
            string        res   = "";
            DIYBill       bill  = CurrentDal.LoadEntities(a => a.Id == DIYBillId).FirstOrDefault();
            List <Record> list1 = CurrentDBSession.RecordDal.LoadEntities(b => b.MainTableId == bill.Id && b.InOrOut == 1).ToList();
            List <Record> list0 = CurrentDBSession.RecordDal.LoadEntities(b => b.MainTableId == bill.Id && b.InOrOut == 0).ToList();

            #region 检查是否有重复项
            //List<Record> list = new List<Record>();
            //list.AddRange(list1);
            //list.AddRange(list0);
            //var listBad = from a in list
            //              group a by new { a.ItemCode, a.ItemBatch, a.ItemLocationId } into g
            //              where g.Count() > 1
            //              select new { g.Key.ItemBatch, g.Key.ItemCode, g.Key.ItemLocationId, TotalCount = g.Count() };
            //if (listBad.Count() > 0)
            //{
            //    string res = "记录中发现重复项:";
            //    foreach (var item in listBad)
            //    {
            //        res += item.ItemCode + '-' + item.ItemBatch + '-' + item.ItemLocationId + ',';
            //    }
            //    return (res);
            //}
            #endregion
            List <InWarehouse> listAdd = new List <InWarehouse>(); //新增列表
            List <InWarehouse> listDel = new List <InWarehouse>(); //删除列表
            foreach (Record item in list1)
            {
                item.State       = 2;
                item.ExamineDate = DateTime.Now;
                InWarehouse inWarehouse = CurrentDBSession.InWarehouseDal.LoadEntities(i => i.ItemCode == item.ItemCode && i.ItemLocation == item.ItemLocation && i.ItemBatch == item.ItemBatch).FirstOrDefault();
                InWarehouse tempAdd     = listAdd.Where(i => i.ItemCode == item.ItemCode && i.ItemLocationId == item.ItemLocationId && i.ItemBatch == item.ItemBatch).FirstOrDefault(); //缓存加  此时缓存减里肯定没有东西
                if (inWarehouse == null && tempAdd == null)                                                                                                                             // 都没有
                {
                    inWarehouse = new InWarehouse()
                    {
                        Id                 = Guid.NewGuid(),
                        ItemBatch          = item.ItemBatch,
                        ItemCode           = item.ItemCode,
                        ItemLine           = item.ItemLine,
                        ItemLocation       = item.ItemLocation,
                        ItemLocationId     = item.ItemLocationId,
                        Warehouse          = item.Warehouse,
                        WarehouseId        = item.WarehouseId,
                        ItemName           = item.ItemName,
                        ItemSpecifications = item.ItemSpecifications,
                        ItemUnit           = item.ItemUnit,
                        Count              = item.Count,
                        Company            = bill.Company,
                        CompanyId          = bill.CompanyId,
                        Department         = bill.Department,
                        DepartmentId       = bill.DepartmentId
                    };
                    item.CurrentCount = item.Count;
                    listAdd.Add(inWarehouse);                    //添加到暂存区
                }
                else if (inWarehouse == null && tempAdd != null) //只有缓存加有
                {
                    tempAdd.Count    += item.Count;
                    item.CurrentCount = tempAdd.Count;
                }
                else if (inWarehouse != null && tempAdd == null) //只有库存有
                {
                    inWarehouse.Count += item.Count;
                    item.CurrentCount  = inWarehouse.Count;
                }
                else //有库存
                {
                    return("入库记录有问题(" + item.ItemCode + "-" + item.ItemBatch + "-" + item.ItemLocationId + "),请联系管理员检查!");
                }
            }
            foreach (Record item in list0)
            {
                item.State       = 2;
                item.ExamineDate = DateTime.Now;
                InWarehouse inWarehouse = CurrentDBSession.InWarehouseDal.LoadEntities(i => i.ItemCode == item.ItemCode && i.ItemLocation == item.ItemLocation && i.ItemBatch == item.ItemBatch).FirstOrDefault();
                InWarehouse tempAdd     = listAdd.Where(i => i.ItemCode == item.ItemCode && i.ItemLocationId == item.ItemLocationId && i.ItemBatch == item.ItemBatch).FirstOrDefault(); //缓存加
                InWarehouse tempDel     = listDel.Where(i => i.ItemCode == item.ItemCode && i.ItemLocationId == item.ItemLocationId && i.ItemBatch == item.ItemBatch).FirstOrDefault(); //缓存删
                //报库存不足的几种情况
                if ((inWarehouse == null && tempAdd == null && tempDel == null) || (tempAdd == null && tempDel != null && inWarehouse != null) || (inWarehouse != null && tempAdd == null && tempDel == null && item.Count > inWarehouse.Count) || (tempAdd != null && tempDel == null && inWarehouse == null && item.Count > tempAdd.Count))
                {
                    res += "物料编号:" + item.ItemCode + ",物料名称:" + item.ItemName + ",批次:" + item.ItemBatch + ",库存不足,审核失败";
                }
                //增加到删除项缓存中
                else if (tempAdd == null && tempDel == null && inWarehouse != null && item.Count == inWarehouse.Count)
                {
                    listDel.Add(inWarehouse);
                    item.CurrentCount = 0;
                }
                //从库存中减
                else if (tempAdd == null && tempDel == null && inWarehouse != null && item.Count < inWarehouse.Count)
                {
                    inWarehouse.Count -= item.Count;
                    CurrentDBSession.InWarehouseDal.EditEntity(inWarehouse);
                    item.CurrentCount = inWarehouse.Count;
                }
                //从缓存加中删除
                else if (tempAdd != null && tempDel == null && inWarehouse == null && tempAdd.Count == item.Count)
                {
                    listAdd.Remove(tempAdd);
                    item.CurrentCount = 0;
                }
                //改缓存加中数据
                else if (tempAdd != null && tempDel == null && inWarehouse == null && tempAdd.Count > item.Count)
                {
                    tempAdd.Count    -= item.Count;
                    item.CurrentCount = tempAdd.Count;
                }
                //其他异常情况
                else
                {
                    return("出库记录有问题(" + item.ItemCode + "-" + item.ItemBatch + "-" + item.ItemLocationId + "),请联系管理员检查!");
                }
            }
            if (res != "")
            {
                return(res);
            }
            foreach (var item in listAdd)
            {
                CurrentDBSession.InWarehouseDal.AddEntity(item);
            }
            foreach (var item in listDel)
            {
                CurrentDBSession.InWarehouseDal.DeleteEntity(item);
            }
            bill.BillState     = 2;        //改成已审核状态
            bill.ExaminePerson = UserName; //审核人
            bill.ExamineDate   = DateTime.Now;
            CurrentDal.EditEntity(bill);
            res = CurrentDBSession.SaveChanges() ? "审核成功!" : "审核失败!";
            return(res);
        }
Ejemplo n.º 28
0
        private void CreateLog()
        {
            IList <InWarehouseDetailDetail> iwddEnts = InWarehouseDetailDetail.FindAll();//入库

            foreach (InWarehouseDetailDetail iwddEnt in iwddEnts)
            {
                StockLog    slEnt = new StockLog();
                InWarehouse iwEnt = null;
                if (!string.IsNullOrEmpty(iwddEnt.InWarehouseDetailId))
                {
                    slEnt.InOrOutDetailId = iwddEnt.InWarehouseDetailId;
                    InWarehouseDetail iwdEnt = InWarehouseDetail.Find(iwddEnt.InWarehouseDetailId);
                    iwEnt = InWarehouse.Find(iwdEnt.InWarehouseId);
                }
                else
                {
                    slEnt.InOrOutDetailId = iwddEnt.OtherInWarehouseDetailId;
                    OtherInWarehouseDetail oiwdEnt = OtherInWarehouseDetail.Find(iwddEnt.OtherInWarehouseDetailId);
                    iwEnt = InWarehouse.Find(oiwdEnt.InWarehouseId);
                }
                slEnt.InOrOutBillNo = iwEnt.InWarehouseNo;
                slEnt.OperateType   = "产品入库";
                slEnt.WarehouseId   = iwEnt.WarehouseId;
                slEnt.WarehouseName = iwEnt.WarehouseName;
                //IList<StockInfo> siEnts = StockInfo.FindAllByProperties(StockInfo.Prop_ProductId, iwddEnt.ProductId, StockInfo.Prop_WarehouseId, iwEnt.WarehouseId);
                //if (siEnts.Count > 0)
                //{
                //    slEnt.StockQuantity = siEnts[0].StockQuantity;
                //}
                slEnt.Quantity  = iwddEnt.Quantity;
                slEnt.ProductId = iwddEnt.ProductId;
                Product pEnt = Product.TryFind(iwddEnt.ProductId);
                if (pEnt != null)
                {
                    slEnt.ProductName = pEnt.Name;
                    slEnt.ProductCode = pEnt.Code;
                    slEnt.ProductIsbn = pEnt.Isbn;
                    slEnt.ProductPcn  = pEnt.Pcn;
                    slEnt.CreateId    = iwddEnt.CreateId;
                    slEnt.CreateName  = iwddEnt.CreateName;
                    slEnt.CreateTime  = iwddEnt.CreateTime;
                    slEnt.DoCreate();
                }
            }
            //生成出库日志
            IList <DelieryOrderPart> dopEnts = DelieryOrderPart.FindAllByProperty(DelieryOrderPart.Prop_State, "已出库");

            foreach (DelieryOrderPart dopEnt in dopEnts)
            {
                StockLog slEnt = new StockLog();
                slEnt.InOrOutDetailId = dopEnt.Id;
                DeliveryOrder doEnt = DeliveryOrder.Find(dopEnt.DId);
                slEnt.InOrOutBillNo = doEnt.Number;
                slEnt.OperateType   = "产品出库";
                slEnt.WarehouseId   = doEnt.WarehouseId;
                slEnt.WarehouseName = doEnt.WarehouseName;
                //IList<StockInfo> siEnts = StockInfo.FindAllByProperties(StockInfo.Prop_ProductId, iwddEnt.ProductId, StockInfo.Prop_WarehouseId, iwEnt.WarehouseId);
                //if (siEnts.Count > 0)
                //{
                //    slEnt.StockQuantity = siEnts[0].StockQuantity;
                //}
                slEnt.Quantity = dopEnt.OutCount;
                if (!string.IsNullOrEmpty(dopEnt.ProductId))
                {
                    slEnt.ProductId = dopEnt.ProductId;
                    Product pEnt = Product.TryFind(dopEnt.ProductId);
                    if (pEnt != null)
                    {
                        slEnt.ProductName = pEnt.Name;
                        slEnt.ProductCode = pEnt.Code;
                        slEnt.ProductIsbn = pEnt.Isbn;
                        slEnt.ProductPcn  = pEnt.Pcn;
                        slEnt.CreateId    = dopEnt.CreateId;
                        slEnt.CreateName  = dopEnt.CreateName;
                        slEnt.CreateTime  = dopEnt.CreateTime;
                        slEnt.DoCreate();
                    }
                }
            }
            //盘点操作库存日志
            string sql = "select * from SHHG_AimExamine..StockCheckDetail where StockCheckResult!='正常' and StockCheckState='盘点结束'";
            IList <EasyDictionary> scdDics = DataHelper.QueryDictList(sql);

            foreach (EasyDictionary scdDic in scdDics)
            {
                StockLog slEnt = new StockLog();
                slEnt.InOrOutDetailId = scdDic.Get <string>("Id");
                StockCheck scEnt = StockCheck.Find(scdDic.Get <string>("StockCheckId"));
                slEnt.InOrOutBillNo = scEnt.StockCheckNo;
                slEnt.OperateType   = "库存盘点";
                slEnt.WarehouseId   = scEnt.WarehouseId;
                slEnt.WarehouseName = scEnt.WarehouseName;
                slEnt.StockQuantity = scdDic.Get <Int32>("StockQuantity");
                slEnt.Quantity      = scdDic.Get <Int32>("StockCheckQuantity") - scdDic.Get <Int32>("StockQuantity");
                slEnt.ProductId     = scdDic.Get <string>("ProductId");
                Product pEnt = Product.TryFind(slEnt.ProductId);
                if (pEnt != null)
                {
                    slEnt.ProductName = pEnt.Name;
                    slEnt.ProductCode = pEnt.Code;
                    slEnt.ProductIsbn = pEnt.Isbn;
                    slEnt.ProductPcn  = pEnt.Pcn;
                    slEnt.CreateId    = scEnt.CreateId;
                    slEnt.CreateName  = scEnt.CreateName;
                    slEnt.CreateTime  = scEnt.CreateTime;
                    slEnt.DoCreate();
                }
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 审核表单
        /// </summary>
        /// <param name="DIYBillId"></param>
        /// <returns></returns>
        public string Examine(Guid DIYBillId, string UserName)
        {
            string        result = "";
            DIYBill       bill   = CurrentDal.LoadEntities(a => a.Id == DIYBillId).FirstOrDefault();
            List <Record> list1  = CurrentDBSession.RecordDal.LoadEntities(b => b.MainTableId == bill.Id && b.InOrOut == 1).ToList();
            List <Record> list0  = CurrentDBSession.RecordDal.LoadEntities(b => b.MainTableId == bill.Id && b.InOrOut == 0).ToList();

            foreach (Record item in list1)
            {
                item.State       = 2;
                item.ExamineDate = DateTime.Now;
                InWarehouse inWarehouse = CurrentDBSession.InWarehouseDal.LoadEntities(i => i.ItemCode == item.ItemCode && i.ItemLocation == item.ItemLocation && i.ItemBatch == item.ItemBatch).FirstOrDefault();
                if (inWarehouse == null)//如果没有库存  新建一条记录
                {
                    inWarehouse = new InWarehouse()
                    {
                        Id                 = Guid.NewGuid(),
                        ItemBatch          = item.ItemBatch,
                        ItemCode           = item.ItemCode,
                        ItemLine           = item.ItemLine,
                        ItemLocation       = item.ItemLocation,
                        ItemName           = item.ItemName,
                        ItemSpecifications = item.ItemSpecifications,
                        ItemUnit           = item.ItemUnit,
                        Count              = item.Count,
                        Company            = bill.Company,
                        CompanyId          = bill.CompanyId,
                        Department         = bill.Department,
                        DepartmentId       = bill.DepartmentId,
                        Warehouse          = item.Warehouse,
                        WarehouseId        = item.WarehouseId,
                        ItemLocationId     = item.ItemLocationId
                    };
                    CurrentDBSession.InWarehouseDal.AddEntity(inWarehouse);
                }
                else//库存大于记录  相减
                {
                    inWarehouse.Count = inWarehouse.Count + item.Count;
                    CurrentDBSession.InWarehouseDal.EditEntity(inWarehouse);
                }
            }
            foreach (Record item in list0)
            {
                item.State       = 2;
                item.ExamineDate = DateTime.Now;
                InWarehouse inWarehouse = CurrentDBSession.InWarehouseDal.LoadEntities(i => i.ItemCode == item.ItemCode && i.ItemLocation == item.ItemLocation && i.ItemBatch == item.ItemBatch).FirstOrDefault();
                if (inWarehouse == null || inWarehouse.Count < item.Count)//如果没有库存  新建一条记录
                {
                    result = "物料编号:" + item.ItemCode + "物料名称:" + item.ItemName + "库存不足,弃审失败";
                    return(result);
                }
                else if (inWarehouse.Count == item.Count) // 库存正好相等  删除这条记录
                {
                    CurrentDBSession.InWarehouseDal.DeleteEntity(inWarehouse);
                }
                else if (inWarehouse.Count > item.Count)//库存大于记录  相减
                {
                    inWarehouse.Count = inWarehouse.Count - item.Count;
                    CurrentDBSession.InWarehouseDal.EditEntity(inWarehouse);
                }
            }
            bill.BillState     = 2;        //改成已审核状态
            bill.ExaminePerson = UserName; //审核人
            bill.ExamineDate   = DateTime.Now;
            CurrentDal.EditEntity(bill);
            result = CurrentDBSession.SaveChanges() ? "审核成功!" : "审核失败!";
            return(result);
        }
Ejemplo n.º 30
0
        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();
                }
            }
        }