Exemplo n.º 1
0
 public T AddEntity(T entity)
 {
     CurrentDAL.AddEntity(entity);
     CurrentDBSession.SaveChanges();
     return(entity);
 }
Exemplo n.º 2
0
 public bool AddEntity(T entity)
 {
     CurrentDal.AddEntity(entity);
     return(CurrentDBSession.SaveChanges());
 }
Exemplo n.º 3
0
 /// <summary>
 /// 删除数据
 /// </summary>
 /// <param name="entities"></param>
 /// <returns></returns>
 public bool DeleteEntites(T entities)
 {
     CurrentDal.DeleteEntites(entities);
     return(CurrentDBSession.SaveChanges());
 }
Exemplo n.º 4
0
 /// <summary>
 /// 设置登录错误次数和时间
 /// </summary>
 /// <param name="uId">用户Id</param>
 /// <param name="errorCount">错误次数</param>
 /// <param name="errorTime">错误时间</param>
 /// <returns>返回是否成功的标识,受影响行数大于0则返回true,否则为false</returns>
 public bool SetErrorInfo(long uId, int errorCount, string errorTime)
 {
     ((IUserInfoDal)CurrentDal).SetErrorInfo(uId, errorCount, errorTime);
     return(CurrentDBSession.SaveChanges());
 }
Exemplo n.º 5
0
        /// <summary>
        /// 弃审
        /// </summary>
        /// <param name="TransferBillId">单据Id</param>
        /// <param name="UserName">用户名</param>
        /// <returns></returns>
        public string GiveupExamine(Guid OtherInputId, string UserName)
        {
            OtherInput    bill = CurrentDal.LoadEntities(a => a.Id == OtherInputId).FirstOrDefault();
            List <Record> list = bill.Record.ToList();
            string        res  = "";

            if (bill.BillState != 2)
            {
                res = "单据状态不对,无法弃审!";
                return(res);
            }
            List <InWarehouse> listDel = new List <InWarehouse>();//暂存区

            //对每一条记录做逆操作
            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(); //库存
                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     = 1;    //改成编辑状态
            bill.ExaminePerson = null; //清除审核人
            bill.ExamineDate   = null; //清除审核时间
            CurrentDal.EditEntity(bill);
            return(CurrentDBSession.SaveChanges() ? "操作成功" : "操作失败");
        }
Exemplo n.º 6
0
 public bool DeleteEntityByID(int ID)
 {
     return(CurrentDBSession.ExcuteSQL("DELETE Account WHERE ID=@ID", new SqlParameter("@ID", ID)) > 0);
 }
Exemplo n.º 7
0
        public bool DeleteRolePermissions(int RoleID)
        {
            string SQLString = "DELETE RoleActionURL_Mapping WHERE RoleID=@RoleID";

            return(CurrentDBSession.ExcuteSQL(SQLString, new System.Data.SqlClient.SqlParameter("@RoleID", RoleID)) > 0);
        }
Exemplo n.º 8
0
 /// <summary>
 /// 保存表单数据
 /// </summary>
 /// <returns></returns>
 public string SaveData(LocationChange bill, List <LocationChangeRecordView> LocationChangeRecordView)
 {
     //主表id为0 新增一条记录  此时子表数据会自动插入
     if (bill.Id == Guid.Parse("00000000-0000-0000-0000-000000000000"))
     {
         bill.Id        = Guid.NewGuid(); //生成一个id
         bill.BillState = 1;              //保存状态
         foreach (var lcrv in LocationChangeRecordView)
         {
             Record cd = new Record();
             cd.Id                 = Guid.NewGuid();
             cd.MainTableId        = bill.Id;
             cd.Count              = lcrv.Count;
             cd.CreateDate         = DateTime.Now;
             cd.Department         = bill.Department;
             cd.DepartmentId       = bill.DepartmentId;
             cd.State              = 1;
             cd.ItemBatch          = lcrv.ItemBatch;
             cd.ItemCode           = lcrv.ItemCode;
             cd.ItemLine           = lcrv.ItemLine;
             cd.ItemName           = lcrv.ItemName;
             cd.ItemSpecifications = lcrv.ItemSpecifications;
             cd.ItemUnit           = lcrv.ItemUnit;
             cd.UnitWeight         = lcrv.UnitWeight;
             cd.Weight             = lcrv.Weight;
             cd.ItemLocation       = lcrv.LocationChangeAfter;
             cd.ItemLocationId     = lcrv.LocationChangeAfterId;
             cd.InOrOut            = 1;
             cd.Warehouse          = lcrv.WarehouseAfter;
             cd.WarehouseId        = lcrv.WarehouseAfterId;
             CurrentDBSession.RecordDal.AddEntity(cd);
             Record cd2 = new Record();
             cd2.Id                 = Guid.NewGuid();
             cd2.MainTableId        = bill.Id;
             cd2.Count              = lcrv.Count;
             cd2.CreateDate         = DateTime.Now;
             cd2.Department         = bill.Department;
             cd2.DepartmentId       = bill.DepartmentId;
             cd2.State              = 1;
             cd2.ItemBatch          = lcrv.ItemBatch;
             cd2.ItemCode           = lcrv.ItemCode;
             cd2.ItemLine           = lcrv.ItemLine;
             cd2.ItemName           = lcrv.ItemName;
             cd2.ItemSpecifications = lcrv.ItemSpecifications;
             cd2.ItemUnit           = lcrv.ItemUnit;
             cd2.UnitWeight         = lcrv.UnitWeight;
             cd2.Weight             = lcrv.Weight;
             cd2.ItemLocation       = lcrv.LocationChangeBefore;
             cd2.ItemLocationId     = lcrv.LocationChangeBeforeId;
             cd2.InOrOut            = 0;
             cd2.Warehouse          = lcrv.WarehouseBefore;
             cd2.WarehouseId        = lcrv.WarehouseBeforeId;
             CurrentDBSession.RecordDal.AddEntity(cd2);
         }
         CurrentDal.AddEntity(bill);
     }
     //主表有id  说明是修改的
     else
     {
         //删除原子表数据
         List <Record> list = CurrentDBSession.RecordDal.LoadEntities(a => a.MainTableId == bill.Id).ToList();
         foreach (Record item in list)
         {
             CurrentDBSession.RecordDal.DeleteEntity(item);
             //RecordService.DeleteEntity(item);
         }
         //添加子表数据
         foreach (var lcrv in LocationChangeRecordView)
         {
             Record cd = new Record();
             cd.Id                 = Guid.NewGuid();
             cd.MainTableId        = bill.Id;
             cd.Count              = lcrv.Count;
             cd.CreateDate         = DateTime.Now;
             cd.Department         = bill.Department;
             cd.DepartmentId       = bill.DepartmentId;
             cd.State              = 1;
             cd.ItemBatch          = lcrv.ItemBatch;
             cd.ItemCode           = lcrv.ItemCode;
             cd.ItemLine           = lcrv.ItemLine;
             cd.ItemName           = lcrv.ItemName;
             cd.ItemSpecifications = lcrv.ItemSpecifications;
             cd.ItemUnit           = lcrv.ItemUnit;
             cd.UnitWeight         = lcrv.UnitWeight;
             cd.Weight             = lcrv.Weight;
             cd.ItemLocation       = lcrv.LocationChangeAfter;
             cd.ItemLocationId     = lcrv.LocationChangeAfterId;
             cd.InOrOut            = 1;
             cd.Warehouse          = lcrv.WarehouseAfter;
             cd.WarehouseId        = lcrv.WarehouseAfterId;
             CurrentDBSession.RecordDal.AddEntity(cd);
             Record cd2 = new Record();
             cd2.Id                 = Guid.NewGuid();
             cd2.MainTableId        = bill.Id;
             cd2.Count              = lcrv.Count;
             cd2.CreateDate         = DateTime.Now;
             cd2.Department         = bill.Department;
             cd2.DepartmentId       = bill.DepartmentId;
             cd2.State              = 1;
             cd2.ItemBatch          = lcrv.ItemBatch;
             cd2.ItemCode           = lcrv.ItemCode;
             cd2.ItemLine           = lcrv.ItemLine;
             cd2.ItemName           = lcrv.ItemName;
             cd2.ItemSpecifications = lcrv.ItemSpecifications;
             cd2.ItemUnit           = lcrv.ItemUnit;
             cd2.UnitWeight         = lcrv.UnitWeight;
             cd2.Weight             = lcrv.Weight;
             cd2.ItemLocation       = lcrv.LocationChangeBefore;
             cd2.ItemLocationId     = lcrv.LocationChangeBeforeId;
             cd2.InOrOut            = 0;
             cd2.Warehouse          = lcrv.WarehouseBefore;
             cd2.WarehouseId        = lcrv.WarehouseBeforeId;
             CurrentDBSession.RecordDal.AddEntity(cd2);
         }
         //修改主表数据
         CurrentDal.EditEntity(bill);
     }
     return(CurrentDBSession.SaveChanges() ? bill.Id.ToString() : "no");
 }
Exemplo n.º 9
0
        /// <summary>
        /// 弃审
        /// </summary>
        /// <param name="TransferBillId">单据Id</param>
        /// <param name="UserName">用户名</param>
        /// <returns></returns>
        public string GiveupExamine(Guid LocationChangeId, string UserName)
        {
            LocationChange bill = CurrentDal.LoadEntities(a => a.Id == LocationChangeId).FirstOrDefault();
            List <Record>  list = CurrentDBSession.RecordDal.LoadEntities(b => b.MainTableId == bill.Id).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.ItemLocation == item.ItemLocation && i.ItemBatch == item.ItemBatch).FirstOrDefault();
                if (item.InOrOut == 0)
                {
                    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);
                    }
                }
                else
                {
                    if (inWarehouse == null || inWarehouse.Count < item.Count) //当前库存不够 ,不允许做弃审操作
                    {
                        var 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     = 1;    //改成编辑状态
            bill.ExaminePerson = null; //清除审核人
            bill.ExamineDate   = null; //清除审核时间
            CurrentDal.EditEntity(bill);
            return(CurrentDBSession.SaveChanges() ? "操作成功" : "操作失败");
        }
Exemplo n.º 10
0
 //修改用户信息
 public bool Updateentity(T entry)
 {
     CurrentDal.Updateentity(entry);
     return(CurrentDBSession.SaveChanges());
 }
Exemplo n.º 11
0
        /// <summary>
        /// 审核表单
        /// </summary>
        /// <param name="TransferBillId"></param>
        /// <returns></returns>
        public string Examine(Guid LocationChangeId, string UserName)
        {
            string         result = "";
            LocationChange bill   = CurrentDal.LoadEntities(a => a.Id == LocationChangeId).FirstOrDefault();
            List <Record>  list   = CurrentDBSession.RecordDal.LoadEntities(b => b.MainTableId == bill.Id).ToList();

            foreach (Record item in list)
            {
                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 (item.InOrOut == 1)
                {                            //等于1入库
                    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);
                    }
                }
                else
                {  //出库
                    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);
        }
Exemplo n.º 12
0
 //删除用户信息
 public bool Deleteeneity(T entry)
 {
     CurrentDal.Deleteeneity(entry);
     return(CurrentDBSession.SaveChanges());
 }
Exemplo n.º 13
0
 public T Addentity(T entry)
 {
     CurrentDal.Addentity(entry);
     CurrentDBSession.SaveChanges();
     return(entry);
 }
Exemplo n.º 14
0
 public bool DeleteEntity(T entity)
 {
     CurrentDAL.DeleteEntity(entity);
     return(CurrentDBSession.SaveChanges());
 }
Exemplo n.º 15
0
        /// <summary>
        /// 添加角色权限对应
        /// </summary>
        /// <param name="RoleID"></param>
        /// <param name="ActionURLID"></param>
        /// <returns></returns>
        public bool InsertRolePermissions(int RoleID, int ActionURLID)
        {
            string SQLString = "INSERT INTO RoleActionURL_Mapping(RoleID,ActionURLID) VALUES(@RoleID,@ActionURLID)";

            return(CurrentDBSession.ExcuteSQL(SQLString, new SqlParameter[] { new SqlParameter("@RoleID", RoleID), new SqlParameter("@ActionURLID", ActionURLID) }) > 0);
        }
Exemplo n.º 16
0
 public T Insert(T model)
 {
     CurrentDal.Insert(model);
     CurrentDBSession.SaveChanges();
     return(model);
 }
Exemplo n.º 17
0
        public List <int> GetAllTopActionURLIDS()
        {
            string SQLString = "SELECT ID FROM ActionURL WHERE ParentID=0";

            return(CurrentDBSession.ExcuteQuery <int>(SQLString));
        }
Exemplo n.º 18
0
 public bool Update(T model)
 {
     CurrentDal.Update(model);
     return(CurrentDBSession.SaveChanges());
 }
Exemplo n.º 19
0
        public List <ActionURL> GetActionURLs(string Filter = "")
        {
            string SQLString = "SELECT * FROM ActionURL" + (string.IsNullOrEmpty(Filter)?"":" WHERE " + Filter);

            return(CurrentDBSession.ExcuteQuery <ActionURL>(SQLString));
        }
Exemplo n.º 20
0
        /// <summary>
        /// 弃审
        /// </summary>
        /// <param name="OtherOutputId">单据Id</param>
        /// <param name="UserName">用户名</param>
        /// <returns></returns>
        public string GiveupExamine(Guid OtherOutputId, string UserName)
        {
            OtherOutput   bill = CurrentDal.LoadEntities(a => a.Id == OtherOutputId).FirstOrDefault();
            List <Record> list = bill.Record.ToList();
            string        res  = "";

            if (bill.BillState != 2)
            {
                res = "单据状态不对,无法弃审!";
                return(res);
            }
            //对每一条记录做逆操作
            List <InWarehouse> listAdd = new List <InWarehouse>();//新增列表

            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();
                //查暂存
                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     = 1;    //改成编辑状态
            bill.ExaminePerson = null; //清除审核人
            bill.ExamineDate   = null; //清除审核时间
            CurrentDal.EditEntity(bill);
            return(CurrentDBSession.SaveChanges() ? "操作成功" : "操作失败");
        }
Exemplo n.º 21
0
 /// <summary>
 /// 设置否决权限
 /// </summary>
 /// <param name="uId">用户Id</param>
 /// <param name="aId">要设置否决的权限</param>
 /// <param name="isAllow">是否允许</param>
 /// <returns>返回是否成功的标识,受影响行数大于0则返回true,否则为false</returns>
 public bool SetAction(long uId, long aId, int isAllow)
 {
     ((IUserInfoDal)CurrentDal).SetAction(uId, aId, isAllow);
     return(CurrentDBSession.SaveChanges());
 }
Exemplo n.º 22
0
 /// <summary>
 /// 保存表单数据
 /// </summary>
 /// <returns></returns>
 public string SaveData(LoadingExpensesBill bill, int billType)
 {
     //主表id为0 新增一条记录  此时子表数据会自动插入
     if (bill.Id == Guid.Parse("00000000-0000-0000-0000-000000000000"))
     {
         bill.Id = Guid.NewGuid();//生成一个id
         if (billType == 1)
         {
             bill.BillCode = GetBillCode("ZS");//生成单号  装卸费收入
             if (bill.BillCode == "no")
             {
                 bill.BillCode = GetBillCode("ZS");//再次生成单号
             }
         }
         if (billType == 2)
         {
             bill.BillCode = GetBillCode("ZF");//生成单号 成本
             if (bill.BillCode == "no")
             {
                 bill.BillCode = GetBillCode("ZF");//再次生成单号
             }
         }
         if (billType == 3)
         {
             bill.BillCode = GetBillCode("LS");//生成单号 力资费收入
             if (bill.BillCode == "no")
             {
                 bill.BillCode = GetBillCode("LS");//再次生成单号
             }
         }
         bill.BillState  = 1;//保存状态
         bill.BillType   = billType;
         bill.CreateDate = DateTime.Now;
         foreach (var item in bill.LoadingAndLaborCostDetail)//生成子表id
         {
             if (item.Id == Guid.Parse("00000000-0000-0000-0000-000000000000"))
             {
                 item.Id = Guid.NewGuid();
             }
             item.MainTableId  = bill.Id;
             item.Department   = bill.Department;
             item.DepartmentId = bill.DepartmentId;
             item.Company      = bill.Company;
             item.CompanyId    = bill.CompanyId;
             item.BillState    = 1;
             item.BillType     = billType;
             item.CreateDate   = DateTime.Now;
         }
         CurrentDal.AddEntity(bill);
     }
     //主表有id  说明是修改的
     else
     {
         //删除原子表数据
         List <LoadingAndLaborCostDetail> list = CurrentDBSession.LoadingAndLaborCostDetailDal.LoadEntities(a => a.MainTableId == bill.Id).ToList();
         foreach (LoadingAndLaborCostDetail item in list)
         {
             CurrentDBSession.LoadingAndLaborCostDetailDal.DeleteEntity(item);
         }
         //添加子表数据
         foreach (LoadingAndLaborCostDetail record in bill.LoadingAndLaborCostDetail)
         {
             if (record.Id == Guid.Parse("00000000-0000-0000-0000-000000000000") || record.Id == Guid.Empty)
             {
                 record.Id = Guid.NewGuid(); //设置子表id
             }
             record.MainTableId  = bill.Id;  //设置主表id
             record.Department   = bill.Department;
             record.DepartmentId = bill.DepartmentId;
             record.Company      = bill.Company;
             record.CompanyId    = bill.CompanyId;
             record.BillState    = 1;
             record.BillType     = billType;
             record.CreateDate   = DateTime.Now;
             CurrentDBSession.LoadingAndLaborCostDetailDal.AddEntity(record);
         }
         //修改主表数据
         CurrentDal.EditEntity(bill);
     }
     return(CurrentDBSession.SaveChanges() ? bill.Id.ToString() : "no");
 }
Exemplo n.º 23
0
 /// <summary>
 /// 保存表单数据
 /// </summary>
 /// <returns></returns>
 public string SaveData(OtherInput bill)
 {
     //主表id为0 新增一条记录  此时子表数据会自动插入
     if (bill.Id == Guid.Parse("00000000-0000-0000-0000-000000000000"))
     {
         bill.Id       = Guid.NewGuid();    //生成一个id
         bill.BillCode = GetBillCode("OI"); //生成单号
         if (bill.BillCode == "no")
         {
             bill.BillCode = GetBillCode("OI"); //再次生成单号
         }
         bill.BillState = 1;                    //保存状态
         foreach (var item in bill.Record)      //生成子表id
         {
             if (item.Id == Guid.Parse("00000000-0000-0000-0000-000000000000"))
             {
                 item.Id = Guid.NewGuid();
             }
             item.Department    = bill.Department;
             item.DepartmentId  = bill.DepartmentId;
             item.WarehouseId   = bill.WarehouseId;
             item.Warehouse     = bill.Warehouse;
             item.State         = bill.BillState;
             item.CreateDate    = DateTime.Now;
             item.InOrOut       = 1;
             item.MainTableType = "OtherInput";
             item.InOutTypeName = bill.InputType;
             item.InOutTypeId   = bill.InputTypeId;
         }
         CurrentDal.AddEntity(bill);
     }
     //主表有id  说明是修改的
     else
     {
         //删除原子表数据
         List <Record> list = CurrentDBSession.RecordDal.LoadEntities(a => a.MainTableId == bill.Id).ToList();
         foreach (Record item in list)
         {
             CurrentDBSession.RecordDal.DeleteEntity(item);
             //RecordService.DeleteEntity(item);
         }
         //添加子表数据
         foreach (Record record in bill.Record)
         {
             if (record.Id == Guid.Parse("00000000-0000-0000-0000-000000000000") || record.Id == Guid.Empty)
             {
                 record.Id = Guid.NewGuid(); //设置子表id
             }
             record.MainTableId   = bill.Id; //设置主表id
             record.Department    = bill.Department;
             record.DepartmentId  = bill.DepartmentId;
             record.WarehouseId   = bill.WarehouseId;
             record.Warehouse     = bill.Warehouse;
             record.State         = bill.BillState;
             record.CreateDate    = DateTime.Now;
             record.InOrOut       = 1;
             record.MainTableType = "OtherInput";
             record.InOutTypeName = bill.InputType;
             record.InOutTypeId   = bill.InputTypeId;
             CurrentDBSession.RecordDal.AddEntity(record);
             //RecordService.AddEntity(record);
         }
         //修改主表数据
         CurrentDal.EditEntity(bill);
     }
     return(CurrentDBSession.SaveChanges()? bill.Id.ToString() : "no");
 }
Exemplo n.º 24
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();

            #region  批次 货位 物料编码相同的 合并在一起(暂时不用)
            //var resultq = from a in list
            //              group a by new { a.ItemBatch, a.ItemLocationId, a.ItemCode, a.ItemLine, a.ItemName, a.ItemSpecifications, a.ItemUnit, a.UnitWeight,a.ItemLocation,a.Warehouse,a.WarehouseId,a.CurrentCount} into g
            //              select new { Count = g.Sum(p => p.Count), Weight = g.Sum(p => p.Weight), g.Key.ItemBatch,g.Key.ItemLocationId,g.Key.ItemCode,g.Key.ItemLine,g.Key.ItemName,g.Key.ItemSpecifications,g.Key.ItemUnit,g.Key.UnitWeight,g.Key.ItemLocation,g.Key.WarehouseId,g.Key.Warehouse,g.Key.CurrentCount };
            #endregion
            List <InWarehouse> listAdd = new List <InWarehouse>();//新增列表
            foreach (Record item in list)
            {
                item.State       = 2;
                item.ExamineDate = DateTime.Now;
                //查库存
                InWarehouse inWarehouse = CurrentDBSession.InWarehouseDal.LoadEntities(p => p.ItemCode == item.ItemCode && p.ItemLocationId == item.ItemLocationId && p.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());
        }
Exemplo n.º 25
0
 /// <summary>
 /// 3- 批量修改
 /// </summary>
 /// <param name="list"></param>
 /// <returns></returns>
 public bool DelByList(List <T> list)
 {
     CurrentDAL.DelByList(list);
     //return idal.SaveChange();
     return(CurrentDBSession.SaveChanges());
 }
Exemplo n.º 26
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();
            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,
                        Department         = item.Department,
                        DepartmentId       = item.DepartmentId,
                        Company            = bill.Company,
                        CompanyId          = bill.CompanyId
                    };
                    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);
            result = CurrentDBSession.SaveChanges() ? "审核成功!" : "审核失败!";
            return(result);
        }
Exemplo n.º 27
0
 /// <summary>
 /// 添加数据
 /// </summary>
 /// <param name="entities"></param>
 /// <returns></returns>
 public T AddEntities(T entities)
 {
     CurrentDal.AddEntities(entities);
     CurrentDBSession.SaveChanges();
     return(entities);
 }
Exemplo n.º 28
0
 public string Examine(Guid CheckBillId, string userName)
 {
     try
     {
         var checkBill = CurrentDal.LoadEntities(a => a.Id == CheckBillId).FirstOrDefault();
         var list      = CurrentDBSession.CheckDetailDal.LoadEntities(a => a.MainTableId == CheckBillId && a.Count != a.ChangeCount);//获取有变化的记录
         //删除原Record
         var oldRecordList = CurrentDBSession.RecordDal.LoadEntities(a => a.MainTableId == CheckBillId);
         foreach (var item in oldRecordList)
         {
             CurrentDBSession.RecordDal.DeleteEntity(item);
         }
         //生成新Record
         List <Record> listRecord = new List <Record>();
         foreach (var item in list)
         {
             item.State       = 2;
             item.ExamineDate = DateTime.Now;
             Record record = new Record()
             {
                 CreateDate         = item.CreateDate,
                 Department         = checkBill.Department,
                 DepartmentId       = checkBill.DepartmentId,
                 ExamineDate        = DateTime.Now,
                 ItemBatch          = item.ItemBatch,
                 ItemCode           = item.ItemCode,
                 ItemLine           = item.ItemLine,
                 ItemLocation       = item.ItemLocation,
                 ItemName           = item.ItemName,
                 ItemSpecifications = item.ItemSpecifications,
                 ItemUnit           = item.ItemUnit,
                 MainTableId        = checkBill.Id,
                 State          = 2,
                 Warehouse      = checkBill.Warehouse,
                 WarehouseId    = checkBill.WarehouseId,
                 InOrOut        = item.ChangeCount - item.Count > 0 ? 1 : 0,
                 Count          = item.ChangeCount - item.Count > 0 ? item.ChangeCount - item.Count : item.Count - item.ChangeCount,
                 ItemLocationId = item.ItemLocationId,
                 Remark         = item.Remark,
                 UnitWeight     = item.UnitWeight,
                 MainTableType  = "CheckBill",
                 Id             = Guid.NewGuid()
             };
             listRecord.Add(record);
             //操作库存
             var inwarehouselist = CurrentDBSession.InWarehouseDal.LoadEntities(a => a.ItemCode == item.ItemCode && a.ItemLocationId == item.ItemLocationId && a.ItemBatch == item.ItemBatch);
             if (inwarehouselist.Count() > 1)
             {
                 return("品项:" + item.ItemCode + "批次:" + item.ItemBatch + "有多条数据!");
             }
             if (inwarehouselist.Count() == 0)
             {
                 return("品项:" + item.ItemCode + "批次:" + item.ItemBatch + "没有库存记录!");
             }
             var inwarehouse = inwarehouselist.FirstOrDefault();
             if (inwarehouse.Count != item.Count)
             {
                 return("库存在盘点期间有变化,请重新盘点!");
             }
             inwarehouse.Count = item.ChangeCount;
             CurrentDBSession.InWarehouseDal.EditEntity(inwarehouse);//修改库存
         }
         checkBill.BillState     = 2;
         checkBill.ExaminePerson = userName;     //审核人
         checkBill.ExamineDate   = DateTime.Now; //审核时间
         checkBill.Record        = listRecord;
         CurrentDal.EditEntity(checkBill);
         return(CurrentDBSession.SaveChanges() ? "审核成功!" : "审核失败!");
     }
     catch (Exception e)
     {
         return(e.ToString());
     }
 }
Exemplo n.º 29
0
 /// <summary>
 /// 编辑数据
 /// </summary>
 /// <param name="entities"></param>
 /// <returns></returns>
 public bool EditEntities(T entities)
 {
     CurrentDal.EditEntities(entities);
     return(CurrentDBSession.SaveChanges());
 }
Exemplo n.º 30
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);
            }
            #region  批次 货位 物料编码相同的 合并在一起
            //var resultq = from a in list group a by new { a.ItemBatch, a.ItemLocationId, a.ItemCode,a.ItemLine,a.ItemName,a.ItemSpecifications,a.ItemUnit,a.UnitWeight } into g
            //              select new { Count = g.Sum(p => p.Count),Weight=g.Sum(p=>p.Weight),g.Key };
            //resultq.ToList();
            #endregion

            List <InWarehouse> listAdd = new List <InWarehouse>();//新增列表
            foreach (Record item in list)
            {
                item.State       = 1;    //修改记录状态
                item.ExamineDate = null; //清空审核时间
                InWarehouse inWarehouse = CurrentDBSession.InWarehouseDal.LoadEntities(a => a.ItemCode == item.ItemCode && a.ItemLocationId == item.ItemLocationId && a.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,
                        Department         = item.Department,
                        DepartmentId       = item.DepartmentId,
                        Company            = bill.Company,
                        CompanyId          = bill.CompanyId
                    };
                    item.CurrentCount = item.Count;
                    listAdd.Add(inWarehouse);                 //添加到暂存区
                }
                else if (inWarehouse == null && temp != null) //只有暂存区有库存
                {
                    temp.Count       += item.Count;
                    item.CurrentCount = temp.Count;
                }
                else//库存有记录  相加
                {
                    inWarehouse.Count = inWarehouse.Count + item.Count;
                    CurrentDBSession.InWarehouseDal.EditEntity(inWarehouse);
                    item.CurrentCount = inWarehouse.Count;
                }
            }
            //最后添加新增列表中数据
            foreach (var item in listAdd)
            {
                CurrentDBSession.InWarehouseDal.AddEntity(item);
            }
            bill.BillState     = 1;    //改成编辑状态
            bill.ExaminePerson = null; //清除审核人
            bill.ExamineDate   = null; //清除审核时间
            CurrentDal.EditEntity(bill);
            return(CurrentDBSession.SaveChanges() ? "操作成功" : "操作失败");
        }