CollageController

目录

1、 CollageController

1.1、 保存领料主页面

1.1.1、 //审核人

1.1.2、 //审核时间

1.1.3、 //需要删除的ID集合

1.1.4、 //库存表

1.1.5、 //查询原来明细信息

1.1.6、 //修改配件表数量

1.1.7、 //修改配件表数量

1.1.8、 //查询原来明细信息

1.1.9、 查询领料单据信息

1.1.10、 //结算单号

1.1.11、 //领料员

1.1.12、 //领料时间

  1. CollageController 

using QXQPS.Models;

using QXQPS.Vo;

using System;

using System.Collections;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.Mvc;

namespace QXQPS.Areas.MechanicsManagment.Controllers

{

    public class CollageController : Controller

    {

        // GET: MechanicsManagment/Collage

    1. 保存领料主页面

        public ActionResult ListCollage(List<PW_Collage> listCollage, List<SYS_CollageDetai> listCollageDetai)//保存领料主页面

        {

            ArrayList list = new ArrayList();

            try

            {

                try

                {

                    var Auditor = Session["UserName"].ToString().Trim();

      1. //审核人

                    var Operator = Session["UserName"].ToString().Trim();//操作人

                    var CollageStates = "已领料".Trim();

                    var AuditDate = DateTime.Now;

      1. //审核时间

                    list.Add(Auditor);

                    list.Add(Operator);

                    list.Add(AuditDate.ToString());

                    list.Add(CollageStates);

                    listCollage[0].Auditor = Auditor;

                    listCollage[0].Operator = Operator;

                    listCollage[0].AuditDate = AuditDate;

                    listCollage[0].ToAudit = true;

                }

                catch (Exception)

                {

                    return Redirect("/Home/Login");

                }

                var CollageState = "已领料".Trim();

                if (listCollage[0].CollageID == 0)

                {

                    myModels.PW_Collage.Add(listCollage[0]);

                }

                else {

                    myModels.Entry(listCollage[0]).State = System.Data.Entity.EntityState.Modified;

                }

                if (myModels.SaveChanges() > 0)

                {

                    var CollageID = listCollage[0].CollageID;

                    if (listCollageDetai!=null)

                    {

                        List<int> oldID = new List<int>();//原来ID

                        List<int> newID = new List<int>();//新ID

                        List<int> listdelectID = new List<int>();

      1. //需要删除的ID集合

                        var lists = myModels.SYS_CollageDetai.Where(m => m.CollageID == CollageID).Select(m => new { m.CollageDetaiID }).ToList();

                        foreach (var item in lists)

                        {

                            oldID.Add(item.CollageDetaiID);

                        }

                        for (int i = 0; i < listCollageDetai.Count; i++)

                        {

                            listCollageDetai[i].CollageID = CollageID;

                            var CollageDetaiID = listCollageDetai[i].CollageDetaiID;

                            var FittingsCode = listCollageDetai[i].FittingsCode.Trim();//配件编码

                            var VehicleType = listCollageDetai[i].VehicleType.Trim();//车型

                            var InvenQuan = listCollageDetai[i].Quantity;//数量

                            var WarehouseID = listCollageDetai[i].WarehouseID;//仓库ID

                            var listInventory = myModels.SYS_Inventory.Where(m => m.FittingsCode == FittingsCode&&m.WarehouseID== WarehouseID).SingleOrDefault();

      1. //库存表

                            var listInventorys = myModels.SYS_Inventory.Where(m => m.FittingsCode == FittingsCode).ToList();//库存表

                            var listFittingsInfos = (from tbFittingsInfo in myModels.SYS_FittingsInfo where tbFittingsInfo.FittingsCode == FittingsCode select tbFittingsInfo).SingleOrDefault();

                            var listFittingsInfo = (from tbFittingsInfo in myModels.SYS_FittingsInfo

                                                    join tbFittingsType in myModels.SYS_FittingsType on tbFittingsInfo.FittingsTypeID equals tbFittingsType.FittingsTypeID

                                                    join tbVehicleType in myModels.SYS_VehicleType on tbFittingsInfo.VehicleTypeID equals tbVehicleType.VehicleTypeID

                                                    join tbSystemUnit in myModels.SYS_SystemUnit on tbFittingsInfo.SystemUnitID equals tbSystemUnit.SystemUnitID

                                                    where tbFittingsInfo.FittingsCode== FittingsCode

                                                    select new FittingsInfoVo

                                                    {

                                                        FittingsCode=tbFittingsInfo.FittingsCode.Trim(),

                                                        FittingsName=tbFittingsInfo.FittingsName.Trim(),

                                                        Intake=tbFittingsInfo.Intake,

                                                        SalesPrice=tbFittingsInfo.SalesPrice,

                                                        WholesalePrice =tbFittingsInfo.WholesalePrice,

                                                        FittingsTypeName=tbFittingsType.FittingsTypeName.Trim(),

                                                        VehicleType=tbVehicleType.VehicleType.Trim(),

                                                        SystemUnit=tbSystemUnit.SystemUnit.Trim(),

                                                    }).SingleOrDefault();

                            if (CollageDetaiID == 0)

                            {

                                myModels.SYS_CollageDetai.Add(listCollageDetai[i]);//新增

                            }

                            else {

                                newID.Add(listCollageDetai[i].CollageDetaiID);

                                myModels.Entry(listCollageDetai[i]).State = System.Data.Entity.EntityState.Modified;//修改

                            }

                            if (listFittingsInfos != null)

                            {

                                var lis = myModels.SYS_CollageDetai.Where(m => m.CollageDetaiID == CollageDetaiID).Select(m => new { m.FittingsCode, m.WarehouseID, m.Quantity }).SingleOrDefault();

      1. //查询原来明细信息

                                if (lis != null)

                                {

                                    var Quantity = lis.Quantity;

                                    listFittingsInfos.InvenQuan = listFittingsInfos.InvenQuan + (Quantity - InvenQuan);

      1. //修改配件表数量

                                }

                                else

                                {

                                    var liInvenQuan = listFittingsInfos.InvenQuan!=null? listFittingsInfos.InvenQuan:0;

                                    listFittingsInfos.InvenQuan = liInvenQuan - InvenQuan;

      1. //修改配件表数量

                                }

                                myModels.Entry(listFittingsInfos).State = System.Data.Entity.EntityState.Modified;

                            }

                            if (listInventory != null)//修改库存信息

                            {

                                if (CollageDetaiID != 0)

                                {

                                    var lis = myModels.SYS_CollageDetai.Where(m => m.CollageDetaiID == CollageDetaiID).Select(m => new { m.FittingsCode, m.WarehouseID , m.Quantity }).SingleOrDefault();

      1. //查询原来明细信息

                                    if (lis.WarehouseID != WarehouseID)

                                    {

                                        var liWarehouseID = lis.WarehouseID;

                                        var liFittingsCode = lis.FittingsCode;

                                        var oldInvenQuan = myModels.SYS_Inventory.Where(m => m.WarehouseID == liWarehouseID && m.FittingsCode == liFittingsCode).SingleOrDefault();//旧库存表

                                        oldInvenQuan.InvenQuan = oldInvenQuan.InvenQuan + InvenQuan;

                                        myModels.Entry(oldInvenQuan).State = System.Data.Entity.EntityState.Modified;//修改

                                        listInventory.InvenQuan = listInventory.InvenQuan - InvenQuan;

                                    }

                                    else

                                    {

                                        var Quantity = lis.Quantity;

                                        listInventory.InvenQuan = listInventory.InvenQuan + (Quantity - InvenQuan);

                                    }

                                }

                                else

                                {

                                   listInventory.InvenQuan = listInventory.InvenQuan  - InvenQuan;

                                }

                                myModels.Entry(listInventory).State = System.Data.Entity.EntityState.Modified;//修改

                            }

                            else//新增库存信息

                            {

                                SYS_Inventory sys_Inventory = new SYS_Inventory();

                                sys_Inventory.Position = listCollageDetai[i].Position;

                                sys_Inventory.WarehouseID = listCollageDetai[i].WarehouseID;

                                if (listFittingsInfo != null)

                                {

                                    sys_Inventory.FittingsType = listFittingsInfo.FittingsTypeName;

                                    sys_Inventory.FittingsCode = listFittingsInfo.FittingsCode;

                                    sys_Inventory.FittingsName = listFittingsInfo.FittingsName;

                                    sys_Inventory.VehicleType = listFittingsInfo.VehicleType;

                                    sys_Inventory.SystemUnit = listFittingsInfo.SystemUnit;

                                    sys_Inventory.InvenQuan = -InvenQuan;

                                    sys_Inventory.NewIntake = listFittingsInfo.Intake;

                                    sys_Inventory.SalePrice = listFittingsInfo.SalesPrice;

                                    sys_Inventory.WholePrice = listFittingsInfo.WholesalePrice;

                                    myModels.SYS_Inventory.Add(sys_Inventory);//新增

                                }

                                else

                                {

                                    sys_Inventory.NewIntake = 0;

                                    sys_Inventory.WholePrice = 0;

                                    sys_Inventory.FittingsCode = listCollageDetai[i].FittingsCode;

                                    sys_Inventory.FittingsName = listCollageDetai[i].FittingsName;

                                    sys_Inventory.VehicleType = listCollageDetai[i].VehicleType;

                                    sys_Inventory.SystemUnit = listCollageDetai[i].SystemUnit;

                                    sys_Inventory.InvenQuan = -listCollageDetai[i].Quantity;

                                    sys_Inventory.SalePrice = listCollageDetai[i].UnitPrice;

                                    sys_Inventory.Position = listCollageDetai[i].Position;

                                    myModels.SYS_Inventory.Add(sys_Inventory);//新增

                                }

                            }

                            myModels.SaveChanges();

                        }

                        var ReceptionID = listCollage[0].ReceptionID;

                        var listReception = (from tbReception in myModels.PW_Reception where tbReception.ReceptionID == ReceptionID select tbReception).Single();

                        listReception.CollageState = CollageState;

                        myModels.Entry(listReception).State = System.Data.Entity.EntityState.Modified;

                        myModels.SaveChanges();

                        listdelectID = oldID.Except(newID).ToList();//从某集合中删除其与另一个集合中相同的项;其实这个说简单点就是某集合中独有的元素(差集)

                        foreach (var item in listdelectID)

                        {

                            var listQuantity = myModels.SYS_CollageDetai.Where(m => m.CollageDetaiID == item).Select(m => new { m.Quantity, m.FittingsCode ,m.WarehouseID }).SingleOrDefault();

                            var FittingsCode = listQuantity.FittingsCode;

                            var WarehouseID = listQuantity.WarehouseID;

                            var Quantity = listQuantity.Quantity;

                            var listInventory = myModels.SYS_Inventory.Where(m => m.FittingsCode == FittingsCode && m.WarehouseID == WarehouseID).SingleOrDefault();//库存表

                            var listFittingsInfos = (from tbFittingsInfo in myModels.SYS_FittingsInfo where tbFittingsInfo.FittingsCode == FittingsCode select tbFittingsInfo).SingleOrDefault();//配件表

                            listInventory.InvenQuan = listInventory.InvenQuan + Quantity;

                            listFittingsInfos.InvenQuan = listFittingsInfos.InvenQuan + Quantity;

                            myModels.Entry(listInventory).State = System.Data.Entity.EntityState.Modified;//修改库存数量

                            myModels.Entry(listFittingsInfos).State = System.Data.Entity.EntityState.Modified;//修改配件数量

                            var listdelect = myModels.SYS_CollageDetai.Where(m => m.CollageDetaiID == item).Single();//删除

                            myModels.SYS_CollageDetai.Remove(listdelect);

                        }

                    }

                    else

                    {

                        var listdelect = myModels.SYS_CollageDetai.Where(m => m.CollageID == CollageID).ToList();//删除全部

                        myModels.SYS_CollageDetai.RemoveRange(listdelect);

                    }

                    myModels.SaveChanges();

                }

            }

            catch (Exception e)

            {

                return Json(false, JsonRequestBehavior.AllowGet);

            }

            return Json(list, JsonRequestBehavior.AllowGet);

        }

      1. 查询领料单据信息

        public ActionResult SelectCollage(BsgridPage bsgridPage)//查询领料单据信息

        {

            var lingItem = (from tbCollage in myModels.PW_Collage

                            join tbReception in myModels.PW_Reception on tbCollage.ReceptionID equals tbReception.ReceptionID

                            select new CollageVo

                            {

                                CollageID=tbCollage.CollageID,//领料ID

                                ReceptionID=tbReception.ReceptionID,

                                CarNum=tbReception.CarNum.Trim(),//车牌

                                Owner=tbReception.Owner.Trim(),//车主

                                MaintenanceNum=tbReception.MaintenanceNum.Trim(),

      1. //结算单号

                                CollageState = tbReception.CollageState.Trim() != "已退料" ? tbReception.CollageState.Trim() : "未领料",

                                ForeMan =tbCollage.ForeMan.Trim(),

      1. //领料员

                                Operator=tbCollage.Operator.Trim(),//操作人

                                Auditor=tbCollage.Auditor.Trim(),//审核人

                                Amount=tbCollage.Amount,//总金额

                                AuditDate=tbCollage.AuditDate.ToString(),//审核时间

                                CollageDate=tbCollage.CollageDate.ToString(),

      1. //领料时间

                                ToAudit=tbCollage.ToAudit,//审核否

                                Remark=tbCollage.Remark.Trim(),//备注

                            }).ToList();

            int count = lingItem.Count();

            List<CollageVo> listCollage = lingItem.OrderBy(m => m.ToAudit).Skip(bsgridPage.GetStartIndex()).Take(bsgridPage.pageSize).ToList();

            Bsgrid<CollageVo> bsgrid = new Bsgrid<CollageVo>()

            {

                success = true,

                totalRows = count,

                curPage = bsgridPage.curPage,

                data = listCollage

            };

            return Json(bsgrid, JsonRequestBehavior.AllowGet);

        }

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/bicheng/56989.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

玫瑰花HTML源码

HTML源码 <pre id"tiresult" style"font-size: 9px; background-color: #000000; font-weight: bold; padding: 4px 5px; --fs: 9px;"><b style"color:#000000">0010000100000111101110110111100010000100000100001010111111100110…

buuctf[湖南省赛2019]Findme1

解压得5个图片&#xff0c;其中图片1&#xff0c;高度不正常&#xff0c;使用下面脚本破解真实高度和宽度 import os import binascii import structcrcbp open("1.png", "rb").read() for i in range(1024):for j in range(1024):data crcbp[12:16] st…

维修数据屏:重塑热力公司运维管理新格局

在热力公司的运维管理中&#xff0c;高效的报修和维修流程是确保系统稳定运行的关键。随着科技的发展&#xff0c;维修数据屏的出现为热力公司的运维工作带来了重大变革。 一、传统热力运维面临的挑战 过去&#xff0c;热力公司在报修和维修方面存在诸多问题&#xff0c;给运维…

Android中的MVP模式

MVP&#xff08;Model-View-Presenter&#xff09;架构在 Android 开发中是一种流行的架构模式&#xff0c;它将业务逻辑和 UI 代码分离&#xff0c;通过 Presenter 来处理用户的操作和界面更新。MVP 提高了代码的可维护性和测试性&#xff0c;特别是 Presenter 中的逻辑可以单…

如何使用Python对Excel、CSV文件完成数据清洗与预处理?

在数据分析和机器学习项目中&#xff0c;数据清洗与预处理是不可或缺的重要环节。 现实世界中的数据往往是不完整、不一致且含有噪声的&#xff0c;这些问题会严重影响数据分析的质量和机器学习模型的性能。 Python作为一门强大的编程语言&#xff0c;提供了多种库和工具来帮…

SpringCloud学习:Seata总结与回顾

SpringCloud学习&#xff1a;Seata总结与回顾 文章目录 SpringCloud学习&#xff1a;Seata总结与回顾1. Seata实战&#xff1a;测试2. Seate原理总结和面试题3. Seata总结与回顾4. 易混点 1. Seata实战&#xff1a;测试 测试问题 未启用分布式事务 若不使用分布式事务&#xf…

sql server删除过期备份文件脚本

一、通过脚本查看过期文件&#xff0c;时间可以自己设定 for /f "delims" %i in (dir /b /a-d "E:\mybak_file\*.bak" ^| findstr /i "backup" ^| findstr /v /i "no_backup") do if "%~ti" LSS "2024/09/29 16:50&qu…

算法-尺取法

尺取法&#xff08;Sliding Window Technique&#xff09;&#xff0c;也称为滑动窗口算法&#xff0c;是一种常用于解决数组或字符串子区间问题的有效方法。其核心思想是通过维护一个窗口&#xff08;子区间&#xff09;&#xff0c;在数组或字符串上滑动这个窗口&#xff0c;…

Greenhills学习总结

学习背景&#xff1a;近期参与xx项目过程中&#xff0c;遇到较多的关于代码集成编译的知识盲区&#xff0c;因此需要进行相关知识的学习和扫盲。 参考资料&#xff1a;GreenHills2017.7编译手册:本手册是GreenHills 2017.7.14版编译器的软件使用手册。该手册详细介绍了GreenHi…

Docker consul注册中心

一、consul 1.1、什么是服务注册与发现 服务注册与发现是微服务架构中不可或缺的重要组件。 起初服务都是单节点的&#xff0c;不保障高可用性&#xff0c;也不考虑服务的压力承载&#xff0c;服务之间调用单纯的通过接口访问。 直到后来出现了多个节点的分布式架构&#x…

React(五) 受控组件和非受控组件; 获取表单元素的值。高阶组件(重点),Portals; Fragment组件;严格模式StrictMode

文章目录 一、受控组件1. 什么是受控组件2. 收集input框内容3. 收集checkBox的值4. 下拉框select总结 二、非受控组件三、高阶组件1. 高阶组件的概念 (回顾高阶函数)2. 高阶组件应用&#xff1a;注入props(1) 高阶组件给---函数式组件注入props(2) 高阶组件给---类组件注入prop…

前100+大型语言模型(LLMs)面试问题和路线图

介绍 获取前 100 个精选的 LLM 面试问题&#xff0c;了解如何准备生成式 AI 或 LLM 面试准备和大型语言模型 &#xff08;LLM&#xff09; 面试准备的学习路径。 This article explains learning path for large language models (LLMs) interview preparation. You will fin…

陪诊小程序之uniapp(从入门到精通)

1.uniapp如何使用vue3编写页面 <template><view class"content"><navbar name"navbar组件"></navbar><image class"logo" src"/static/logo.png"></image><view class"text-area"&…

K14837 时空穿越(through)

题目描述 杰克船长的“黑珍珠号”误入了一片海域&#xff0c;一翻风浪过后&#xff0c;他发现自己穿越到了一个未知且神奇的岛屿上&#xff0c;岛屿上空无一物&#xff0c;只有一块写着字的牌子&#xff0c;上面写着&#xff1a;欢迎来到这里&#xff0c;参加我们的时间旅行计…

【OD】【E卷】【真题】【100分】补种未成活胡杨(PythonJavajavaScriptC++C)

题目描述 近些年来&#xff0c;我国防沙治沙取得显著成果。某沙漠新种植N棵胡杨&#xff08;编号1-N&#xff09;&#xff0c;排成一排。 一个月后&#xff0c;有M棵胡杨未能成活。 现可补种胡杨K棵&#xff0c;请问如何补种&#xff08;只能补种&#xff0c;不能新种&#…

C++进阶:AVL树实现

目录 一.AVL的概念 二.AVL的实现 2.1AVL树的结构 2.2AVL树的插入 2.2.1AVL树插入一个值的大概过程 2.2.2平衡因子更新 2.2.3插入节点及更新平衡因子的实现 2.3旋转 2.3.1旋转的原则 2.3.2右单旋 2.3.3右单旋的代码实现 2.3.4左单旋 2.3.5左单旋的代码实现 2.3.6…

vue综合指南(二)

​&#x1f308;个人主页&#xff1a;前端青山 &#x1f525;系列专栏&#xff1a;Vue篇 &#x1f516;人终将被年少不可得之物困其一生 依旧青山,本期给大家带来Vuet篇专栏内容:vue综合指南(二) 目录 21、介绍虚拟DOM 22、vue生命周期的理解 23、vue父组件向子组件传递数据…

架构设计笔记-20-补充知识

知识产权 我国没有专门针对知识产权制定统一的法律(知识产权法)&#xff0c;而是在民法通则规定的原则下&#xff0c;根据知识产权的不同类型制定了不同的单项法律及法规&#xff0c;如著作权法、商标法、专利法、计算机软件保护条例等&#xff0c;这些法律、法规共同构成了我…

STM32_实验5_中断实验

通过外部中断来检测四个按键按下的状态&#xff1a; WK_UP 控制蜂鸣器响和停 KEY0 控制 LED_R 互斥点亮 KEY1 控制 LED_G 互斥点亮 KEY2 控制 LED_B 互斥点亮。 中断的基本概念&#xff1a; 中断请求&#xff08;IRQ&#xff09;&#xff1a; 当发生某个特定事件&#xff08;例…

【问题解决】——当出现0xc000007b和缺少mfc140.dll时,该怎么做才能让软件可以打开

目录 事情起因 问题处理 明确定义 填坑之路 最后我是怎么解决的&#xff08;不想看故事直接到这里&#xff09; 事情起因 最近想要重新安装西门子博途来做西门子的一些算法的时候&#xff0c;发现自己软件装的是V15.1的版本&#xff0c;而买的plc1200固件版本要求至少16以…