Exemplo n.º 1
0
        /// <summary>
        /// 产品入库操作
        /// </summary>
        /// <param name="Batch"></param>
        /// <param name="stockinfo"></param>
        /// <returns></returns>
        public string InStock(string Batch, List <PI_BodyInfo> stockinfo)
        {
            using (DbTransactionScope <PI_BodyInfo> dbtran = base.CreateTransactionScope())
            {
                try
                {
                    //查询入库单是否审核
                    string SqlAuditSel = "select F_Status from PI_Head where F_Id='" + stockinfo[0].F_HId + "'";
                    string AuditState  = this.GetDataTableBySql(SqlAuditSel).Rows[0][0].ToString();
                    if (AuditState == "0")
                    {
                        return("该入库单未审核,不能进行入库操作");
                    }

                    //查询库存表是否存在该仓库中的产品
                    foreach (PI_BodyInfo item in stockinfo)
                    {
                        SearchCondition condtion = new SearchCondition();
                        condtion.AddCondition("F_GoodsId", item.F_GoodsId, SqlOperator.Equal);
                        condtion.AddCondition("F_WarehouseId", item.F_WarehouseId, SqlOperator.Equal);
                        List <Sys_StockInfo> stock = BLLFactory <Sys_Stock> .Instance.Find(condtion.BuildConditionSql().Replace("Where (1=1)  AND ", string.Empty));

                        if (stock == null)
                        {
                            item.IsHave = false;
                        }
                        else
                        {
                            item.IsHave      = true;
                            item.StockID     = stock[0].F_Id;
                            item.StockNumber = stock[0].F_Number;
                        }
                    }
                    foreach (PI_BodyInfo item in stockinfo)
                    {
                        //判断是否入库
                        PI_BodyInfo binfo = BLLFactory <PI_Body> .Instance.FindByID(item.F_Id);

                        if (binfo.F_AlreadyOperatedNum == "")
                        {
                            binfo.F_AlreadyOperatedNum = "0";
                        }
                        if (int.Parse(binfo.F_AlreadyOperatedNum) > 0)
                        {
                            return("该单据已入库,不能重复执行入库操作");
                        }
                        //查询库存表是否存在该仓库中的产品
                        //没有
                        if (!item.IsHave)
                        {
                            //新添加一条数据
                            Sys_StockInfo entity = new Sys_StockInfo();
                            entity.F_Id                = Guid.NewGuid().ToString();
                            entity.F_Batch             = item.F_OrderNo;
                            entity.F_CargoPositionId   = item.F_CargoPositionId;
                            entity.F_CargoPositionName = item.F_CargoPositionName;
                            entity.F_WarehouseId       = item.F_WarehouseId;
                            entity.F_WarehouseName     = item.F_WarehouseName;
                            entity.F_GoodsName         = item.F_GoodsName;
                            entity.F_GoodsId           = item.F_GoodsId;
                            entity.F_SpecifModel       = item.F_SpecifModel;
                            entity.F_SellingPrice      = item.F_SellingPrice;
                            entity.F_PurchasePrice     = item.F_PurchasePrice;
                            entity.F_Unit              = item.F_Unit;
                            entity.F_Number            = item.F_InStockNum;
                            Sys_Stock.Instance.Insert(entity, dbtran.Transaction);

                            //添加履历
                            Sys_InRecordsInfo inRec = new Sys_InRecordsInfo();
                            inRec.F_Id                = Guid.NewGuid().ToString();
                            inRec.F_WarehouseId       = item.F_WarehouseId;
                            inRec.F_WarehouseName     = item.F_WarehouseName;
                            inRec.F_GoodsName         = item.F_GoodsName;
                            inRec.F_GoodsId           = item.F_GoodsId;
                            inRec.F_CargoPositionId   = item.F_CargoPositionId;
                            inRec.F_CargoPositionName = item.F_CargoPositionName;
                            inRec.F_SpecifModel       = item.F_SpecifModel;
                            inRec.F_SellingPrice      = item.F_SellingPrice;
                            inRec.F_PurchasePrice     = item.F_PurchasePrice;
                            inRec.F_Unit              = item.F_Unit;
                            inRec.F_InStockNum        = item.F_InStockNum;
                            inRec.F_CreatorTime       = DateTime.Now;
                            Sys_InRecords.Instance.Insert(inRec, dbtran.Transaction);


                            //更新子表入库状态
                            Hashtable hash = new Hashtable();
                            hash.Add("F_AlreadyOperatedNum", 1);
                            PI_Body.Instance.Update(item.F_Id, hash, dbtran.Transaction);

                            //更新主表入库状态
                            hash = new Hashtable();
                            hash.Add("F_State", 1);
                            PI_Head.Instance.Update(item.F_HId, hash, dbtran.Transaction);
                        }
                        else
                        {
                            //更新前库存数量
                            Hashtable hash = new Hashtable();
                            hash.Add("F_Number", item.StockNumber + item.F_InStockNum);
                            Sys_Stock.Instance.Update(item.StockID, hash, dbtran.Transaction);
                            for (int i = 0; i < stockinfo.Count; i++)
                            {
                                if (stockinfo[i].StockID == item.StockID)
                                {
                                    stockinfo[i].StockNumber += item.F_InStockNum;
                                }
                            }

                            //更新子表入库状态
                            hash = new Hashtable();
                            hash.Add("F_AlreadyOperatedNum", 1);
                            PI_Body.Instance.Update(item.F_Id, hash, dbtran.Transaction);

                            //更新主表入库状态
                            hash = new Hashtable();
                            hash.Add("F_State", 1);
                            PI_Head.Instance.Update(item.F_HId, hash, dbtran.Transaction);


                            //添加履历
                            Sys_InRecordsInfo inRec = new Sys_InRecordsInfo();
                            inRec.F_Id                = Guid.NewGuid().ToString();
                            inRec.F_WarehouseId       = item.F_WarehouseId;
                            inRec.F_WarehouseName     = item.F_WarehouseName;
                            inRec.F_GoodsName         = item.F_GoodsName;
                            inRec.F_GoodsId           = item.F_GoodsId;
                            inRec.F_CargoPositionId   = item.F_CargoPositionId;
                            inRec.F_CargoPositionName = item.F_CargoPositionName;
                            inRec.F_SpecifModel       = item.F_SpecifModel;
                            inRec.F_SellingPrice      = item.F_SellingPrice;
                            inRec.F_PurchasePrice     = item.F_PurchasePrice;
                            inRec.F_Unit              = item.F_Unit;
                            inRec.F_InStockNum        = item.F_InStockNum;
                            inRec.F_CreatorTime       = DateTime.Now;
                            Sys_InRecords.Instance.Insert(inRec, dbtran.Transaction);
                        }
                    }
                    dbtran.Commit();
                    return("操作成功");
                }
                catch (Exception ex)
                {
                    dbtran.RollBack();
                    return("操作失败");

                    throw ex;
                }
            }

            //try
            //{
            //    //循环获取子表信息
            //    for (int i = 0; i < stockinfo.Count; i++)
            //    {
            //        string SqlAuditSel = "select F_Status from PI_Head where F_Id='" + stockinfo[i].F_HId + "'";
            //        string AuditState = this.GetDataTableBySql(SqlAuditSel).Rows[0][0].ToString();
            //        if (AuditState == "0")
            //        {
            //            return "该入库单未审核,不能进行入库操作";
            //        }

            //        string state = "select F_AlreadyOperatedNum from PI_Body where F_Id='" + stockinfo[i].F_Id + "'";
            //        DataTable dt = this.GetDataTableBySql(state);
            //        //判断是否已入库
            //        string AoNum = dt.Rows[0][0].ToString();
            //        if (AoNum == "")
            //        {
            //            AoNum = "0";
            //        }
            //        if (int.Parse(AoNum) > 0)
            //        {
            //            return "该单据已入库,不能重复执行入库操作";
            //        }

            //        //查询库存表是否存在该仓库中的产品
            //        string sql = "select F_Id,F_Number from Sys_Stock where F_GoodsId='" + stockinfo[i].F_GoodsId + "' and F_WarehouseId='" + stockinfo[i].F_WarehouseId + "'";

            //        //如果没有则添加一条数据
            //        if (this.GetDataTableBySql(sql).Rows.Count == 0)
            //        {
            //            //新添加一条数据
            //            Sys_StockInfo entity = new Sys_StockInfo();
            //            entity.F_Id = Guid.NewGuid().ToString();
            //            entity.F_Batch = stockinfo[i].F_OrderNo;
            //            entity.F_CargoPositionId = stockinfo[i].F_CargoPositionId;
            //            entity.F_CargoPositionName = stockinfo[i].F_CargoPositionName;
            //            entity.F_WarehouseId = stockinfo[i].F_WarehouseId;
            //            entity.F_WarehouseName = stockinfo[i].F_WarehouseName;
            //            entity.F_GoodsName = stockinfo[i].F_GoodsName;
            //            entity.F_GoodsId = stockinfo[i].F_GoodsId;
            //            entity.F_SpecifModel = stockinfo[i].F_SpecifModel;
            //            entity.F_SellingPrice = stockinfo[i].F_SellingPrice;
            //            entity.F_PurchasePrice = stockinfo[i].F_PurchasePrice;
            //            entity.F_Unit = stockinfo[i].F_Unit;
            //            entity.F_Number = stockinfo[i].F_InStockNum;
            //            Sys_Stock.Instance.Insert(entity);

            //            //添加履历
            //            Sys_InRecordsInfo inRec = new Sys_InRecordsInfo();
            //            inRec.F_Id = Guid.NewGuid().ToString();
            //            inRec.F_WarehouseId = stockinfo[i].F_WarehouseId;
            //            inRec.F_WarehouseName = stockinfo[i].F_WarehouseName;
            //            inRec.F_GoodsName = stockinfo[i].F_GoodsName;
            //            inRec.F_GoodsId = stockinfo[i].F_GoodsId;
            //            inRec.F_CargoPositionId = stockinfo[i].F_CargoPositionId;
            //            inRec.F_CargoPositionName = stockinfo[i].F_CargoPositionName;
            //            inRec.F_SpecifModel = stockinfo[i].F_SpecifModel;
            //            inRec.F_SellingPrice = stockinfo[i].F_SellingPrice;
            //            inRec.F_PurchasePrice = stockinfo[i].F_PurchasePrice;
            //            inRec.F_Unit = stockinfo[i].F_Unit;
            //            inRec.F_InStockNum = stockinfo[i].F_InStockNum;
            //            inRec.F_CreatorTime = DateTime.Now;

            //            Sys_InRecords.Instance.Insert(inRec);

            //            //更新子表入库状态
            //            string upState = "update PI_Body set F_AlreadyOperatedNum='1' where F_Id='" + stockinfo[i].F_Id + "'";
            //            Hashtable hash = new Hashtable();
            //            base.ExecuteNonQuery(upState, hash);

            //            //更新主表入库状态
            //            string upStateH = "update PI_Head set F_State='1' where F_Id='" + stockinfo[i].F_HId + "'";
            //            Hashtable hash1 = new Hashtable();
            //            base.ExecuteNonQuery(upStateH, hash1);
            //        }
            //        //存在就更新库存
            //        else
            //        {
            //            //更新前库存数量
            //            int oldnum = int.Parse(this.GetDataTableBySql(sql).Rows[0][1].ToString());
            //            //要入库的数量
            //            int instockNum = stockinfo[i].F_InStockNum;
            //            //更新后库存数量
            //            int num = oldnum + instockNum;
            //            string Str = "update Sys_Stock set F_Number='" + num + "' where F_Id='" + this.GetDataTableBySql(sql).Rows[0][0].ToString() + "'";
            //            Hashtable hash = new Hashtable();
            //            base.ExecuteNonQuery(Str, hash);

            //            //更新子表入库状态
            //            string upState = "update PI_Body set F_AlreadyOperatedNum='1' where F_Id='" + stockinfo[i].F_Id + "'";
            //            Hashtable hash1 = new Hashtable();
            //            base.ExecuteNonQuery(upState, hash1);

            //            //更新主表入库状态
            //            string upStateH = "update PI_Head set F_State='1' where F_Id='" + stockinfo[i].F_HId + "'";
            //            Hashtable hash2 = new Hashtable();
            //            base.ExecuteNonQuery(upStateH, hash2);

            //            //添加履历
            //            Sys_InRecordsInfo inRec = new Sys_InRecordsInfo();
            //            inRec.F_Id = Guid.NewGuid().ToString();
            //            inRec.F_WarehouseId = stockinfo[i].F_WarehouseId;
            //            inRec.F_WarehouseName = stockinfo[i].F_WarehouseName;
            //            inRec.F_GoodsName = stockinfo[i].F_GoodsName;
            //            inRec.F_GoodsId = stockinfo[i].F_GoodsId;
            //            inRec.F_CargoPositionId = stockinfo[i].F_CargoPositionId;
            //            inRec.F_CargoPositionName = stockinfo[i].F_CargoPositionName;
            //            inRec.F_SpecifModel = stockinfo[i].F_SpecifModel;
            //            inRec.F_SellingPrice = stockinfo[i].F_SellingPrice;
            //            inRec.F_PurchasePrice = stockinfo[i].F_PurchasePrice;
            //            inRec.F_Unit = stockinfo[i].F_Unit;
            //            inRec.F_InStockNum = stockinfo[i].F_InStockNum;
            //            inRec.F_CreatorTime = DateTime.Now;
            //            Sys_InRecords.Instance.Insert(inRec);
            //        }
            //    }
            //    return "操作成功";
            //}
            //catch (Exception ex)
            //{
            //    throw ex;
            //}
        }
Exemplo n.º 2
0
        /// <summary>
        ///审核单据
        /// </summary>
        /// <param name="date">审核日期</param>
        /// <param name="Id">审核单据</param>
        /// <param name="user">审核人</param>
        public string Audit(string date, string user, string Id, List <PI_BodyInfo> stockinfo)
        {
            string SqlAuditSel = "select F_Status from PI_Head where F_Id='" + Id + "'";
            string AuditState  = this.GetDataTableBySql(SqlAuditSel).Rows[0][0].ToString();

            if (AuditState == "1")
            {
                return("单据已被审核");
            }
            else
            {
                using (DbTransactionScope <PI_HeadInfo> dbtran = base.CreateTransactionScope())
                {
                    try
                    {
                        //查询所有库存信息
                        List <Sys_StockInfo> stockList = BLLFactory <Sys_Stock> .Instance.GetAll();

                        //查询主表信息
                        PI_HeadInfo hinfo = BLLFactory <PI_Head> .Instance.FindByID(Id);


                        foreach (PI_BodyInfo item in stockinfo)
                        {
                            //判断是否入库
                            PI_BodyInfo binfo = BLLFactory <PI_Body> .Instance.FindByID(item.F_Id);

                            if (binfo.F_AlreadyOperatedNum == "")
                            {
                                binfo.F_AlreadyOperatedNum = "0";
                            }
                            if (int.Parse(binfo.F_AlreadyOperatedNum) > 0)
                            {
                                return("该单据已入库,不能重复执行入库操作");
                            }

                            if (binfo.F_WarehouseId == "" || binfo.F_CargoPositionId == "")
                            {
                                return("该单据中仓库或仓位为空,审核未通过");
                            }

                            Sys_StockInfo stock = stockList.Find(u => u.F_WarehouseId == binfo.F_WarehouseId && u.F_CargoPositionId == binfo.F_CargoPositionId && u.F_GoodsId == binfo.F_GoodsId && u.F_Batch == binfo.F_SerialNum);
                            if (stock == null)
                            {
                                item.IsHave = false;
                            }
                            else
                            {
                                item.IsHave      = true;
                                item.StockID     = stock.F_Id;
                                item.StockNumber = stock.F_Number;
                            }

                            //查询库存表是否存在该仓库中的产品
                            //没有
                            if (!item.IsHave)
                            {
                                //新添加一条数据 库存表
                                Sys_StockInfo entity = new Sys_StockInfo();
                                entity.F_Id = Guid.NewGuid().ToString();
                                entity.F_CargoPositionId   = item.F_CargoPositionId;
                                entity.F_CargoPositionName = item.F_CargoPositionName;
                                entity.F_WarehouseId       = item.F_WarehouseId;
                                entity.F_WarehouseName     = item.F_WarehouseName;
                                entity.F_GoodsName         = item.F_FullName;
                                entity.F_Batch             = item.F_SerialNum;
                                entity.F_GoodsId           = item.F_GoodsId;
                                entity.F_SpecifModel       = item.F_SpecifModel;
                                entity.F_SellingPrice      = item.F_SellingPrice;
                                entity.F_PurchasePrice     = item.F_PurchasePrice;
                                entity.F_Unit   = item.F_Unit;
                                entity.F_Number = item.F_InStockNum;
                                Sys_Stock.Instance.Insert(entity, dbtran.Transaction);

                                //更新审核状态
                                string    sql  = string.Format("update PI_Head set F_Status=1,F_VeriDate='{0}',F_Verify='{1}' where F_Id='{2}'", date, user, Id);
                                Hashtable hash = new Hashtable();
                                base.ExecuteNonQuery(sql, hash, dbtran.Transaction);

                                //添加入库履历 入库履历
                                Sys_InRecordsInfo inRec = new Sys_InRecordsInfo();
                                inRec.F_Id                = Guid.NewGuid().ToString();
                                inRec.F_WarehouseId       = item.F_WarehouseId;
                                inRec.F_Vendor            = hinfo.F_Vendor;
                                inRec.F_VendorName        = hinfo.F_VendorName;
                                inRec.F_Contacts          = hinfo.F_Contacts;
                                inRec.F_TelePhone         = hinfo.F_TelePhone;
                                inRec.F_Verify            = user;
                                inRec.F_Maker             = hinfo.F_Maker;
                                inRec.F_VeriDate          = DateTime.Now;
                                inRec.F_EnCode            = item.F_OrderNo;
                                inRec.F_Batch             = item.F_SerialNum;
                                inRec.F_WarehouseName     = item.F_WarehouseName;
                                inRec.F_GoodsName         = item.F_FullName;
                                inRec.F_GoodsId           = item.F_GoodsId;
                                inRec.F_CargoPositionId   = item.F_CargoPositionId;
                                inRec.F_CargoPositionName = item.F_CargoPositionName;
                                inRec.F_SpecifModel       = item.F_SpecifModel;
                                inRec.F_SellingPrice      = item.F_SellingPrice;
                                inRec.F_PurchasePrice     = item.F_PurchasePrice;
                                inRec.F_Unit              = item.F_Unit;
                                inRec.F_InStockNum        = item.F_InStockNum;
                                inRec.F_CreatorTime       = DateTime.Now;
                                Sys_InRecords.Instance.Insert(inRec, dbtran.Transaction);



                                //添加  库存履历
                                Sys_StockHistoryInfo instock = new Sys_StockHistoryInfo();
                                instock.F_Id                = Guid.NewGuid().ToString();
                                instock.F_WarehouseId       = item.F_WarehouseId;
                                instock.F_Vendor            = hinfo.F_Vendor;
                                instock.F_VendorName        = hinfo.F_VendorName;
                                instock.F_Contacts          = hinfo.F_Contacts;
                                instock.F_TelePhone         = hinfo.F_TelePhone;
                                instock.F_Verify            = user;
                                instock.F_Maker             = hinfo.F_Maker;
                                instock.F_VeriDate          = DateTime.Now;
                                instock.F_EnCode            = item.F_OrderNo;
                                instock.F_Batch             = item.F_SerialNum;
                                instock.F_WarehouseName     = item.F_WarehouseName;
                                instock.F_BllCategory       = "入库";
                                instock.F_GoodsName         = item.F_FullName;
                                instock.F_GoodsId           = item.F_GoodsId;
                                instock.F_CargoPositionId   = item.F_CargoPositionId;
                                instock.F_CargoPositionName = item.F_CargoPositionName;
                                instock.F_SpecifModel       = item.F_SpecifModel;
                                instock.F_SellingPrice      = item.F_SellingPrice;
                                instock.F_PurchasePrice     = item.F_PurchasePrice;
                                instock.F_Unit              = item.F_Unit;
                                instock.F_OperationNum      = item.F_InStockNum;
                                instock.F_CreatorTime       = DateTime.Now;
                                Sys_StockHistory.Instance.Insert(instock, dbtran.Transaction);



                                //更新子表入库状态
                                hash = new Hashtable();
                                hash.Add("F_AlreadyOperatedNum", 1);
                                PI_Body.Instance.Update(item.F_Id, hash, dbtran.Transaction);

                                //更新主表入库状态
                                hash = new Hashtable();
                                hash.Add("F_State", 1);
                                PI_Head.Instance.Update(item.F_HId, hash, dbtran.Transaction);
                            }
                            else
                            {
                                //更新前库存数量
                                Hashtable hash = new Hashtable();
                                hash.Add("F_Number", item.StockNumber + item.F_InStockNum);
                                Sys_Stock.Instance.Update(item.StockID, hash, dbtran.Transaction);
                                for (int i = 0; i < stockinfo.Count; i++)
                                {
                                    if (stockinfo[i].StockID == item.StockID)
                                    {
                                        stockinfo[i].StockNumber += item.F_InStockNum;
                                    }
                                }

                                //更新审核状态
                                string sql = string.Format("update PI_Head set F_Status=1,F_VeriDate='{0}',F_Verify='{1}' where F_Id='{2}'", date, user, Id);
                                hash = new Hashtable();
                                base.ExecuteNonQuery(sql, hash, dbtran.Transaction);

                                //更新子表入库状态
                                hash = new Hashtable();
                                hash.Add("F_AlreadyOperatedNum", 1);
                                PI_Body.Instance.Update(item.F_Id, hash, dbtran.Transaction);

                                //更新主表入库状态
                                hash = new Hashtable();
                                hash.Add("F_State", 1);
                                PI_Head.Instance.Update(item.F_HId, hash, dbtran.Transaction);


                                //添加履历
                                Sys_InRecordsInfo inRec = new Sys_InRecordsInfo();
                                inRec.F_Id                = Guid.NewGuid().ToString();
                                inRec.F_WarehouseId       = item.F_WarehouseId;
                                inRec.F_EnCode            = item.F_OrderNo;
                                inRec.F_Batch             = item.F_SerialNum;
                                inRec.F_Vendor            = hinfo.F_Vendor;
                                inRec.F_VendorName        = hinfo.F_VendorName;
                                inRec.F_Contacts          = hinfo.F_Contacts;
                                inRec.F_TelePhone         = hinfo.F_TelePhone;
                                inRec.F_Verify            = user;
                                inRec.F_Maker             = hinfo.F_Maker;
                                inRec.F_VeriDate          = DateTime.Now;
                                inRec.F_WarehouseName     = item.F_WarehouseName;
                                inRec.F_GoodsName         = item.F_FullName;
                                inRec.F_GoodsId           = item.F_GoodsId;
                                inRec.F_CargoPositionId   = item.F_CargoPositionId;
                                inRec.F_CargoPositionName = item.F_CargoPositionName;
                                inRec.F_SpecifModel       = item.F_SpecifModel;
                                inRec.F_SellingPrice      = item.F_SellingPrice;
                                inRec.F_PurchasePrice     = item.F_PurchasePrice;
                                inRec.F_Unit              = item.F_Unit;
                                inRec.F_InStockNum        = item.F_InStockNum;
                                inRec.F_CreatorTime       = DateTime.Now;
                                Sys_InRecords.Instance.Insert(inRec, dbtran.Transaction);

                                //添加库存履历
                                Sys_StockHistoryInfo instock = new Sys_StockHistoryInfo();
                                instock.F_Id                = Guid.NewGuid().ToString();
                                instock.F_WarehouseId       = item.F_WarehouseId;
                                instock.F_EnCode            = item.F_OrderNo;
                                instock.F_Batch             = item.F_SerialNum;
                                instock.F_Vendor            = hinfo.F_Vendor;
                                instock.F_VendorName        = hinfo.F_VendorName;
                                instock.F_Contacts          = hinfo.F_Contacts;
                                instock.F_TelePhone         = hinfo.F_TelePhone;
                                instock.F_Verify            = user;
                                instock.F_Maker             = hinfo.F_Maker;
                                instock.F_VeriDate          = DateTime.Now;
                                instock.F_WarehouseName     = item.F_WarehouseName;
                                instock.F_BllCategory       = "入库";
                                instock.F_GoodsName         = item.F_FullName;
                                instock.F_GoodsId           = item.F_GoodsId;
                                instock.F_CargoPositionId   = item.F_CargoPositionId;
                                instock.F_CargoPositionName = item.F_CargoPositionName;
                                instock.F_SpecifModel       = item.F_SpecifModel;
                                instock.F_SellingPrice      = item.F_SellingPrice;
                                instock.F_PurchasePrice     = item.F_PurchasePrice;
                                instock.F_Unit              = item.F_Unit;
                                instock.F_OperationNum      = item.F_InStockNum;
                                instock.F_CreatorTime       = DateTime.Now;
                                Sys_StockHistory.Instance.Insert(instock, dbtran.Transaction);
                            }
                        }
                        dbtran.Commit();
                        return("单据审核成功");
                    }
                    catch (Exception ex)
                    {
                        dbtran.RollBack();
                        return("操作失败");

                        throw ex;
                    }
                }
            }
        }