Exemple #1
0
        void SetInfo()
        {
            InitForm();

            if (m_lnqBillInfo != null)
            {
                lbBillStatus.Text = m_serverFlow.GetNowBillStatus(m_lnqBillInfo.BillNo);

                txtBillNo.Text              = m_lnqBillInfo.BillNo;
                cmbBillType.Text            = m_lnqBillInfo.BillType;
                cmbInvoiceType.Text         = m_lnqBillInfo.InvoiceType;
                cmbTaxRate.Text             = m_lnqBillInfo.TaxRate.ToString();
                txtAccoutingDocumentNo.Text = m_lnqBillInfo.AccoutingDocumentNo;

                txtSettlementCompany.Text = UniversalFunction.GetProviderInfo(m_lnqBillInfo.SettlementCompany).供应商名称;
                txtSettlementCompany.Tag  = m_lnqBillInfo.SettlementCompany;
            }
            else
            {
                lbBillStatus.Text = CE_CommonBillStatus.新建单据.ToString();

                m_lnqBillInfo        = new Business_Settlement_ProcurementStatement();
                txtBillNo.Text       = this.FlowInfo_BillNo;
                m_lnqBillInfo.BillNo = txtBillNo.Text;
            }

            m_listViewDetail = m_serviceStatement.GetListViewDetailInfo(m_lnqBillInfo.BillNo);
            m_listInvoice    = m_serviceStatement.GetListInvoiceInfo(m_lnqBillInfo.BillNo);
            RefreshDataGridView(m_listViewDetail, m_listInvoice);
        }
Exemple #2
0
        bool 采购结算单_Form_CommonProcessSubmit(CustomFlowForm form, string advise)
        {
            try
            {
                Business_Settlement_ProcurementStatement lnqBillInfo =
                    form.ResultInfo as Business_Settlement_ProcurementStatement;

                List <Business_Settlement_ProcurementStatement_Invoice> invoiceInfo =
                    form.ResultList[0] as List <Business_Settlement_ProcurementStatement_Invoice>;
                List <View_Business_Settlement_ProcurementStatementDetail> detailInfo =
                    form.ResultList[1] as List <View_Business_Settlement_ProcurementStatementDetail>;

                this.OperationType = GeneralFunction.StringConvertToEnum <CE_FlowOperationType>(form.ResultList[2].ToString());
                this.BillNo        = lnqBillInfo.BillNo;

                switch (this.OperationType)
                {
                case CE_FlowOperationType.提交:
                    m_serviceStatement.SaveInfo(lnqBillInfo, invoiceInfo, detailInfo);
                    m_serviceStatement.OperatarUnFlowBusiness(lnqBillInfo.BillNo);
                    break;

                case CE_FlowOperationType.暂存:
                    m_serviceStatement.SaveInfo(lnqBillInfo, invoiceInfo, detailInfo);
                    break;

                case CE_FlowOperationType.回退:
                    break;

                case CE_FlowOperationType.未知:
                    break;

                default:
                    break;
                }

                if (!m_serviceStatement.IsExist(lnqBillInfo.BillNo))
                {
                    MessageDialog.ShowPromptMessage("数据为空,保存失败,如需退出,请直接X掉界面");
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
                return(false);
            }
        }
Exemple #3
0
        public override void LoadFormInfo()
        {
            try
            {
                m_billNoControl = new BillNumberControl(CE_BillTypeEnum.采购结算单.ToString(), m_serviceStatement);
                m_lnqBillInfo   = m_serviceStatement.GetSingleBillInfo(this.FlowInfo_BillNo);
                SetInfo();

                if (GlobalObject.GeneralFunction.StringConvertToEnum <CE_ProcurementStatementBillTypeEnum>(cmbBillType.Text) !=
                    CE_ProcurementStatementBillTypeEnum.零星采购加工)
                {
                    cmbTaxRate.Enabled = false;
                }
                else
                {
                    cmbTaxRate.Enabled = true;
                }

                if (GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommonBillStatus>(lbBillStatus.Text) == CE_CommonBillStatus.等待审核)
                {
                    groupBox1.Enabled = false;

                    差异说明.ReadOnly = false;
                    发票单价.ReadOnly = false;
                }

                if (GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommonBillStatus>(lbBillStatus.Text) == CE_CommonBillStatus.新建单据)
                {
                    panel1.Enabled = false;

                    差异说明.ReadOnly = false;
                    发票单价.ReadOnly = false;
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowErrorMessage(ex.Message);
            }
        }
Exemple #4
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();
            }
        }
Exemple #5
0
        /// <summary>
        /// 保存信息
        /// </summary>
        /// <param name="billInfo">单据信息</param>
        /// <param name="invoiceInfo">发票信息列表</param>
        /// <param name="detailInfo">明细信息列表</param>
        public void SaveInfo(Business_Settlement_ProcurementStatement billInfo,
                             List <Business_Settlement_ProcurementStatement_Invoice> invoiceInfo,
                             List <View_Business_Settlement_ProcurementStatementDetail> detailInfo)
        {
            DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

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

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

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

                    lnqBill.InvoiceType         = billInfo.InvoiceType;
                    lnqBill.BillType            = billInfo.BillType;
                    lnqBill.SettlementCompany   = billInfo.SettlementCompany;
                    lnqBill.TaxRate             = billInfo.TaxRate;
                    lnqBill.AccoutingDocumentNo = billInfo.AccoutingDocumentNo;
                }
                else if (varData.Count() == 0)
                {
                    ctx.Business_Settlement_ProcurementStatement.InsertOnSubmit(billInfo);
                }
                else
                {
                    throw new Exception("单据数据不唯一");
                }

                var varInvoice = from a in ctx.Business_Settlement_ProcurementStatement_Invoice
                                 where a.BillNo == billInfo.BillNo
                                 select a;

                ctx.Business_Settlement_ProcurementStatement_Invoice.DeleteAllOnSubmit(varInvoice);
                ctx.SubmitChanges();

                if (invoiceInfo != null && invoiceInfo.Count > 0)
                {
                    foreach (Business_Settlement_ProcurementStatement_Invoice item in invoiceInfo)
                    {
                        Business_Settlement_ProcurementStatement_Invoice lnqTemp = new Business_Settlement_ProcurementStatement_Invoice();

                        lnqTemp.BillNo      = billInfo.BillNo;
                        lnqTemp.InvoiceDate = item.InvoiceDate;
                        lnqTemp.InvoiceNo   = item.InvoiceNo;

                        ctx.Business_Settlement_ProcurementStatement_Invoice.InsertOnSubmit(lnqTemp);
                    }
                }

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

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

                foreach (View_Business_Settlement_ProcurementStatementDetail item in detailInfo)
                {
                    Business_Settlement_ProcurementStatementDetail lnqTemp = new Business_Settlement_ProcurementStatementDetail();

                    lnqTemp.BillNo = billInfo.BillNo;
                    lnqTemp.ConsignedProcessingMaterials = item.委托加工材料;
                    lnqTemp.ContractRequestNotes         = item.合同申请单号;
                    lnqTemp.DifferencesMean           = item.差异说明;
                    lnqTemp.GoodsCount                = item.入库数量;
                    lnqTemp.GoodsID                   = item.物品ID;
                    lnqTemp.BatchNo                   = item.批次号;
                    lnqTemp.InPutBillNo               = item.入库单号;
                    lnqTemp.InPutPrice                = item.入库金额;
                    lnqTemp.InPutUnitPrice            = item.入库单价;
                    lnqTemp.InvocieUnitPrice          = item.发票单价;
                    lnqTemp.InvoicePrice              = item.发票金额;
                    lnqTemp.SingleCommissionMaterials = item.单件委托材料;
                    lnqTemp.SingleProcessingCost      = item.单件加工费;
                    lnqTemp.TaxAmount                 = item.税额;
                    lnqTemp.TotalTaxPrice             = item.价税合计;

                    ctx.Business_Settlement_ProcurementStatementDetail.InsertOnSubmit(lnqTemp);
                }

                ctx.SubmitChanges();
                ctx.Transaction.Commit();
            }
            catch (Exception ex)
            {
                ctx.Transaction.Rollback();
                throw new Exception(ex.Message);
            }
        }
Exemple #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);
            }
        }