예제 #1
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();
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 变更金额_采购退货单
        /// </summary>
        /// <param name="dataContxt">数据上下文</param>
        /// <param name="detailInfo">结算单明细</param>
        void ChangePrice_S_MaterialRejectBill(DepotManagementDataContext dataContxt,
                                              View_Business_Settlement_ProcurementStatementDetail detailInfo)
        {
            IMaterialRejectBill serviceMaterialRejectBill = ServerModule.ServerModuleFactory.GetServerModule <IMaterialRejectBill>();
            string error         = "";
            var    varRejectList = from a in dataContxt.S_MaterialListRejectBill
                                   where a.Bill_ID == detailInfo.入库单号 &&
                                   a.GoodsID == detailInfo.物品ID &&
                                   a.BatchNo == detailInfo.批次号
                                   select a;

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

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

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

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

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

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

                        lnqMaterialBill.InvoiceFlag = intFlag;
                        dataContxt.SubmitChanges();
                    }
                }
            }
        }
예제 #3
0
        /// <summary>
        /// 变更金额_委外报检入库单
        /// </summary>
        /// <param name="dataContxt">数据上下文</param>
        /// <param name="detailInfo">结算单明细</param>
        void ChangePrice_S_CheckOutInDepotForOutsourcingBill(DepotManagementDataContext dataContxt,
                                                             View_Business_Settlement_ProcurementStatementDetail detailInfo)
        {
            var varOutsourcing = from a in dataContxt.S_CheckOutInDepotForOutsourcingBill
                                 where a.Bill_ID == detailInfo.入库单号 &&
                                 a.GoodsID == detailInfo.物品ID &&
                                 a.BatchNo == detailInfo.批次号
                                 select a;

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

                lnqOutsourcing.UnitInvoicePrice = detailInfo.发票单价 + (decimal)detailInfo.单件委托材料;
                lnqOutsourcing.InvoicePrice     = lnqOutsourcing.UnitInvoicePrice * detailInfo.入库数量;

                lnqOutsourcing.HavingInvoice = true;
                dataContxt.SubmitChanges();
            }
        }
예제 #4
0
        /// <summary>
        /// 变更金额_报检入库单
        /// </summary>
        /// <param name="dataContxt">数据上下文</param>
        /// <param name="detailInfo">结算单明细</param>
        void ChangePrice_S_CheckOutInDepotBill(DepotManagementDataContext dataContxt,
                                               View_Business_Settlement_ProcurementStatementDetail detailInfo)
        {
            var varCheckOutInDepot = from a in dataContxt.S_CheckOutInDepotBill
                                     where a.Bill_ID == detailInfo.入库单号 &&
                                     a.GoodsID == detailInfo.物品ID &&
                                     a.BatchNo == detailInfo.批次号
                                     select a;

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

                lnqCheckOutInDepotBill.UnitInvoicePrice = detailInfo.发票单价;
                lnqCheckOutInDepotBill.InvoicePrice     = detailInfo.发票金额;

                lnqCheckOutInDepotBill.HavingInvoice = true;
                dataContxt.SubmitChanges();
            }
        }
예제 #5
0
        /// <summary>
        /// 变更金额_入库明细
        /// </summary>
        /// <param name="dataContxt">数据上下文</param>
        /// <param name="detailInfo">结算单明细</param>
        void ChangePrice_S_InDepotDetailBill(DepotManagementDataContext dataContxt,
                                             View_Business_Settlement_ProcurementStatementDetail detailInfo)
        {
            DateTime dtStart = new DateTime();
            DateTime dtEnd   = new DateTime();

            Business_Settlement_ProcurementStatement statement = GetSingleBillInfo(detailInfo.单据号);

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

            var varInDepotBill = from b in dataContxt.S_InDepotDetailBill
                                 where b.GoodsID == detailInfo.物品ID &&
                                 b.InDepotBillID == detailInfo.入库单号 &&
                                 b.BatchNo == detailInfo.批次号
                                 select b;

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

                var varData1 = from a in dataContxt.BASE_Storage
                               where a.StorageID == lnqInDepotBill.StorageID
                               select a;

                if (varData1.Count() == 1)
                {
                    BASE_Storage storageInfo = varData1.Single();

                    if (!storageInfo.FinancialAccountingFlag)
                    {
                        throw new Exception("单据号【" + lnqInDepotBill.InDepotBillID + "】的入库库房不在财务核算范围之内");
                    }
                }
                else
                {
                    throw new Exception("单据号【" + lnqInDepotBill.InDepotBillID + "】的入库库房不存在或者重复");
                }

                if (statement.BillType == CE_ProcurementStatementBillTypeEnum.委托加工物资.ToString())
                {
                    lnqInDepotBill.InvoiceUnitPrice = detailInfo.发票单价 + (decimal)detailInfo.单件委托材料;
                    lnqInDepotBill.InvoicePrice     = Math.Round((decimal)lnqInDepotBill.InvoiceUnitPrice * (decimal)lnqInDepotBill.InDepotCount, 2);
                }
                else
                {
                    lnqInDepotBill.InvoiceUnitPrice = detailInfo.发票单价;
                    lnqInDepotBill.InvoicePrice     = detailInfo.发票金额;
                }

                if (lnqInDepotBill.FactPrice != detailInfo.发票金额)
                {
                    //当查询的记录不在当月的结算日期范围内,插入红冲单据与对冲单据
                    if (lnqInDepotBill.BillTime < dtStart || lnqInDepotBill.BillTime > dtEnd)
                    {
                        var varDetail = from d in dataContxt.S_InDepotDetailBill
                                        where d.GoodsID == detailInfo.物品ID &&
                                        d.InDepotBillID.Contains(detailInfo.入库单号) &&
                                        d.BatchNo == detailInfo.批次号 &&
                                        d.BillTime >= dtStart && d.BillTime <= dtEnd
                                        select d;

                        //判断是否已经在当前结算日期范围内插入了红冲与对冲数据
                        if (varDetail.Count() != 0)
                        {
                            foreach (var item in varDetail)
                            {
                                //针对已经插入的对冲数据进行修改
                                if (item.InDepotBillID.Contains("(对冲单据)"))
                                {
                                    if (statement.BillType == CE_ProcurementStatementBillTypeEnum.委托加工物资.ToString())
                                    {
                                        item.FactUnitPrice = detailInfo.发票单价 + (decimal)detailInfo.单件委托材料;
                                        item.FactPrice     = Math.Round((decimal)item.FactUnitPrice * (decimal)item.InDepotCount, 2);
                                    }
                                    else
                                    {
                                        item.FactUnitPrice = detailInfo.发票单价;
                                        item.FactPrice     = detailInfo.发票金额;
                                    }
                                }
                            }
                        }//对没有插入的红冲与对冲的记录进行插入
                        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.InDepotCount  = lnqInDepotBill.InDepotCount;

                            if (statement.BillType == CE_ProcurementStatementBillTypeEnum.委托加工物资.ToString())
                            {
                                lnqNewInDepotBill.FactUnitPrice = detailInfo.发票单价 + (decimal)detailInfo.单件委托材料;
                                lnqNewInDepotBill.FactPrice     = Math.Round((decimal)lnqNewInDepotBill.FactUnitPrice * (decimal)lnqNewInDepotBill.InDepotCount, 2);
                            }
                            else
                            {
                                lnqNewInDepotBill.FactUnitPrice = detailInfo.发票单价;
                                lnqNewInDepotBill.FactPrice     = detailInfo.发票金额;
                            }

                            lnqNewInDepotBill.FillInPersonnel = lnqInDepotBill.FillInPersonnel;
                            lnqNewInDepotBill.GoodsID         = lnqInDepotBill.GoodsID;
                            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
                    {
                        if (statement.BillType == CE_ProcurementStatementBillTypeEnum.委托加工物资.ToString())
                        {
                            lnqInDepotBill.FactUnitPrice = detailInfo.发票单价 + (decimal)detailInfo.单件委托材料;
                            lnqInDepotBill.FactPrice     = Math.Round((decimal)lnqInDepotBill.InvoiceUnitPrice * (decimal)lnqInDepotBill.InDepotCount, 2);
                        }
                        else
                        {
                            lnqInDepotBill.FactUnitPrice = detailInfo.发票单价;
                            lnqInDepotBill.FactPrice     = detailInfo.发票金额;
                        }
                    }
                }

                dataContxt.SubmitChanges();
            }
        }
예제 #6
0
        private bool customPanel1_PanelGetDataInfo(CE_FlowOperationType flowOperationType)
        {
            try
            {
                if (flowOperationType == CE_FlowOperationType.提交)
                {
                    if (!CheckData_Submit())
                    {
                        return(false);
                    }

                    if (GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommonBillStatus>(lbBillStatus.Text) == CE_CommonBillStatus.等待审核)
                    {
                        CE_ProcurementStatementBillTypeEnum billType =
                            GlobalObject.GeneralFunction.StringConvertToEnum <CE_ProcurementStatementBillTypeEnum>(cmbBillType.Text);

                        foreach (DataGridViewRow dgvr in customDataGridView1.Rows)
                        {
                            if (billType != CE_ProcurementStatementBillTypeEnum.委托加工物资)
                            {
                                if (Convert.ToDecimal(dgvr.Cells["入库金额"].Value) != Convert.ToDecimal(dgvr.Cells["发票金额"].Value) &&
                                    dgvr.Cells["差异说明"].Value.ToString().Trim().Length == 0)
                                {
                                    MessageDialog.ShowPromptMessage("入库金额与发票金额不一致的记录的差异说明不能为空");
                                    return(false);
                                }
                            }
                            else
                            {
                                decimal dcTemp = Convert.ToDecimal(dgvr.Cells["入库数量"].Value) * Convert.ToDecimal(dgvr.Cells["单件委托材料"].Value);

                                if (Convert.ToDecimal(dgvr.Cells["入库金额"].Value) != (Convert.ToDecimal(dgvr.Cells["发票金额"].Value) + dcTemp) &&
                                    dgvr.Cells["差异说明"].Value.ToString().Trim().Length == 0)
                                {
                                    MessageDialog.ShowPromptMessage("入库金额与(发票金额 + 入库数量 * 单件委托材料) 不一致的记录的差异说明不能为空");
                                    return(false);
                                }
                            }
                        }
                    }
                }
                else if (flowOperationType == CE_FlowOperationType.暂存)
                {
                    if (!CheckData_Hold())
                    {
                        return(false);
                    }
                }

                m_lnqBillInfo = new Business_Settlement_ProcurementStatement();

                m_lnqBillInfo.BillNo              = txtBillNo.Text;
                m_lnqBillInfo.BillType            = cmbBillType.Text;
                m_lnqBillInfo.InvoiceType         = cmbInvoiceType.Text;
                m_lnqBillInfo.SettlementCompany   = txtSettlementCompany.Tag.ToString();
                m_lnqBillInfo.TaxRate             = Convert.ToDecimal(cmbTaxRate.Text);
                m_lnqBillInfo.AccoutingDocumentNo = txtAccoutingDocumentNo.Text;

                List <View_Business_Settlement_ProcurementStatementDetail> listTemp = new List <View_Business_Settlement_ProcurementStatementDetail>();

                foreach (DataGridViewRow dgvr in customDataGridView1.Rows)
                {
                    View_Business_Settlement_ProcurementStatementDetail detailTemp = new View_Business_Settlement_ProcurementStatementDetail();

                    detailTemp.差异说明   = dgvr.Cells["差异说明"].Value == null ? "" : dgvr.Cells["差异说明"].Value.ToString();
                    detailTemp.零件名称   = dgvr.Cells["零件名称"].Value == null ? "" : dgvr.Cells["零件名称"].Value.ToString();
                    detailTemp.物品ID   = Convert.ToInt32(dgvr.Cells["物品ID"].Value);
                    detailTemp.零件图号   = dgvr.Cells["零件图号"].Value == null ? "" : dgvr.Cells["零件图号"].Value.ToString();
                    detailTemp.规格     = dgvr.Cells["规格"].Value == null ? "" : dgvr.Cells["规格"].Value.ToString();
                    detailTemp.单据号    = txtBillNo.Text;
                    detailTemp.批次号    = dgvr.Cells["批次号"].Value == null ? "" : dgvr.Cells["批次号"].Value.ToString();
                    detailTemp.单件加工费  = (decimal?)dgvr.Cells["单件加工费"].Value;
                    detailTemp.单件委托材料 = (decimal?)dgvr.Cells["单件委托材料"].Value;
                    detailTemp.发票单价   = Convert.ToDecimal(dgvr.Cells["发票单价"].Value);
                    detailTemp.发票金额   = Convert.ToDecimal(dgvr.Cells["发票金额"].Value);
                    detailTemp.合同申请单号 = dgvr.Cells["执行合同号_申请单"].Value == null ? "" : dgvr.Cells["执行合同号_申请单"].Value.ToString();
                    detailTemp.价税合计   = (decimal?)dgvr.Cells["价税合计"].Value;
                    detailTemp.入库单号   = dgvr.Cells["入库单号"].Value == null ? "" : dgvr.Cells["入库单号"].Value.ToString();
                    detailTemp.入库单价   = (decimal)dgvr.Cells["入库单价_不含税"].Value;
                    detailTemp.入库金额   = (decimal)dgvr.Cells["入库金额"].Value;
                    detailTemp.入库数量   = (decimal)dgvr.Cells["入库数量"].Value;
                    detailTemp.税额     = (decimal)dgvr.Cells["税额"].Value;
                    detailTemp.委托加工材料 = (decimal)dgvr.Cells["委托加工材料"].Value;

                    listTemp.Add(detailTemp);
                }

                this.FlowInfo_BillNo = txtBillNo.Text;
                this.ResultInfo      = m_lnqBillInfo;

                this.ResultList = new List <object>();

                this.ResultList.Add(m_listInvoice);
                this.ResultList.Add(listTemp);
                this.ResultList.Add(flowOperationType);
                this.KeyWords = "【供应商】:" + m_lnqBillInfo.SettlementCompany;

                return(true);
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
                return(false);
            }
        }