Exemplo n.º 1
0
        public override IModel CreateModel(SqlDataReader dr)
        {
            FinanceInvoice financeinvoice = new FinanceInvoice();

            int indexFinanceInvoiceId = dr.GetOrdinal("FinanceInvoiceId");
            financeinvoice.FinanceInvoiceId = Convert.ToInt32(dr[indexFinanceInvoiceId]);

            int indexInvoiceId = dr.GetOrdinal("InvoiceId");
            if (dr["InvoiceId"] != DBNull.Value)
            {
                financeinvoice.InvoiceId = Convert.ToInt32(dr[indexInvoiceId]);
            }

            int indexAssetId = dr.GetOrdinal("AssetId");
            if (dr["AssetId"] != DBNull.Value)
            {
                financeinvoice.AssetId = Convert.ToInt32(dr[indexAssetId]);
            }

            int indexIntegerAmount = dr.GetOrdinal("IntegerAmount");
            if (dr["IntegerAmount"] != DBNull.Value)
            {
                financeinvoice.IntegerAmount = Convert.ToDecimal(dr[indexIntegerAmount]);
            }

            int indexNetAmount = dr.GetOrdinal("NetAmount");
            if (dr["NetAmount"] != DBNull.Value)
            {
                financeinvoice.NetAmount = Convert.ToDecimal(dr[indexNetAmount]);
            }

            int indexMUId = dr.GetOrdinal("MUId");
            if (dr["MUId"] != DBNull.Value)
            {
                financeinvoice.MUId = Convert.ToInt32(dr[indexMUId]);
            }

            int indexVATRatio = dr.GetOrdinal("VATRatio");
            if (dr["VATRatio"] != DBNull.Value)
            {
                financeinvoice.VATRatio = Convert.ToDecimal(dr[indexVATRatio]);
            }

            int indexVATBala = dr.GetOrdinal("VATBala");
            if (dr["VATBala"] != DBNull.Value)
            {
                financeinvoice.VATBala = Convert.ToDecimal(dr[indexVATBala]);
            }

            return financeinvoice;
        }
Exemplo n.º 2
0
        public ResultModel GetByInvoiceId(UserModel user, int invoiceId)
        {
            ResultModel result = new ResultModel();

            if (invoiceId < 1)
            {
                result.Message = "序号不能小于1";
                return result;
            }

            List<SqlParameter> paras = new List<SqlParameter>();
            SqlParameter para = new SqlParameter("@invoiceId", SqlDbType.Int, 4);
            para.Value = invoiceId;
            paras.Add(para);

            SqlDataReader dr = null;

            try
            {
                string cmdText = "select * from dbo.Inv_FinanceInvoice where InvoiceId=@invoiceId";
                dr = SqlHelper.ExecuteReader(ConnectString, CommandType.Text, cmdText, paras.ToArray());

                FinanceInvoice financeinvoice = new FinanceInvoice();

                if (dr.Read())
                {
                    int indexFinanceInvoiceId = dr.GetOrdinal("FinanceInvoiceId");
                    financeinvoice.FinanceInvoiceId = Convert.ToInt32(dr[indexFinanceInvoiceId]);

                    int indexInvoiceId = dr.GetOrdinal("InvoiceId");
                    if (dr["InvoiceId"] != DBNull.Value)
                    {
                        financeinvoice.InvoiceId = Convert.ToInt32(dr[indexInvoiceId]);
                    }

                    int indexAssetId = dr.GetOrdinal("AssetId");
                    if (dr["AssetId"] != DBNull.Value)
                    {
                        financeinvoice.AssetId = Convert.ToInt32(dr[indexAssetId]);
                    }

                    int indexIntegerAmount = dr.GetOrdinal("IntegerAmount");
                    if (dr["IntegerAmount"] != DBNull.Value)
                    {
                        financeinvoice.IntegerAmount = Convert.ToDecimal(dr[indexIntegerAmount]);
                    }

                    int indexNetAmount = dr.GetOrdinal("NetAmount");
                    if (dr["NetAmount"] != DBNull.Value)
                    {
                        financeinvoice.NetAmount = Convert.ToDecimal(dr[indexNetAmount]);
                    }

                    int indexMUId = dr.GetOrdinal("MUId");
                    if (dr["MUId"] != DBNull.Value)
                    {
                        financeinvoice.MUId = Convert.ToInt32(dr[indexMUId]);
                    }

                    int indexVATRatio = dr.GetOrdinal("VATRatio");
                    if (dr["VATRatio"] != DBNull.Value)
                    {
                        financeinvoice.VATRatio = Convert.ToDecimal(dr[indexVATRatio]);
                    }

                    int indexVATBala = dr.GetOrdinal("VATBala");
                    if (dr["VATBala"] != DBNull.Value)
                    {
                        financeinvoice.VATBala = Convert.ToDecimal(dr[indexVATBala]);
                    }

                    result.AffectCount = 1;
                    result.Message = "读取成功";
                    result.ResultStatus = 0;
                    result.ReturnValue = financeinvoice;
                }
                else
                {
                    result.Message = "读取失败或无数据";
                    result.AffectCount = 0;
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            finally
            {
                if (dr != null)
                    dr.Dispose();
            }
            return result;
        }
Exemplo n.º 3
0
        public ResultModel Update(UserModel user, Operate.Model.Invoice invoice, FinanceInvoice fundsInvoice,string bids)
        {
            ResultModel result = new ResultModel();

            try
            {
                FinanceInvoiceDAL fundsInvoiceDAL = new FinanceInvoiceDAL();
                InvoiceDAL invoiceDAL = new InvoiceDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {

                    //获取财务发票
                    result = fundsInvoiceDAL.Get(user, fundsInvoice.FinanceInvoiceId);
                    if (result.ResultStatus != 0)
                        return result;

                    FinanceInvoice resultFundsInvoice = result.ReturnValue as FinanceInvoice;
                    if (resultFundsInvoice == null || resultFundsInvoice.FinanceInvoiceId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "财务发票获取失败";
                        return result;
                    }

                    //更新财务发票
                    resultFundsInvoice.AssetId = fundsInvoice.AssetId;
                    resultFundsInvoice.IntegerAmount = fundsInvoice.IntegerAmount;
                    resultFundsInvoice.NetAmount = fundsInvoice.NetAmount;
                    resultFundsInvoice.MUId = fundsInvoice.MUId;
                    resultFundsInvoice.VATRatio = fundsInvoice.VATRatio;
                    resultFundsInvoice.VATBala = fundsInvoice.VATBala;

                    result = fundsInvoiceDAL.Update(user, resultFundsInvoice);
                    if (result.ResultStatus != 0)
                        return result;

                    //获取发票
                    result = invoiceDAL.Get(user, resultFundsInvoice.InvoiceId);
                    if (result.ResultStatus != 0)
                        return result;
                    Operate.Model.Invoice resultInvoice = result.ReturnValue as Operate.Model.Invoice;
                    if (resultInvoice == null || resultInvoice.InvoiceId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "发票信息获取失败";
                        return result;
                    }

                    resultInvoice.InvoiceDate = invoice.InvoiceDate;
                    resultInvoice.InvoiceName = invoice.InvoiceName;
                    resultInvoice.InvoiceBala = invoice.InvoiceBala;
                    resultInvoice.CurrencyId = invoice.CurrencyId;
                    resultInvoice.OutCorpId = invoice.OutCorpId;

                    Corporation outCorp = UserProvider.Corporations.FirstOrDefault(temp => temp.CorpId == invoice.OutCorpId);
                    if (outCorp == null || outCorp.CorpId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "开票公司信息错误";
                        return result;
                    }
                    resultInvoice.OutCorpName = outCorp.CorpName;

                    resultInvoice.InCorpId = invoice.InCorpId;
                    Corporation inCorp = UserProvider.Corporations.FirstOrDefault(temp => temp.CorpId == invoice.InCorpId);
                    if (inCorp == null || inCorp.CorpId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "收票公司信息错误";
                        return result;
                    }
                    resultInvoice.InCorpName = inCorp.CorpName;
                    resultInvoice.Memo = invoice.Memo;

                    result = invoiceDAL.Update(user, resultInvoice);
                    if (result.ResultStatus != 0)
                        return result;

                    if (!string.IsNullOrEmpty(bids))
                    {
                        FinBusInvAllotDAL finBusInvAllotDAL = new FinBusInvAllotDAL();
                        FinBusInvAllotDetailDAL finBusInvAllotDetailDAL = new FinBusInvAllotDetailDAL();
                        result = finBusInvAllotDetailDAL.GetAllotIdByFid(user, fundsInvoice.FinanceInvoiceId);
                        if (result.ResultStatus != 0)
                            return result;

                        int allotId = (int)result.ReturnValue;

                        result = finBusInvAllotDAL.Get(user, allotId);
                        if (result.ResultStatus != 0)
                            return result;

                        FinBusInvAllot finBusInvAllot = result.ReturnValue as FinBusInvAllot;
                        finBusInvAllot.AllotBala = invoice.InvoiceBala;

                        result = finBusInvAllotDAL.Update(user, finBusInvAllot);
                        if (result.ResultStatus != 0)
                            return result;

                        result = finBusInvAllotDetailDAL.InvalidAll(user, allotId);
                        if (result.ResultStatus != 0)
                            return result;

                        foreach (string businessInvoiceId in bids.Split(','))
                        {
                            result = invoiceDAL.GetByBussinessInvoiceId(user, Convert.ToInt32(businessInvoiceId));
                            if (result.ResultStatus != 0)
                                return result;

                            Operate.Model.Invoice busInvoice = result.ReturnValue as Operate.Model.Invoice;

                            result = finBusInvAllotDetailDAL.Insert(user, new FinBusInvAllotDetail()
                            {
                                AllotId = allotId,
                                BusinessInvoiceId = Convert.ToInt32(businessInvoiceId),
                                FinanceInvoiceId = fundsInvoice.FinanceInvoiceId,
                                AllotBala = busInvoice.InvoiceBala,
                                DetailStatus = StatusEnum.已生效
                            });
                            if (result.ResultStatus != 0)
                                return result;
                        }

                    }

                    if (result.ResultStatus == 0)
                        result.ReturnValue = invoice.InvoiceId;

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }
Exemplo n.º 4
0
        public ResultModel Update(UserModel user, Operate.Model.Invoice invoice, FinanceInvoice fundsInvoice)
        {
            ResultModel result = new ResultModel();

            try
            {
                FinanceInvoiceDAL fundsInvoiceDAL = new FinanceInvoiceDAL();
                InvoiceDAL invoiceDAL = new InvoiceDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {

                    //获取财务发票
                    result = fundsInvoiceDAL.Get(user, fundsInvoice.FinanceInvoiceId);
                    if (result.ResultStatus != 0)
                        return result;

                    FinanceInvoice resultFundsInvoice = result.ReturnValue as FinanceInvoice;
                    if (resultFundsInvoice == null || resultFundsInvoice.FinanceInvoiceId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "财务发票获取失败";
                        return result;
                    }

                    //更新财务发票
                    resultFundsInvoice.AssetId = fundsInvoice.AssetId;
                    resultFundsInvoice.IntegerAmount = fundsInvoice.IntegerAmount;
                    resultFundsInvoice.NetAmount = fundsInvoice.NetAmount;
                    resultFundsInvoice.MUId = fundsInvoice.MUId;
                    resultFundsInvoice.VATRatio = fundsInvoice.VATRatio;
                    resultFundsInvoice.VATBala = fundsInvoice.VATBala;

                    result = fundsInvoiceDAL.Update(user, resultFundsInvoice);
                    if (result.ResultStatus != 0)
                        return result;

                    //获取发票
                    result = invoiceDAL.Get(user, resultFundsInvoice.InvoiceId);
                    if (result.ResultStatus != 0)
                        return result;
                    Operate.Model.Invoice resultInvoice = result.ReturnValue as Operate.Model.Invoice;
                    if (resultInvoice == null || resultInvoice.InvoiceId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "发票信息获取失败";
                        return result;
                    }

                    resultInvoice.InvoiceDate = invoice.InvoiceDate;
                    resultInvoice.InvoiceName = invoice.InvoiceName;
                    resultInvoice.InvoiceBala = invoice.InvoiceBala;
                    resultInvoice.CurrencyId = invoice.CurrencyId;
                    resultInvoice.OutCorpId = invoice.OutCorpId;

                    Corporation outCorp = UserProvider.Corporations.FirstOrDefault(temp => temp.CorpId == invoice.OutCorpId);
                    if (outCorp == null || outCorp.CorpId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "开票公司信息错误";
                        return result;
                    }
                    resultInvoice.OutCorpName = outCorp.CorpName;

                    resultInvoice.InCorpId = invoice.InCorpId;
                    Corporation inCorp = UserProvider.Corporations.FirstOrDefault(temp => temp.CorpId == invoice.InCorpId);
                    if (inCorp == null || inCorp.CorpId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "收票公司信息错误";
                        return result;
                    }
                    resultInvoice.InCorpName = inCorp.CorpName;
                    resultInvoice.Memo = invoice.Memo;

                    result = invoiceDAL.Update(user, resultInvoice);
                    if (result.ResultStatus != 0)
                        return result;

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }
Exemplo n.º 5
0
        public ResultModel CreateByInvApply(UserModel user, Operate.Model.Invoice invoice, FinanceInvoice fundsInvoice, string bids, int invoiceApplyId)
        {
            ResultModel result = new ResultModel();

            try
            {
                FinanceInvoiceDAL fundsInvoiceDAL = new FinanceInvoiceDAL();
                InvoiceDAL invoiceDAL = new InvoiceDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //新增发票主表
                    int invoiceId = 0;

                    invoice.InvoiceType = (int)InvoiceTypeEnum.财务发票;

                    invoice.InvoiceStatus = StatusEnum.已录入;
                    Corporation outCorp = UserProvider.Corporations.FirstOrDefault(temp => temp.CorpId == invoice.OutCorpId);
                    if (outCorp == null || outCorp.CorpId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "开票公司信息错误";
                        return result;
                    }
                    invoice.OutCorpName = outCorp.CorpName;
                    //invoice.OutBlocId = outCorp.b

                    Corporation inCorp = UserProvider.Corporations.FirstOrDefault(temp => temp.CorpId == invoice.InCorpId);
                    if (inCorp == null || inCorp.CorpId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "收票公司信息错误";
                        return result;
                    }
                    invoice.InCorpName = inCorp.CorpName;

                    result = invoiceDAL.Insert(user, invoice);
                    if (result.ResultStatus != 0)
                        return result;

                    if (result.ReturnValue == null || !int.TryParse(result.ReturnValue.ToString(), out invoiceId))
                    {
                        result.ResultStatus = -1;
                        result.Message = "发票添加失败";
                        return result;
                    }

                    //新增财务发票表
                    fundsInvoice.InvoiceId = invoiceId;
                    fundsInvoice.VATRatio = fundsInvoice.VATRatio;
                    result = fundsInvoiceDAL.Insert(user, fundsInvoice);
                    if (result.ResultStatus != 0)
                        return result;

                    int financeInvoiceId = (int)result.ReturnValue;

                    //财务发票业务发票分配
                    if (!string.IsNullOrEmpty(bids))
                    {
                        FinBusInvAllotDAL finBusInvAllotDAL = new FinBusInvAllotDAL();
                        result = finBusInvAllotDAL.Insert(user, new FinBusInvAllot()
                        {
                            AllotBala = invoice.InvoiceBala,
                            CurrencyId = invoice.CurrencyId,
                            Alloter = user.EmpId,
                            AllotDate = DateTime.Now,
                            AllotStatus = StatusEnum.已生效
                        });

                        if (result.ResultStatus != 0)
                            return result;

                        int allotId = (int)result.ReturnValue;

                        FinBusInvAllotDetailDAL finBusInvAllotDetailDAL = new FinBusInvAllotDetailDAL();
                        foreach (string businessInvoiceId in bids.Split(','))
                        {
                            result = invoiceDAL.GetByBussinessInvoiceId(user, Convert.ToInt32(businessInvoiceId));
                            if (result.ResultStatus != 0)
                                return result;

                            Operate.Model.Invoice busInvoice = result.ReturnValue as Operate.Model.Invoice;

                            result = finBusInvAllotDetailDAL.Insert(user, new FinBusInvAllotDetail()
                            {
                                AllotId = allotId,
                                BusinessInvoiceId = Convert.ToInt32(businessInvoiceId),
                                FinanceInvoiceId = financeInvoiceId,
                                AllotBala = busInvoice.InvoiceBala,
                                DetailStatus = StatusEnum.已生效
                            });
                            if (result.ResultStatus != 0)
                                return result;
                        }
                    }

                    //添加开票申请与财务票关联
                    InvoiceApplyFinanceDAL invoiceApplyFinanceDAL = new InvoiceApplyFinanceDAL();
                    result = invoiceApplyFinanceDAL.Insert(user, new InvoiceApplyFinance()
                    {
                        InvoiceId = invoiceId,
                        FinanceInvoiceId = financeInvoiceId,
                        InvoiceApplyId = invoiceApplyId
                    });
                    if (result.ResultStatus != 0)
                        return result;

                    invoice.InvoiceId = invoiceId;
                    if (result.ResultStatus == 0) result.ReturnValue = invoice;

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }
Exemplo n.º 6
0
        public ResultModel Create(UserModel user, Operate.Model.Invoice invoice, FinanceInvoice fundsInvoice)
        {
            ResultModel result = new ResultModel();

            try
            {
                FinanceInvoiceDAL fundsInvoiceDAL = new FinanceInvoiceDAL();
                InvoiceDAL invoiceDAL = new InvoiceDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //新增发票主表
                    int invoiceId = 0;

                    invoice.InvoiceType = (int)InvoiceTypeEnum.财务发票;

                    invoice.InvoiceStatus = StatusEnum.已录入;
                    Corporation outCorp = UserProvider.Corporations.FirstOrDefault(temp => temp.CorpId == invoice.OutCorpId);
                    if (outCorp == null || outCorp.CorpId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "开票公司信息错误";
                        return result;
                    }
                    invoice.OutCorpName = outCorp.CorpName;
                    //invoice.OutBlocId = outCorp.b

                    Corporation inCorp = UserProvider.Corporations.FirstOrDefault(temp => temp.CorpId == invoice.InCorpId);
                    if (inCorp == null || inCorp.CorpId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "收票公司信息错误";
                        return result;
                    }
                    invoice.InCorpName = inCorp.CorpName;

                    result = invoiceDAL.Insert(user, invoice);
                    if (result.ResultStatus != 0)
                        return result;

                    if (result.ReturnValue == null || !int.TryParse(result.ReturnValue.ToString(), out invoiceId))
                    {
                        result.ResultStatus = -1;
                        result.Message = "发票添加失败";
                        return result;
                    }

                    //新增财务发票表
                    fundsInvoice.InvoiceId = invoiceId;
                    fundsInvoice.VATRatio = fundsInvoice.VATRatio;
                    result = fundsInvoiceDAL.Insert(user, fundsInvoice);
                    if (result.ResultStatus != 0)
                        return result;

                    if (result.ResultStatus == 0) result.ReturnValue = invoiceId;

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }
Exemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                VerificationUtility ver = new VerificationUtility();
                ver.JudgeOperate(this.Page, 117, new List<OperateEnum>() { OperateEnum.提交审核, OperateEnum.作废, OperateEnum.撤返, OperateEnum.执行完成, OperateEnum.执行完成撤销 });

                this.navigation1.Routes.Add("财务发票列表", "FinanceInvoiceList.aspx");
                this.navigation1.Routes.Add("财务发票明细", string.Empty);
                UserModel user = UserUtility.CurrentUser;
                ResultModel result = new ResultModel();

                int invoiceId = 0;
                if (string.IsNullOrEmpty(Request.QueryString["iid"]) || !int.TryParse(Request.QueryString["iid"], out invoiceId))
                    invoiceId = 0;

                int fundsInvoiceId = 0;
                if (invoiceId == 0 && (string.IsNullOrEmpty(Request.QueryString["id"]) || !int.TryParse(Request.QueryString["id"], out fundsInvoiceId)))
                    Response.Redirect("FinanceInvoiceList.aspx");

                //获取财务发票
                FinanceInvoiceBLL financeInvoiceBLL = new FinanceInvoiceBLL();
                if (invoiceId > 0)
                    result = financeInvoiceBLL.GetByInvoiceId(user, invoiceId);
                else
                    result = financeInvoiceBLL.Get(user, fundsInvoiceId);
                if (result.ResultStatus != 0)
                    Response.Redirect("FinanceInvoiceList.aspx");
                FinanceInvoice fundsInvoice = result.ReturnValue as FinanceInvoice;
                if (fundsInvoice == null || fundsInvoice.FinanceInvoiceId <= 0)
                    Response.Redirect("FinanceInvoiceList.aspx");

                this.curFundsInvoice = fundsInvoice;

                //获取主发票信息
                InvoiceBLL invoiceBLL = new InvoiceBLL();
                result = invoiceBLL.Get(user, fundsInvoice.InvoiceId);
                if (result.ResultStatus != 0)
                    Response.Redirect("FinanceInvoiceList.aspx");
                NFMT.Operate.Model.Invoice invoice = result.ReturnValue as NFMT.Operate.Model.Invoice;
                if (invoice == null || invoice.InvoiceId <= 0)
                    Response.Redirect("FinanceInvoiceList.aspx");

                this.curInvoice = invoice;

                FinBusInvAllotDetailBLL finBusInvAllotDetailBLL = new FinBusInvAllotDetailBLL();
                result = finBusInvAllotDetailBLL.GetBIds(user, fundsInvoice.FinanceInvoiceId);
                if (result.ResultStatus != 0)
                    Response.Redirect("FinanceInvoiceList.aspx");

                this.hidsids.Value = result.ReturnValue.ToString();

                string dirStr = "开出";
                if (invoice.InvoiceDirection == 34)
                {
                    dirStr = "收入";
                    outSelf = 0;
                    inSelf = 1;
                }
                invoiceDirection = invoice.InvoiceDirection;
                //title init
                this.titInvDate.InnerHtml = string.Format("{0}日期:", dirStr);

                JavaScriptSerializer serializer = new JavaScriptSerializer();
                string json = serializer.Serialize(invoice);
                this.hidModel.Value = json;

                //attach
                this.attach1.BusinessIdValue = this.curInvoice.InvoiceId;
            }
        }