コード例 #1
0
        /// <summary>
        /// 赋值账务信息
        /// </summary>
        /// <param name="dataContext">数据上下文</param>
        /// <param name="bill">单据信息</param>
        /// <param name="item">明细信息</param>
        /// <returns>返回账务信息</returns>
        public S_InDepotDetailBill AssignDetailInfo(DepotManagementDataContext dataContext, S_OrdinaryInDepotBill bill,
                                                    S_OrdinaryInDepotGoodsBill item)
        {
            IPersonnelInfoServer personnelServer = ServerModuleFactory.GetServerModule <IPersonnelInfoServer>();

            S_InDepotDetailBill  detailBill     = new S_InDepotDetailBill();
            View_HR_Personnel    personnel      = UniversalFunction.GetPersonnelInfo(dataContext, bill.BuyerCode);
            View_F_GoodsPlanCost basicGoodsInfo = UniversalFunction.GetGoodsInfo(dataContext, item.GoodsID);

            detailBill.ID              = Guid.NewGuid();
            detailBill.BillTime        = (DateTime)bill.InDepotDate;
            detailBill.FillInPersonnel = personnel.姓名;
            detailBill.Department      = personnel.部门名称;
            detailBill.FactPrice       = Math.Round((item.UnitPrice * (decimal)item.Amount), 2);
            detailBill.FactUnitPrice   = item.UnitPrice;
            detailBill.GoodsID         = item.GoodsID;
            detailBill.BatchNo         = item.BatchNo;
            detailBill.InDepotBillID   = bill.Bill_ID;
            detailBill.InDepotCount    = item.Amount;
            detailBill.Price           = Math.Round((item.UnitPrice * (decimal)item.Amount), 2);
            detailBill.UnitPrice       = item.UnitPrice;
            detailBill.OperationType   = (int)GlobalObject.CE_SubsidiaryOperationType.普通入库;
            detailBill.Provider        = bill.Provider;
            detailBill.StorageID       = bill.StorageID;
            detailBill.AffrimPersonnel = UniversalFunction.GetPersonnelInfo(bill.DepotManager).姓名;
            detailBill.FillInDate      = bill.Bill_Time;

            return(detailBill);
        }
コード例 #2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0)
            {
                MessageDialog.ShowPromptMessage("请选择要修改的记录后再进行此操作");
                return;
            }
            else if (dataGridView1.SelectedRows.Count > 1)
            {
                MessageDialog.ShowPromptMessage("只能选择要修改的一条记录后再进行此操作");
                return;
            }

            if (!CheckDataItem())
            {
                return;
            }

            View_F_GoodsPlanCost planCost = GetBasicGoodsInfo(txtCode.Text, txtName.Text, txtSpec.Text, numUnitPrice.Value);

            if (planCost == null)
            {
                return;
            }

            S_OrdinaryInDepotGoodsBill      goods     = new S_OrdinaryInDepotGoodsBill();
            View_S_OrdinaryInDepotGoodsBill viewGoods = GetGoodsInfo(dataGridView1.SelectedRows[0]);

            goods.ID              = viewGoods.序号;
            goods.GoodsID         = planCost.序号;
            goods.ProviderBatchNo = txtProviderBatchNo.Text;
            goods.BatchNo         = txtProviderBatchNo.Tag.ToString();
            goods.Amount          = numGoodsAmount.Value;
            goods.UnitPrice       = numUnitPrice.Value;
            goods.Price           = Math.Round(numUnitPrice.Value * numGoodsAmount.Value, 2);
            goods.AmountInWords   = CalculateClass.GetTotalPrice(goods.Price);
            goods.TestingSingle   = lnklbSingleBill.Text;

            if (m_operateMode == CE_BusinessOperateMode.仓库核实)
            {
                goods.ShelfArea    = txtShelf.Text;
                goods.ColumnNumber = txtColumn.Text;
                goods.LayerNumber  = txtLayer.Text;
            }

            goods.Remark = txtRemark.Text;

            if (!m_goodsServer.UpdateGoods(goods, out m_queryResult, out m_error))
            {
                MessageDialog.ShowErrorMessage(m_error);
                return;
            }

            int rowIndex = dataGridView1.SelectedRows[0].Index;

            RefreshDataGridView(m_queryResult);

            PositioningRecord(rowIndex);
        }
コード例 #3
0
        /// <summary>
        /// 变更金额_普通入库单
        /// </summary>
        /// <param name="dataContxt">数据上下文</param>
        /// <param name="detailInfo">结算单明细</param>
        void ChangePrice_S_OrdinaryInDepotGoodsBill(DepotManagementDataContext dataContxt,
                                                    View_Business_Settlement_ProcurementStatementDetail detailInfo)
        {
            IOrdinaryInDepotBillServer serviceOrdinaryBill = ServerModule.ServerModuleFactory.GetServerModule <IOrdinaryInDepotBillServer>();
            string error            = "";
            var    varOrdinaryGoods = from a in dataContxt.S_OrdinaryInDepotGoodsBill
                                      where a.Bill_ID == detailInfo.入库单号 &&
                                      a.GoodsID == detailInfo.物品ID &&
                                      a.BatchNo == detailInfo.批次号
                                      select a;

            //普通入库单单价修改
            if (varOrdinaryGoods.Count() != 0)
            {
                S_OrdinaryInDepotGoodsBill lnqOrdinaryGoods = varOrdinaryGoods.Single();

                lnqOrdinaryGoods.InvoiceUnitPrice = detailInfo.发票单价;
                lnqOrdinaryGoods.InvoicePrice     = detailInfo.发票金额;

                lnqOrdinaryGoods.HavingInvoice = true;
                dataContxt.SubmitChanges();

                int intFlag = serviceOrdinaryBill.GetHavingInvoice(dataContxt, detailInfo.入库单号, out error);

                if (intFlag == 4)
                {
                    throw new Exception(error);
                }
                else
                {
                    var varOrdinaryBill = from a in dataContxt.S_OrdinaryInDepotBill
                                          where a.Bill_ID == detailInfo.入库单号
                                          select a;

                    if (varOrdinaryBill.Count() != 0)
                    {
                        S_OrdinaryInDepotBill lnqOrdinaryBill = varOrdinaryBill.Single();

                        lnqOrdinaryBill.InvoiceStatus = intFlag;
                        dataContxt.SubmitChanges();
                    }
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// 更新普通入库单物品
        /// </summary>
        /// <param name="goods">物品信息</param>
        /// <param name="returnInfo">操作完毕后查询数据库的返回结果</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>操作是否成功的标志</returns>
        public bool UpdateGoods(S_OrdinaryInDepotGoodsBill goods,
                                out IQueryable <View_S_OrdinaryInDepotGoodsBill> returnInfo, out string error)
        {
            returnInfo = null;
            error      = null;

            try
            {
                DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

                var result = from r in dataContxt.S_OrdinaryInDepotGoodsBill
                             where r.ID == goods.ID
                             select r;

                ClearNullValue(goods);

                S_OrdinaryInDepotGoodsBill updateObject = result.Single();

                updateObject.GoodsID         = goods.GoodsID;
                updateObject.Amount          = goods.Amount;
                updateObject.UnitPrice       = goods.UnitPrice;
                updateObject.Price           = goods.Price;
                updateObject.AmountInWords   = goods.AmountInWords;
                updateObject.ProviderBatchNo = goods.ProviderBatchNo;
                updateObject.BatchNo         = goods.BatchNo;
                updateObject.ShelfArea       = goods.ShelfArea;
                updateObject.ColumnNumber    = goods.ColumnNumber;
                updateObject.LayerNumber     = goods.LayerNumber;
                updateObject.Remark          = goods.Remark;
                updateObject.TestingSingle   = goods.TestingSingle;

                dataContxt.SubmitChanges();

                returnInfo = GetGoodsViewInfo(updateObject.Bill_ID);
                return(true);
            }
            catch (Exception err)
            {
                error = err.Message;
                return(false);
            }
        }
コード例 #5
0
        /// <summary>
        /// 清除NULL值
        /// </summary>
        /// <param name="goods">物品信息</param>
        private void ClearNullValue(S_OrdinaryInDepotGoodsBill goods)
        {
            if (goods.BatchNo == null)
            {
                goods.BatchNo = "";
            }

            if (goods.ShelfArea == null)
            {
                goods.ShelfArea = "";
            }

            if (goods.ColumnNumber == null)
            {
                goods.ColumnNumber = "";
            }

            if (goods.LayerNumber == null)
            {
                goods.LayerNumber = "";
            }
        }
コード例 #6
0
        /// <summary>
        /// 赋值库存信息
        /// </summary>
        /// <param name="dataContext">数据上下文</param>
        /// <param name="bill">单据信息</param>
        /// <param name="item">明细信息</param>
        /// <returns>返回库存信息</returns>
        public S_Stock AssignStockInfo(DepotManagementDataContext dataContext, S_OrdinaryInDepotBill bill,
                                       S_OrdinaryInDepotGoodsBill item)
        {
            S_Stock lnqStock = new S_Stock();

            lnqStock.GoodsID = item.GoodsID;

            lnqStock.ProviderBatchNo = item.ProviderBatchNo;
            lnqStock.BatchNo         = item.BatchNo;
            lnqStock.Provider        = bill.Provider;

            lnqStock.StorageID    = bill.StorageID;
            lnqStock.ShelfArea    = item.ShelfArea;
            lnqStock.ColumnNumber = item.ColumnNumber;
            lnqStock.LayerNumber  = item.LayerNumber;

            lnqStock.ExistCount = (decimal)item.Amount;

            lnqStock.UnitPrice = item.UnitPrice;
            lnqStock.Price     = 0;

            return(lnqStock);
        }
コード例 #7
0
        /// <summary>
        /// 添加普通入库单物品
        /// </summary>
        /// <param name="billNo">单据编号</param>
        /// <param name="goods">物品信息</param>
        /// <param name="returnInfo">操作完毕后查询数据库的返回结果</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>操作是否成功的标志</returns>
        public bool AddGoods(string billNo, S_OrdinaryInDepotGoodsBill goods,
                             out IQueryable <View_S_OrdinaryInDepotGoodsBill> returnInfo, out string error)
        {
            returnInfo = null;
            error      = null;

            DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

            try
            {
                ClearNullValue(goods);

                dataContxt.S_OrdinaryInDepotGoodsBill.InsertOnSubmit(goods);
                dataContxt.SubmitChanges();

                returnInfo = GetGoodsViewInfo(billNo);
                return(true);
            }
            catch (Exception err)
            {
                error = err.Message;
                return(false);
            }
        }
コード例 #8
0
        /// <summary>
        /// 更新出入库的金额
        /// </summary>
        /// <param name="invoiceTable">需要更新的数据集</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>更新成功True,更新失败False</returns>
        public bool UpdatePrice(DataTable invoiceTable, out string error)
        {
            error = null;

            try
            {
                DepotManagementDataContext dataContxt               = CommentParameter.DepotDataContext;
                OrdinaryInDepotBillServer  serverOrdinaryBill       = new OrdinaryInDepotBillServer();
                MaterialRejectBill         serverMaterialRejectBill = new MaterialRejectBill();
                DateTime dtStart = new DateTime();
                DateTime dtEnd   = new DateTime();

                //获得当前日期的月结起始日期与结束日期
                ServerTime.GetMonthlyBalance(ServerTime.Time, out dtStart, out dtEnd);

                for (int i = 0; i <= invoiceTable.Rows.Count - 1; i++)
                {
                    string code = invoiceTable.Rows[i]["GoodsCode"].ToString();
                    string name = invoiceTable.Rows[i]["GoodsName"].ToString();
                    string spec = invoiceTable.Rows[i]["Spec"].ToString();

                    View_F_GoodsPlanCost basicGoods = m_basicGoodsServer.GetGoodsInfo(code, name, spec, out error);

                    if (!GlobalObject.GeneralFunction.IsNullOrEmpty(error))
                    {
                        return(false);
                    }

                    #region 改变入库表的单价(普通入库或者报检入库)

                    var varCheckOutInDepot = from a in dataContxt.S_CheckOutInDepotBill
                                             where a.Bill_ID == invoiceTable.Rows[i]["Bill_ID"].ToString() &&
                                             a.GoodsID == basicGoods.序号 &&
                                             a.BatchNo == invoiceTable.Rows[i]["BatchNo"].ToString()
                                             select a;

                    //报检入库单单价修改
                    if (varCheckOutInDepot.Count() != 0)
                    {
                        S_CheckOutInDepotBill lnqCheckOutInDepotBill = varCheckOutInDepot.Single();

                        lnqCheckOutInDepotBill.UnitInvoicePrice = Convert.ToDecimal(invoiceTable.Rows[i]["UnitPrice"]);
                        lnqCheckOutInDepotBill.InvoicePrice     = Convert.ToDecimal(invoiceTable.Rows[i]["Price"]);

                        lnqCheckOutInDepotBill.HavingInvoice = true;
                        dataContxt.SubmitChanges();
                    }
                    else
                    {
                        int intGoodsID = m_basicGoodsServer.GetGoodsID(invoiceTable.Rows[i]["GoodsCode"].ToString(),
                                                                       invoiceTable.Rows[i]["GoodsName"].ToString(),
                                                                       invoiceTable.Rows[i]["Spec"].ToString());

                        var varOrdinaryGoods = from a in dataContxt.S_OrdinaryInDepotGoodsBill
                                               where a.Bill_ID == invoiceTable.Rows[i]["Bill_ID"].ToString() &&
                                               a.GoodsID == intGoodsID &&
                                               a.BatchNo == invoiceTable.Rows[i]["BatchNo"].ToString()
                                               select a;

                        //普通入库单单价修改
                        if (varOrdinaryGoods.Count() != 0)
                        {
                            S_OrdinaryInDepotGoodsBill lnqOrdinaryGoods = varOrdinaryGoods.Single();

                            lnqOrdinaryGoods.InvoiceUnitPrice = Convert.ToDecimal(invoiceTable.Rows[i]["UnitPrice"]);
                            lnqOrdinaryGoods.InvoicePrice     = Convert.ToDecimal(invoiceTable.Rows[i]["Price"]);

                            lnqOrdinaryGoods.HavingInvoice = true;
                            dataContxt.SubmitChanges();

                            int intFlag = serverOrdinaryBill.GetHavingInvoice(invoiceTable.Rows[i]["Bill_ID"].ToString(), out error);

                            if (intFlag == 4)
                            {
                                return(false);
                            }
                            else
                            {
                                var varOrdinaryBill = from a in dataContxt.S_OrdinaryInDepotBill
                                                      where a.Bill_ID == invoiceTable.Rows[i]["Bill_ID"].ToString()
                                                      select a;

                                if (varOrdinaryBill.Count() != 0)
                                {
                                    S_OrdinaryInDepotBill lnqOrdinaryBill = varOrdinaryBill.Single();

                                    lnqOrdinaryBill.InvoiceStatus = intFlag;
                                    dataContxt.SubmitChanges();
                                }
                            }
                        }//采购退货单单价修改
                        else
                        {
                            intGoodsID = m_basicGoodsServer.GetGoodsID(invoiceTable.Rows[i]["GoodsCode"].ToString(),
                                                                       invoiceTable.Rows[i]["GoodsName"].ToString(),
                                                                       invoiceTable.Rows[i]["Spec"].ToString());

                            var varRejectList = from a in dataContxt.S_MaterialListRejectBill
                                                where a.Bill_ID == invoiceTable.Rows[i]["Bill_ID"].ToString() &&
                                                a.GoodsID == intGoodsID &&
                                                a.BatchNo == invoiceTable.Rows[i]["BatchNo"].ToString()
                                                select a;

                            if (varRejectList.Count() != 0)
                            {
                                S_MaterialListRejectBill lnqMaterialList = varRejectList.Single();

                                lnqMaterialList.InvoiceUnitPrice = Convert.ToDecimal(invoiceTable.Rows[i]["UnitPrice"]);
                                lnqMaterialList.InvoicePrice     = Convert.ToDecimal(invoiceTable.Rows[i]["Price"]);

                                lnqMaterialList.HavingInvoice = true;
                                dataContxt.SubmitChanges();

                                int intFlag = serverMaterialRejectBill.SetHavingInvoiceReturn(invoiceTable.Rows[i]["Bill_ID"].ToString(), out error);

                                if (intFlag == 4)
                                {
                                    return(false);
                                }
                                else
                                {
                                    var varReject = from a in dataContxt.S_MaterialRejectBill
                                                    where a.Bill_ID == invoiceTable.Rows[i]["Bill_ID"].ToString()
                                                    select a;

                                    if (varReject.Count() != 0)
                                    {
                                        S_MaterialRejectBill lnqMaterialBill = varReject.Single();

                                        lnqMaterialBill.InvoiceFlag = intFlag;
                                        dataContxt.SubmitChanges();
                                    }
                                }
                            }
                            else
                            {
                                intGoodsID = m_basicGoodsServer.GetGoodsID(invoiceTable.Rows[i]["GoodsCode"].ToString(),
                                                                           invoiceTable.Rows[i]["GoodsName"].ToString(),
                                                                           invoiceTable.Rows[i]["Spec"].ToString());

                                var varOutsourcing = from a in dataContxt.S_CheckOutInDepotForOutsourcingBill
                                                     where a.Bill_ID == invoiceTable.Rows[i]["Bill_ID"].ToString() &&
                                                     a.GoodsID == intGoodsID &&
                                                     a.BatchNo == invoiceTable.Rows[i]["BatchNo"].ToString()
                                                     select a;

                                //委外报检入库单单价修改
                                if (varOutsourcing.Count() != 0)
                                {
                                    S_CheckOutInDepotForOutsourcingBill lnqOutsourcing = varOutsourcing.Single();

                                    lnqOutsourcing.UnitInvoicePrice = Convert.ToDecimal(invoiceTable.Rows[i]["UnitPrice"]);
                                    lnqOutsourcing.InvoicePrice     = Convert.ToDecimal(invoiceTable.Rows[i]["Price"]);

                                    lnqOutsourcing.HavingInvoice = true;
                                    dataContxt.SubmitChanges();
                                }
                            }
                        }
                    }

                    #endregion

                    #region 改变入库明细表金额
                    var varInDepotBill = from b in dataContxt.S_InDepotDetailBill
                                         where b.GoodsID == basicGoods.序号 &&
                                         b.InDepotBillID == invoiceTable.Rows[i]["Bill_ID"].ToString() &&
                                         b.BatchNo == invoiceTable.Rows[i]["BatchNo"].ToString()
                                         select b;

                    if (varInDepotBill.Count() == 1)
                    {
                        S_InDepotDetailBill lnqInDepotBill = varInDepotBill.Single();

                        lnqInDepotBill.InvoiceUnitPrice = Convert.ToDecimal(invoiceTable.Rows[i]["UnitPrice"]);
                        lnqInDepotBill.InvoicePrice     = Convert.ToDecimal(invoiceTable.Rows[i]["Price"]);

                        if (lnqInDepotBill.FactPrice != Convert.ToDecimal(invoiceTable.Rows[i]["Price"]))
                        {
                            //当查询的记录不在当月的结算日期范围内,插入红冲单据与对冲单据
                            if (lnqInDepotBill.BillTime < dtStart || lnqInDepotBill.BillTime > dtEnd)
                            {
                                var varDetail = from d in dataContxt.S_InDepotDetailBill
                                                where d.GoodsID == basicGoods.序号 &&
                                                d.InDepotBillID.Contains(invoiceTable.Rows[i]["Bill_ID"].ToString()) &&
                                                d.BatchNo == invoiceTable.Rows[i]["BatchNo"].ToString() &&
                                                d.BillTime >= dtStart && d.BillTime <= dtEnd
                                                select d;

                                //判断是否已经在当前结算日期范围内插入了红冲与对冲数据
                                if (varDetail.Count() != 0)
                                {
                                    foreach (var item in varDetail)
                                    {
                                        //针对已经插入的对冲数据进行修改
                                        if (item.InDepotBillID.Contains("(对冲单据)"))
                                        {
                                            item.FactPrice     = Convert.ToDecimal(invoiceTable.Rows[i]["Price"]);
                                            item.FactUnitPrice = Convert.ToDecimal(invoiceTable.Rows[i]["UnitPrice"]);
                                        }
                                    }
                                }//对没有插入的红冲与对冲的记录进行插入
                                else
                                {
                                    //插一条原始的负记录(红冲单据)
                                    S_InDepotDetailBill lnqOldInDepotBill = new S_InDepotDetailBill();

                                    lnqOldInDepotBill.ID              = Guid.NewGuid();
                                    lnqOldInDepotBill.InDepotBillID   = lnqInDepotBill.InDepotBillID + "(红冲单据)";
                                    lnqOldInDepotBill.BatchNo         = lnqInDepotBill.BatchNo;
                                    lnqOldInDepotBill.BillTime        = ServerTime.Time;
                                    lnqOldInDepotBill.Department      = lnqInDepotBill.Department;
                                    lnqOldInDepotBill.FactUnitPrice   = lnqInDepotBill.FactUnitPrice;
                                    lnqOldInDepotBill.FactPrice       = -lnqInDepotBill.FactPrice;
                                    lnqOldInDepotBill.FillInPersonnel = lnqInDepotBill.FillInPersonnel;
                                    lnqOldInDepotBill.GoodsID         = lnqInDepotBill.GoodsID;
                                    lnqOldInDepotBill.InDepotCount    = -lnqInDepotBill.InDepotCount;
                                    lnqOldInDepotBill.Price           = -lnqInDepotBill.Price;
                                    lnqOldInDepotBill.OperationType   = (int)GlobalObject.CE_SubsidiaryOperationType.财务红冲;
                                    lnqOldInDepotBill.Provider        = lnqInDepotBill.Provider;
                                    lnqOldInDepotBill.Remark          = lnqInDepotBill.Remark;
                                    lnqOldInDepotBill.StorageID       = lnqInDepotBill.StorageID;
                                    lnqOldInDepotBill.UnitPrice       = lnqInDepotBill.UnitPrice;
                                    lnqOldInDepotBill.FillInDate      = lnqInDepotBill.FillInDate;
                                    lnqOldInDepotBill.AffrimPersonnel = lnqInDepotBill.AffrimPersonnel;

                                    IFinancialDetailManagement serverDetail =
                                        ServerModule.ServerModuleFactory.GetServerModule <IFinancialDetailManagement>();
                                    serverDetail.ProcessInDepotDetail(dataContxt, lnqOldInDepotBill, null);

                                    //插一条新的正记录(对冲单据)
                                    S_InDepotDetailBill lnqNewInDepotBill = new S_InDepotDetailBill();

                                    lnqNewInDepotBill.ID              = Guid.NewGuid();
                                    lnqNewInDepotBill.InDepotBillID   = lnqInDepotBill.InDepotBillID + "(对冲单据)";
                                    lnqNewInDepotBill.BatchNo         = lnqInDepotBill.BatchNo;
                                    lnqNewInDepotBill.BillTime        = ServerTime.Time;
                                    lnqNewInDepotBill.Department      = lnqInDepotBill.Department;
                                    lnqNewInDepotBill.FactUnitPrice   = Convert.ToDecimal(invoiceTable.Rows[i]["UnitPrice"]);
                                    lnqNewInDepotBill.FactPrice       = Convert.ToDecimal(invoiceTable.Rows[i]["Price"]);
                                    lnqNewInDepotBill.FillInPersonnel = lnqInDepotBill.FillInPersonnel;
                                    lnqNewInDepotBill.GoodsID         = lnqInDepotBill.GoodsID;
                                    lnqNewInDepotBill.InDepotCount    = lnqInDepotBill.InDepotCount;
                                    lnqNewInDepotBill.Price           = lnqInDepotBill.Price;
                                    lnqNewInDepotBill.OperationType   = (int)GlobalObject.CE_SubsidiaryOperationType.财务对冲;
                                    lnqNewInDepotBill.Provider        = lnqInDepotBill.Provider;
                                    lnqNewInDepotBill.Remark          = lnqInDepotBill.Remark;
                                    lnqNewInDepotBill.StorageID       = lnqInDepotBill.StorageID;
                                    lnqNewInDepotBill.UnitPrice       = lnqInDepotBill.UnitPrice;
                                    lnqNewInDepotBill.FillInDate      = lnqInDepotBill.FillInDate;
                                    lnqNewInDepotBill.AffrimPersonnel = lnqInDepotBill.AffrimPersonnel;

                                    serverDetail.ProcessInDepotDetail(dataContxt, lnqNewInDepotBill, null);
                                }
                            }
                            else
                            {
                                lnqInDepotBill.FactPrice     = Convert.ToDecimal(invoiceTable.Rows[i]["Price"]);
                                lnqInDepotBill.FactUnitPrice = Convert.ToDecimal(invoiceTable.Rows[i]["UnitPrice"]);
                            }
                        }

                        dataContxt.SubmitChanges();
                    }
                    #endregion
                }

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
コード例 #9
0
        /// <summary>
        /// 删除发票记录
        /// </summary>
        /// <param name="invoiceCode">发票号</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>删除成功返回True,删除失败返回False</returns>
        public bool DeleteInvoiceInfo(string invoiceCode, out string error)
        {
            error = null;

            string str   = "0";
            int    count = 0;

            try
            {
                DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

                OrdinaryInDepotBillServer serverOrdinaryBill = new OrdinaryInDepotBillServer();

                MaterialRejectBill serverMaterialRejectBill = new MaterialRejectBill();

                string strSql = "select * from B_Invoice where InvoiceCode = '" + invoiceCode + "'";

                DataTable dtInvoice = GlobalObject.DatabaseServer.QueryInfo(strSql);

                for (int i = 0; i <= dtInvoice.Rows.Count - 1; i++)
                {
                    count = i;

                    decimal dcOldUnitPrice = 0;

                    if (!GlobalObject.GeneralFunction.IsNullOrEmpty(error))
                    {
                        return(false);
                    }

                    str = "1";

                    #region 改变入库表的单价(普通入库或者报检入库)

                    var varCheckOutInDepot = from a in dataContxt.S_CheckOutInDepotBill
                                             where a.Bill_ID == dtInvoice.Rows[i]["Bill_ID"].ToString() &&
                                             a.GoodsID == Convert.ToInt32(dtInvoice.Rows[i]["GoodsID"].ToString()) &&
                                             a.BatchNo == dtInvoice.Rows[i]["BatchNo"].ToString()
                                             select a;

                    if (varCheckOutInDepot.Count() != 0)
                    {
                        S_CheckOutInDepotBill lnqCheckOutInDepot = varCheckOutInDepot.Single();

                        lnqCheckOutInDepot.UnitInvoicePrice = 0;
                        lnqCheckOutInDepot.InvoicePrice     = 0;
                        lnqCheckOutInDepot.HavingInvoice    = false;
                        dcOldUnitPrice = lnqCheckOutInDepot.UnitPrice;
                        dataContxt.SubmitChanges();
                    }
                    else
                    {
                        var varOrdinaryGoods = from a in dataContxt.S_OrdinaryInDepotGoodsBill
                                               where a.Bill_ID == dtInvoice.Rows[i]["Bill_ID"].ToString() &&
                                               a.GoodsID == Convert.ToInt32(dtInvoice.Rows[i]["GoodsID"].ToString()) &&
                                               a.BatchNo == dtInvoice.Rows[i]["BatchNo"].ToString()
                                               select a;

                        if (varOrdinaryGoods.Count() != 0)
                        {
                            S_OrdinaryInDepotGoodsBill lnqOrdinaryGoods = varOrdinaryGoods.Single();

                            lnqOrdinaryGoods.InvoiceUnitPrice = 0;
                            lnqOrdinaryGoods.InvoicePrice     = 0;
                            lnqOrdinaryGoods.HavingInvoice    = false;

                            dcOldUnitPrice = lnqOrdinaryGoods.UnitPrice;
                            dataContxt.SubmitChanges();

                            int intFlag = serverOrdinaryBill.GetHavingInvoice(dtInvoice.Rows[i]["Bill_ID"].ToString(), out error);

                            if (intFlag == 4)
                            {
                                return(false);
                            }
                            else
                            {
                                var varOrdinaryBill = from a in dataContxt.S_OrdinaryInDepotBill
                                                      where a.Bill_ID == dtInvoice.Rows[i]["Bill_ID"].ToString()
                                                      select a;

                                if (varOrdinaryBill.Count() != 0)
                                {
                                    S_OrdinaryInDepotBill lnqOrdinaryBill = varOrdinaryBill.Single();
                                    lnqOrdinaryBill.InvoiceStatus = intFlag;

                                    dataContxt.SubmitChanges();
                                }
                            }
                        }
                        else
                        {
                            var varRejectList = from a in dataContxt.S_MaterialListRejectBill
                                                where a.Bill_ID == dtInvoice.Rows[i]["Bill_ID"].ToString() &&
                                                a.GoodsID == Convert.ToInt32(dtInvoice.Rows[i]["GoodsID"].ToString()) &&
                                                a.BatchNo == dtInvoice.Rows[i]["BatchNo"].ToString()
                                                select a;

                            if (varRejectList.Count() != 0)
                            {
                                S_MaterialListRejectBill lnqMaterialList = varRejectList.Single();

                                lnqMaterialList.InvoiceUnitPrice = 0;
                                lnqMaterialList.InvoicePrice     = 0;
                                lnqMaterialList.HavingInvoice    = false;

                                dcOldUnitPrice = lnqMaterialList.UnitPrice;

                                dataContxt.SubmitChanges();

                                int intFlag = serverMaterialRejectBill.SetHavingInvoiceReturn(dtInvoice.Rows[i]["Bill_ID"].ToString(), out error);

                                if (intFlag == 4)
                                {
                                    return(false);
                                }
                                else
                                {
                                    var varRejectBill = from a in dataContxt.S_MaterialRejectBill
                                                        where a.Bill_ID == dtInvoice.Rows[i]["Bill_ID"].ToString()
                                                        select a;

                                    if (varRejectBill.Count() != 0)
                                    {
                                        S_MaterialRejectBill lnqMaterialBill = varRejectBill.Single();
                                        lnqMaterialBill.InvoiceFlag = intFlag;

                                        dataContxt.SubmitChanges();
                                    }
                                }
                            }
                            else
                            {
                                var varOutsourcing = from a in dataContxt.S_CheckOutInDepotForOutsourcingBill
                                                     where a.Bill_ID == dtInvoice.Rows[i]["Bill_ID"].ToString() &&
                                                     a.GoodsID == Convert.ToInt32(dtInvoice.Rows[i]["GoodsID"].ToString()) &&
                                                     a.BatchNo == dtInvoice.Rows[i]["BatchNo"].ToString()
                                                     select a;

                                if (varOutsourcing.Count() != 0)
                                {
                                    S_CheckOutInDepotForOutsourcingBill lnqOutsourcing = varOutsourcing.Single();

                                    lnqOutsourcing.UnitInvoicePrice = 0;
                                    lnqOutsourcing.InvoicePrice     = 0;
                                    lnqOutsourcing.HavingInvoice    = false;
                                    dcOldUnitPrice = lnqOutsourcing.UnitPrice;

                                    dataContxt.SubmitChanges();
                                }
                            }
                        }
                    }

                    #endregion

                    str = "2";

                    #region 改变入库明细表金额

                    var varInDepotDetail = from b in dataContxt.S_InDepotDetailBill
                                           where b.GoodsID == Convert.ToInt32(dtInvoice.Rows[i]["GoodsID"].ToString()) &&
                                           b.InDepotBillID.Contains(dtInvoice.Rows[i]["Bill_ID"].ToString()) &&
                                           b.BatchNo == dtInvoice.Rows[i]["BatchNo"].ToString()
                                           select b;

                    if (varInDepotDetail.Count() != 0)
                    {
                        if (varInDepotDetail.Count() == 1)
                        {
                            S_InDepotDetailBill lnqInDepotDetailSingle = varInDepotDetail.Single();

                            lnqInDepotDetailSingle.InvoiceUnitPrice = 0;
                            lnqInDepotDetailSingle.InvoicePrice     = 0;
                            lnqInDepotDetailSingle.FactUnitPrice    = dcOldUnitPrice;
                            lnqInDepotDetailSingle.FactPrice        = Math.Round(dcOldUnitPrice * Convert.ToDecimal(lnqInDepotDetailSingle.InDepotCount), 2);
                        }
                        else
                        {
                            var varInDepotDetailList = from a in varInDepotDetail
                                                       where a.InDepotBillID == dtInvoice.Rows[i]["Bill_ID"].ToString()
                                                       select a;

                            S_InDepotDetailBill lnqInDepotDetailData = varInDepotDetailList.Single();

                            lnqInDepotDetailData.InvoiceUnitPrice = 0;
                            lnqInDepotDetailData.InvoicePrice     = 0;
                            lnqInDepotDetailData.FactUnitPrice    = dcOldUnitPrice;
                            lnqInDepotDetailData.FactPrice        = Math.Round(dcOldUnitPrice
                                                                               * Convert.ToDecimal(lnqInDepotDetailData.InDepotCount), 2);

                            var varData7 = from a in varInDepotDetail
                                           where a.InDepotBillID != dtInvoice.Rows[i]["Bill_ID"].ToString()
                                           select a;

                            dataContxt.S_InDepotDetailBill.DeleteAllOnSubmit(varData7);
                        }

                        dataContxt.SubmitChanges();
                    }
                    #endregion
                }

                var varInvoice = from a in dataContxt.B_Invoice
                                 where a.InvoiceCode == invoiceCode
                                 select a;

                if (varInvoice.Count() > 0)
                {
                    dataContxt.B_Invoice.DeleteAllOnSubmit(varInvoice);
                    dataContxt.SubmitChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message + str + count.ToString();
                return(false);
            }
        }
コード例 #10
0
        private void btnAutoGenerate_Click(object sender, EventArgs e)
        {
            if (dataGridView1.Rows.Count > 0)
            {
                MessageDialog.ShowPromptMessage("请删除此清单中的所有物品后再进行此操作!");
                return;
            }

            IOrderFormGoodsServer orderFormGoodsServer    = ServerModuleFactory.GetServerModule <IOrderFormGoodsServer>();
            IQueryable <View_B_OrderFormGoods> goodsGroup = null;

            if (!orderFormGoodsServer.GetOrderFormGoods(
                    BasicInfo.ListRoles, BasicInfo.LoginID, m_billInfo.OrderBill_ID, out goodsGroup, out m_error))
            {
                MessageDialog.ShowErrorMessage(m_error);
                return;
            }

            S_OrdinaryInDepotBill lnqBill          = m_serverBill.GetBill(m_billNo);
            IOrderFormInfoServer  serviceOrderForm = ServerModuleFactory.GetServerModule <IOrderFormInfoServer>();
            View_B_OrderFormInfo  orderInfo        = serviceOrderForm.GetOrderFormInfo(m_billInfo.OrderBill_ID);

            foreach (var item in goodsGroup)
            {
                if (item.订货数量 == 0)
                {
                    continue;
                }

                S_OrdinaryInDepotGoodsBill goods    = new S_OrdinaryInDepotGoodsBill();
                View_F_GoodsPlanCost       planCost = GetBasicGoodsInfo(item.图号型号, item.物品名称, item.规格, 0);

                if (planCost == null)
                {
                    return;
                }

                goods.GoodsID         = planCost.序号;
                goods.Bill_ID         = m_billNo;
                goods.ProviderBatchNo = "";

                if (m_serverGoodsShelfLife.IsShelfLife(planCost.序号))
                {
                    goods.BatchNo = m_goodsServer.GetNewBatchNo();
                }
                else
                {
                    goods.BatchNo = "";
                }

                goods.Amount = item.订货数量;

                IBargainGoodsServer serviceBargainGoods = ServerModuleFactory.GetServerModule <IBargainGoodsServer>();

                goods.UnitPrice     = serviceBargainGoods.GetGoodsUnitPrice(orderInfo.订单号, goods.GoodsID, orderInfo.供货单位);
                goods.Price         = decimal.Round(goods.UnitPrice * item.订货数量, (int)2);
                goods.AmountInWords = CalculateClass.GetTotalPrice(goods.Price);
                goods.Remark        = txtRemark.Text;

                if (!m_goodsServer.AddGoods(m_billNo, goods, out m_queryResult, out m_error))
                {
                    MessageDialog.ShowErrorMessage(m_error);
                    return;
                }
            }

            btnRefresh_Click(sender, e);
        }
コード例 #11
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!CheckDataItem())
            {
                return;
            }

            S_OrdinaryInDepotBill      lnqBill  = m_serverBill.GetBill(m_billNo);
            S_OrdinaryInDepotGoodsBill goods    = new S_OrdinaryInDepotGoodsBill();
            View_F_GoodsPlanCost       planCost = GetBasicGoodsInfo(txtCode.Text, txtName.Text, txtSpec.Text, numUnitPrice.Value);

            if (planCost == null)
            {
                return;
            }

            goods.Bill_ID         = m_billNo;
            goods.ProviderBatchNo = txtProviderBatchNo.Text;

            if (m_serverGoodsShelfLife.IsShelfLife(planCost.序号))
            {
                goods.BatchNo = m_goodsServer.GetNewBatchNo();
            }
            else
            {
                goods.BatchNo = "";
            }

            goods.Amount        = numGoodsAmount.Value;
            goods.UnitPrice     = numUnitPrice.Value;
            goods.Price         = decimal.Round(goods.UnitPrice * numGoodsAmount.Value, 2);
            goods.AmountInWords = CalculateClass.GetTotalPrice(goods.Price);
            goods.ShelfArea     = "";
            goods.ColumnNumber  = "";
            goods.LayerNumber   = "";
            goods.Remark        = txtRemark.Text;
            goods.TestingSingle = lnklbSingleBill.Text;

            goods.GoodsID = planCost.序号;

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (row.Cells["图号型号"].Value.ToString() == txtCode.Text &&
                    row.Cells["物品名称"].Value.ToString() == txtName.Text &&
                    row.Cells["规格"].Value.ToString() == txtSpec.Text &&
                    row.Cells["供方批次号"].Value.ToString() == txtProviderBatchNo.Text)
                {
                    MessageDialog.ShowPromptMessage("已经存在相同的物品信息列不允许再进行重复添加!");
                    return;
                }
            }

            if (!m_goodsServer.AddGoods(m_billNo, goods, out m_queryResult, out m_error))
            {
                if (m_error.Contains("不能在具有唯一索引"))
                {
                    m_error = "此物品清单中的物品(同种物品、同一批号)可能已经在其他普通入库单中增加,不允许再重复入库!";
                }

                MessageDialog.ShowErrorMessage(m_error);
                return;
            }

            RefreshDataGridView(m_queryResult);
            PositioningRecord(planCost.图号型号, planCost.物品名称, planCost.规格);
        }