Exemplo n.º 1
0
        public ActionResult printwin(string title, string key, string no)
        {
            dynamic        data      = new System.Dynamic.ExpandoObject();
            PrintHeadModel pm        = new PrintHeadModel();
            List <string>  datas     = new List <string>();
            bool           showPrice = false;

            #region 分支
            switch (key)
            {
            case "require":
                if (Masterpage.CheckRight("require_print"))
                {
                    pm = purchaseService.RequireList(no).Where(p => p.requireNo == no).Select(x => new PrintHeadModel {
                        checkStaff = x.checkStaff, date = x.createDate, depName = "部门:" + x.depName, makeStaff = x.staffName, No = x.requireNo, showdeport = false
                    }).FirstOrDefault();
                    datas = purchaseService.RequireDetailList(no).Select(x => x.materialNo + "<br>" + x.materialName + "," + x.materialModel + "," + x.orderAmount.ToString("N") + "," + x.materialUnit + "," + (x.needdate < DateTime.Now.AddYears(5) ? x.needdate.ToString("yyyy-MM-dd") : "") + "," + x.remark).ToList();
                }
                break;

            case "delegate":
                if (Masterpage.CheckRight("delegate_print"))
                {
                    var one = ServiceDB.Instance.QueryOneModel <V_DelegateOrderModel>(" select * from V_DelegateOrderModel where delegateNo='" + no + "'");
                    pm = new PrintHeadModel {
                        checkStaff = one.checkStaff, date = one.createDate, depName = "订单:" + one.bomOrderNo, makeStaff = one.staffName, No = one.delegateNo, showdeport = true, deportStaff = "产品:" + one.productNo + " " + one.productName + " " + one.productModel
                    };
                    datas = ServiceDB.Instance.QueryModelList <V_DelegateOrderDetail>(" select * from V_DelegateOrderDetail where delegateNo='" + no + "'").ToList().Select(x => x.materialNo + "," + x.materialName + "," + x.materialModel + "," + x.detailAmount.Value.ToString("N") + "," + x.unit + "," + x.detailRemark).ToList();
                }
                break;

            case "produce":
                if (Masterpage.CheckRight("produce_print"))
                {
                    var one = ServiceDB.Instance.QueryOneModel <V_ProductionModel>(" select * from V_ProductionModel where produceNo='" + no + "'");
                    pm = new PrintHeadModel {
                        checkStaff = one.checkStaff, date = one.createDate.Value, depName = "订单:" + one.bomOrderNo, makeStaff = one.staffName, No = one.produceNo, showdeport = true, deportStaff = "产品:" + one.productNo + " " + one.productName + " " + one.productModel
                    };
                    datas = ServiceDB.Instance.QueryModelList <V_ProductionDetailModel>(" select * from V_ProductionDetailModel where produceNo='" + no + "'").ToList().Select(x => x.materialNo + "," + x.materialName + "," + x.materialModel + "," + x.amount.Value.ToString("N") + "," + x.outAmount.Value.ToString("N") + "," + x.unit + "," + x.remark).ToList();
                }
                break;

            case "producepull":
                if (Masterpage.CheckRight("producepull_print"))
                {
                    var one = ServiceDB.Instance.QueryOneModel <V_ProductPullModel>(" select * from V_ProductPullModel where pullNo='" + no + "'");
                    pm = new PrintHeadModel {
                        checkStaff = one.checkStaff, date = one.createDate, depName = "工单:" + one.produceNo, makeStaff = one.staffName, No = one.pullNo, showdeport = true, deportStaff = "产品:" + one.materialNo + " " + one.materialName + " " + one.materialModel
                    };
                    datas = ServiceDB.Instance.QueryModelList <V_ProductPullDetail>(" select * from V_ProductPullDetail where pullNo='" + no + "'").ToList().Select(x => x.materialNo + "," + x.materialName + "," + x.materialModel + "," + x.theoryAmount.ToString("N") + "," + x.realAmount.ToString("N") + "," + x.unit + "," + x.remark).ToList();
                }
                break;

            case "producegive":
                if (Masterpage.CheckRight("producegive_print"))
                {
                    var one = ServiceDB.Instance.QueryOneModel <V_ProductGiveModel>(" select * from V_ProductGiveModel where giveNo='" + no + "'");
                    pm = new PrintHeadModel {
                        checkStaff = one.checkStaff, date = one.createDate, depName = "工单:" + one.pullNo, makeStaff = one.staffName, No = one.giveNo, showdeport = true, deportStaff = "产品:" + one.materialNo + " " + one.materialName + " " + one.materialModel + " 交货数:" + one.giveAmount
                    };
                    datas = ServiceDB.Instance.QueryModelList <V_ProductGiveDetail>(" select * from V_ProductGiveDetail where giveNo='" + no + "'").ToList().Select(x => x.materialNo + "," + x.materialName + "," + x.materialModel + "," + x.realAmount.ToString("N") + "," + x.giveAmount.ToString("N") + "," + x.unit + "," + x.remark).ToList();
                }
                break;

            case "order":
                if (Masterpage.CheckRight("order_print"))
                {
                    pm = purchaseService.PurchaseList(no).Select(x => new PrintHeadModel {
                        checkStaff = x.checkStaff, date = x.createDate, depName = "供应商:" + x.suppliername, makeStaff = x.staffName, No = x.purchaseNo, showdeport = false
                    }).FirstOrDefault();
                    if (Masterpage.CurrUser.showPrice)
                    {
                        datas = purchaseService.PurchaseDetailList(no).Select(x => x.materialNo + "<br>" + x.materialName + "," + x.materialModel + "," + x.poAmount + "," + x.materialUnit + "," + x.poPrice + "," + (x.poAmount * x.poPrice) + "," + (x.sendDate < DateTime.Now.AddYears(5) ? x.sendDate.ToString("yyyy-MM-dd") : "") + "," + x.remark).ToList();
                    }
                    else
                    {
                        datas = purchaseService.PurchaseDetailList(no).Select(x => x.materialNo + "<br>" + x.materialName + "," + x.materialModel + "," + x.poAmount + "," + x.materialUnit + "," + (x.sendDate < DateTime.Now.AddYears(5) ? x.sendDate.ToString("yyyy-MM-dd") : "") + "," + x.remark).ToList();
                    }
                }
                break;

            case "stockin":
                if (Masterpage.CheckRight("stockin_print"))
                {
                    pm = stockinService.StockInList(no).Select(x => new PrintHeadModel {
                        checkStaff = x.checkStaff, date = x.createDate, depName = "部门:" + x.depName, makeStaff = x.staffName, No = x.stockNo, showdeport = true, deportStaff = "仓库:" + x.deportStaff
                    }).FirstOrDefault();
                    datas = stockinService.StockInDetailList(no).ToList().Select(x => x.materialNo + "<br>" + x.materialName + "," + x.materialModel + "," + x.amount + "," + x.materialUnit + "," + x.depotName + "," + x.purchaseNo + "," + x.remark).ToList();
                }
                break;

            case "stockout":
                if (Masterpage.CheckRight("stockout_print"))
                {
                    pm = stockoutService.StockOutList(no).Where(p => p.datatype != 1).Select(x => new PrintHeadModel {
                        checkStaff = x.checkStaff, date = x.createDate, depName = "部门:" + x.depName, makeStaff = x.staffName, No = x.stockNo, showdeport = true, deportStaff = "仓库:" + x.deportStaff
                    }).FirstOrDefault();
                    datas = stockoutService.StockOutDetailList(no).ToList().Select(x => x.materialNo + "<br>" + x.materialName + "," + x.materialModel + "," + x.amount + "," + x.materialUnit + "," + x.depotName + "," + x.remark).ToList();
                }
                break;

            case "change":
                if (Masterpage.CheckRight("stockout_old2new_print"))
                {
                    pm = stockoutService.ChangeOtNList(no).Select(x => new PrintHeadModel {
                        checkStaff = x.checkStaff, date = x.createDate, depName = "部门:" + x.depName, makeStaff = x.staffName, No = x.stockNo, showdeport = true, deportStaff = "仓库:" + x.deportStaff
                    }).FirstOrDefault();
                    List <string> l1 = new List <string>(); List <string> l2 = new List <string>();
                    l1 = stockoutService.ChangeOtNInList(no).ToList().Select(x => x.materialNo + "<br>" + x.materialName + "," + x.materialModel + "," + x.amount + "," + x.materialUnit + ",入库," + x.depotName + "," + x.remark).ToList();
                    l2 = stockoutService.ChangeOtNOutList(no).ToList().Select(x => x.materialNo + "<br>" + x.materialName + "," + x.materialModel + "," + x.amount + "," + x.materialUnit + ",出库," + x.depotName + "," + x.remark).ToList();
                    datas.AddRange(l1);
                    datas.AddRange(l2);
                }
                break;

            case "orderreturn":
                if (Masterpage.CheckRight("stockin_return_print"))
                {
                    pm = stockinService.ReturnModelList(no).Select(x => new PrintHeadModel {
                        checkStaff = x.checkStaff, date = x.createDate, depName = "供应商:" + x.supplierName, makeStaff = x.staffName, No = x.returnNo, showdeport = true, deportStaff = "供应商:"
                    }).FirstOrDefault();
                    datas = stockinService.ReturnDetailList(no).ToList().Select(x => x.materialNo + "<br>" + x.materialName + "," + x.materialModel + "," + x.returnAmount + "," + x.materialUnit + "," + x.purchaseNo + "," + x.depotName + "," + x.remark).ToList();
                }
                break;

            case "stockreturn":
                if (Masterpage.CheckRight("stockout_return_print"))
                {
                    pm = stockoutService.ReturnModelList(no).Select(x => new PrintHeadModel {
                        checkStaff = x.checkStaff, date = x.createDate, depName = "部门:" + x.depName, makeStaff = x.staffName, No = x.returnNo, showdeport = true, deportStaff = "仓库:" + x.deportStaff
                    }).FirstOrDefault();
                    datas = stockoutService.StockReturnDetailList(no).ToList().Select(x => x.materialNo + "<br>" + x.materialName + "," + x.materialModel + "," + x.outAmoutn + "," + x.returnAmount + "," + x.materialUnit + "," + x.stockoutNo + "," + x.todepotName + "," + x.remark).ToList();
                }
                break;

            case "bomorder":
                if (Masterpage.CheckRight("bomorder_print"))
                {
                    showPrice = Masterpage.CheckRight("ordermoney_print");
                    pm        = bomService.BomOrderList(no).Select(x => new PrintHeadModel {
                        checkStaff = x.checkStaff, date = x.createDate, depName = "部门:" + x.depName, makeStaff = x.staffName, No = x.bomOrderNo, showdeport = true, deportStaff = "仓库:" + x.deportStaff
                    }).FirstOrDefault();
                    if (showPrice)
                    {
                        datas = bomService.BomOrderDetailList(no).ToList().Select(x => x.materialNo + "," + x.materialName + "," + x.materialModel + "," + x.Amount + "," + x.Price.ToString("N").Replace(",", "") + "," + (x.Amount * x.Price).ToString("N").Replace(",", "") + "," + (x.sendDate.HasValue ? x.sendDate.Value.ToString("yyyy-MM-dd") : "") + "," + x.remark).ToList();               // + x.Price.ToString("N").Replace(",", "") + "," + (x.Amount * x.Price).ToString("N").Replace(",", "") + ","
                    }
                    else
                    {
                        datas = bomService.BomOrderDetailList(no).ToList().Select(x => x.materialNo + "," + x.materialName + "," + x.materialModel + "," + x.Amount + "," + (x.sendDate.HasValue ? x.sendDate.Value.ToString("yyyy-MM-dd") : "") + "," + x.remark).ToList();     // + x.Price.ToString("N").Replace(",", "") + "," + (x.Amount * x.Price).ToString("N").Replace(",", "") + ","
                    }
                }
                break;

            case "bomorderdetail":
                if (Masterpage.CheckRight("bomorder_print"))
                {
                    var sn     = Convert.ToInt32(no);
                    var detail = bomService.BomOrderDetailOne(sn);
                    pm = bomService.BomOrderList(detail.bomOrderNo).Select(x => new PrintHeadModel {
                        checkStaff = x.checkStaff, date = x.createDate, depName = "部门:" + x.depName, makeStaff = x.staffName, No = x.bomOrderNo, showdeport = true, deportStaff = "仓库:" + x.deportStaff
                    }).FirstOrDefault();
                    datas = bomService.GetBomOrderBomDetailList(sn).ToList().Select(x => x.materialNo + "<br>" + x.materialName + "," + x.materialModel + "," + x.materialCate + "," + x.bomAmount + "," + (x.sendDate.HasValue ? x.sendDate.Value.ToString("yyyy-MM-dd") : "") + "," + x.remark).ToList();
                }
                break;

            case "bill":
                if (Masterpage.CheckRight("bill_print"))
                {
                    var model = ServiceDB.Instance.QueryOneModel <V_BillCost>(" select * from V_BillCost where billNo='" + no + "'");
                    var list  = ServiceDB.Instance.QueryModelList <V_BillCostDetail>(" select * from V_BillCostDetail where billNo='" + no + "'").ToList();
                    pm = new PrintHeadModel {
                        checkStaff = model.checkName, makeStaff = model.makeName, bossStaff = model.bossName, cfoStaff = model.cfoName, date = model.createDate, depName = "部门:" + model.depName, No = model.billNo, showdeport = false
                    };
                    datas = list.Select(x => x.billTitle + "," + x.cost + "," + x.billDate.ToString("yyyy-MM-dd") + "," + x.remark).ToList();
                }
                break;

            case "purchase2":
                if (Masterpage.CheckRight("purchase2_print"))
                {
                    var model = ServiceDB.Instance.QueryOneModel <V_BillCost>(" select * from V_BillCost where billNo='" + no + "'");
                    var list  = ServiceDB.Instance.QueryModelList <V_BillCostDetail>(" select * from V_BillCostDetail where billNo='" + no + "'").ToList();
                    pm = new PrintHeadModel {
                        checkStaff = model.checkName, makeStaff = model.makeName, bossStaff = model.bossName, cfoStaff = model.cfoName, date = model.createDate, depName = "部门:" + model.depName, No = model.billNo, showdeport = false
                    };
                    datas = list.Select(x => x.billTitle + "," + x.amount + "," + x.cost + "," + x.cost * x.amount + "," + x.billDate.ToString("yyyy-MM-dd") + "," + x.remark).ToList();
                }
                break;

            case "delegateback":
                if (Masterpage.CheckRight("delegateback_print"))
                {
                    var model = ServiceDB.Instance.QueryOneModel <V_DelegateBackModel>(" select * from V_DelegateBackModel where backNo='" + no + "'");
                    var list  = ServiceDB.Instance.QueryModelList <V_DelegateBackDetail>(" select * from V_DelegateBackDetail where backNo='" + no + "'").ToList();
                    pm = new PrintHeadModel {
                        checkStaff = model.checkStaff, date = model.backDate, depName = "供应商:" + model.supplierName, makeStaff = model.staffName, No = model.backNo, showdeport = true, deportStaff = "仓库:" + model.deportStaff, bossStaff = model.supplierName
                    };
                    datas = list.Select(x => (x.isProduct ? "货品" : "原料") + "," + x.materialNo + "," + x.materialName + "," + x.materialModel + "," + x.backAmount + "," + x.fromDelegateNo + "," + x.remark).ToList();
                }
                break;

            case "stocksemi":
                if (Masterpage.CheckRight("stockin_semi_print"))
                {
                    showPrice = Masterpage.CheckRight("semishowmoney_print");
                    var model = ServiceDB.Instance.QueryOneModel <ProductSemi>(" select * from ProductSemi where semiNo='" + no + "'");
                    var list  = ServiceDB.Instance.QueryModelList <ProductSemi>(" select * from ProductSemi where semiNo='" + no + "'").ToList();
                    var dep   = ServiceDB.Instance.QueryOneModel <Department>("select d.* from Department as d inner join Employee as e on d.depId=e.depId where e.staffId=" + model.staffId);
                    pm = new PrintHeadModel {
                        checkStaff = model.checkStaff, makeStaff = model.staffName, bossStaff = "", cfoStaff = "", date = model.createDate, depName = dep != null ? "部门:" + dep.depName : "", No = model.semiNo, showdeport = false
                    };
                    datas = list.Select(x => x.proName + "," + x.proModel + "," + x.amount + "," + (showPrice?x.price.ToString():"") + "," + (showPrice?Math.Round((decimal)x.amount * x.price, 4).ToString():"") + "," + x.createDate.ToString("yyyy-MM-dd") + "," + x.remark).ToList();
                }
                break;

            case "delegatesend":
                if (Masterpage.CheckRight("delegate_send_print"))
                {
                    showPrice = Masterpage.CheckRight("delegatesendshowmoney_print");
                    var model = ServiceDB.Instance.QueryOneModel <V_DelegateSendModel>(" select * from V_DelegateSendModel where sendNo='" + no + "'");
                    var list  = ServiceDB.Instance.QueryModelList <V_DelegateSendDetailModel>(" select * from V_DelegateSendDetailModel where sendNo='" + no + "'").ToList();
                    //pm = new PrintHeadModel { checkStaff = model.checkStaff, makeStaff = model.staffName, bossStaff = "", cfoStaff = "", date = model.createDate, depName = model.depName, No = model.sendNo, showdeport = true };
                    //datas = list.Select(x => x.materialNo + "," + x.materialName + "," + x.materialModel + "," + x.realAmount + "," + (showPrice ? x.price.ToString() : "") + "," + (showPrice ? Math.Round((decimal)x.productAmount * x.price, 4).ToString() : "") + "," + x.remark).ToList();
                    var delegatenos = ServiceDB.Instance.QueryModelList <string>("select distinct delegateNo from DelegateSendDetail where sendNo='" + no + "' ").ToList();

                    data.showPrice   = showPrice;
                    data.delegatenos = delegatenos;
                    data.title       = title;
                    data.pm          = model;
                    data.list        = list;
                    return(View("~/Views/main/delegatesendprint.cshtml", data));
                }
                break;

            default:
                break;
            }
            #endregion

            data.showPrice = showPrice;
            data.title     = title;
            data.key       = key;
            data.pm        = pm;
            data.datas     = datas;

            return(View(data));
        }