Exemplo n.º 1
0
        /// <summary>
        /// 保存业务信息
        /// </summary>
        /// <param name="billInfo">业务总单信息</param>
        /// <param name="detailInfo">业务明细信息</param>
        public void SaveInfo(Business_WarehouseInPut_InPut billInfo, List <View_Business_WarehouseInPut_InPutDetail> detailInfo)
        {
            DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

            ctx.Connection.Open();
            ctx.Transaction = ctx.Connection.BeginTransaction();

            try
            {
                var varData = from a in ctx.Business_WarehouseInPut_InPut
                              where a.BillNo == billInfo.BillNo
                              select a;

                if (varData.Count() == 1)
                {
                    Business_WarehouseInPut_InPut lnqBill = varData.Single();

                    lnqBill.ApplyingDepartment = billInfo.ApplyingDepartment;
                    lnqBill.BillType           = billInfo.BillType;
                    lnqBill.StorageID          = billInfo.StorageID;
                    lnqBill.Remark             = billInfo.Remark;
                    lnqBill.BillTypeDetail     = billInfo.BillTypeDetail;
                }
                else if (varData.Count() == 0)
                {
                    ctx.Business_WarehouseInPut_InPut.InsertOnSubmit(billInfo);
                }
                else
                {
                    throw new Exception("单据数据不唯一");
                }

                var varDetail = from a in ctx.Business_WarehouseInPut_InPutDetail
                                where a.BillNo == billInfo.BillNo
                                select a;

                ctx.Business_WarehouseInPut_InPutDetail.DeleteAllOnSubmit(varDetail);
                ctx.SubmitChanges();

                foreach (View_Business_WarehouseInPut_InPutDetail item in detailInfo)
                {
                    Business_WarehouseInPut_InPutDetail lnqDetail = new Business_WarehouseInPut_InPutDetail();

                    lnqDetail.BatchNo    = item.批次号;
                    lnqDetail.BillNo     = billInfo.BillNo;
                    lnqDetail.BillRelate = item.关联业务;
                    lnqDetail.GoodsCount = item.数量;
                    lnqDetail.GoodsID    = item.物品ID;
                    lnqDetail.Provider   = item.供应商;
                    lnqDetail.Remark     = item.备注;

                    if (!IsInput(lnqDetail))
                    {
                        throw new Exception(UniversalFunction.GetGoodsMessage(lnqDetail.GoodsID) + "【批次号】:"
                                            + lnqDetail.BatchNo + "【供应商】:" + lnqDetail.Provider + ",此物品无【检验报告】/【判定报告】");
                    }

                    ctx.Business_WarehouseInPut_InPutDetail.InsertOnSubmit(lnqDetail);
                }

                ctx.SubmitChanges();
                ctx.Transaction.Commit();
            }
            catch (Exception ex)
            {
                ctx.Transaction.Rollback();
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 2
0
        bool IsInput(Business_WarehouseInPut_InPutDetail detail)
        {
            string error = "";

            if (detail.GoodsCount == 0)
            {
                return(true);
            }

            DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

            Business_WarehouseInPut_RequisitionDetail requistionDetail = new Business_WarehouseInPut_RequisitionDetail();

            var varData = from a in ctx.Business_WarehouseInPut_RequisitionDetail
                          where a.BillNo == detail.BillRelate &&
                          a.GoodsID == detail.GoodsID &&
                          a.BatchNo == detail.BatchNo &&
                          a.Provider == detail.Provider
                          select a;

            if (varData.Count() == 0)
            {
                varData = from a in ctx.Business_WarehouseInPut_RequisitionDetail
                          where a.BillNo == detail.BillRelate &&
                          a.GoodsID == detail.GoodsID &&
                          a.Provider == detail.Provider
                          select a;

                if (varData.Count() == 0)
                {
                    return(false);
                }
            }

            requistionDetail = varData.First();

            if (requistionDetail.IsCheck)
            {
                //string strSql = " IF not (object_id('tempdb.dbo.#tempTable1') is null)  " +
                //                " drop table tempdb.dbo.#tempTable1;  " +
                //                " Create Table #tempTable1 (BillNo varchar(50));  " +
                //                " exec dbo.Business_GetReferenceBillNo_Backwards '判定报告','"+ requistionDetail.BillNo +"', "+
                //                requistionDetail.GoodsID +", '"+ requistionDetail.BatchNo +"', '"+ requistionDetail.Provider +"'" +
                //                " select * from tempdb.dbo.#tempTable1";

                Hashtable hsTable = new Hashtable();

                hsTable.Add("@BillType", CE_BillTypeEnum.检验报告.ToString());
                hsTable.Add("@BillNo", requistionDetail.BillNo);
                hsTable.Add("@GoodsID", requistionDetail.GoodsID);
                hsTable.Add("@BatchNo", requistionDetail.BatchNo);
                hsTable.Add("@Provider", requistionDetail.Provider);

                DataTable tempTable = GlobalObject.DatabaseServer.QueryInfoPro("Business_GetReferenceBillNo_Backwards_Incipit", hsTable, out error);

                if (tempTable == null || tempTable.Rows.Count == 0)
                {
                    hsTable = new Hashtable();

                    hsTable.Add("@BillType", CE_BillTypeEnum.判定报告.ToString());
                    hsTable.Add("@BillNo", requistionDetail.BillNo);
                    hsTable.Add("@GoodsID", requistionDetail.GoodsID);
                    hsTable.Add("@BatchNo", requistionDetail.BatchNo);
                    hsTable.Add("@Provider", requistionDetail.Provider);

                    tempTable = GlobalObject.DatabaseServer.QueryInfoPro("Business_GetReferenceBillNo_Backwards_Incipit", hsTable, out error);

                    if (tempTable == null || tempTable.Rows.Count == 0)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }