Пример #1
0
        /// <summary>
        /// 检查数据有效性
        /// </summary>
        /// <param name="invoiceChange"></param>
        /// <returns></returns>
        private int CheckData(Neusoft.HISFC.Models.Fee.InvoiceChange invoiceChange)
        {
            Neusoft.HISFC.Models.Fee.Invoice invoice = null;
            if (this.neuSpread1_Sheet1.RowCount > 0)
            {
                int row = this.neuSpread1_Sheet1.ActiveRow.Index;
                if (row >= 0)
                {
                    invoice = this.neuSpread1_Sheet1.Rows[row].Tag as Neusoft.HISFC.Models.Fee.Invoice;
                }
            }

            for (int i = 0, j = this.txtUsedNO.Text.Length; i < j; i++)
            {
                if (!char.IsDigit(this.txtUsedNO.Text, i))
                {
                    //可以说明是第几个字符错误了
                    MessageBox.Show("输入的已用发票号必须是数字", "提示", MessageBoxButtons.OK);
                    return(-1);
                }
            }

            if (Convert.ToInt64(invoiceChange.EndNO) < Convert.ToInt64(invoice.UsedNO))
            {
                MessageBox.Show("输入的已用发票号不能小于当前已用号");
                return(-1);
            }
            return(0);
        }
Пример #2
0
        /// <summary>
        /// 生成发票变更实体
        /// </summary>
        /// <returns></returns>
        private Neusoft.HISFC.Models.Fee.InvoiceChange SetInvoiceChange()
        {
            Neusoft.HISFC.Models.Fee.InvoiceChange myInvoiceChange = new Neusoft.HISFC.Models.Fee.InvoiceChange();
            Neusoft.HISFC.Models.Fee.Invoice       invoice         = null;
            long beginNO = 0;

            if (this.neuSpread1_Sheet1.RowCount > 0)
            {
                int row = this.neuSpread1_Sheet1.ActiveRow.Index;
                if (row >= 0)
                {
                    invoice = this.neuSpread1_Sheet1.Rows[row].Tag as Neusoft.HISFC.Models.Fee.Invoice;
                }
            }
            myInvoiceChange.HappenNO    = this.invoiceServiceManager.GetInvoiceChangeHappenNO(this.myOperator.ID);
            myInvoiceChange.GetOper.ID  = invoice.AcceptOper.ID;
            myInvoiceChange.InvoiceType = invoice.Type;
            beginNO = Convert.ToInt64(invoice.UsedNO) + 1;
            myInvoiceChange.BeginNO   = beginNO.ToString().PadLeft(12, '0');
            myInvoiceChange.EndNO     = this.txtUsedNO.Text.ToString().PadLeft(12, '0');
            myInvoiceChange.ShiftType = "2";
            myInvoiceChange.Oper.ID   = this.myOperator.ID;
            myInvoiceChange.Memo      = "发票跳号";
            return(myInvoiceChange);
        }
Пример #3
0
        /// <summary>
        /// 保存数据
        /// </summary>
        private int SaveInvoiceChange()
        {
            Neusoft.HISFC.Models.Fee.InvoiceChange invoiceChange = null;
            Neusoft.HISFC.Models.Fee.Invoice       invoice       = null;
            if (this.neuSpread1_Sheet1.RowCount > 0)
            {
                int row = this.neuSpread1_Sheet1.ActiveRow.Index;
                if (row >= 0)
                {
                    invoice = this.neuSpread1_Sheet1.Rows[row].Tag as Neusoft.HISFC.Models.Fee.Invoice;
                }
            }
            invoiceChange = this.SetInvoiceChange();
            if (this.CheckData(invoiceChange) < 0)
            {
                return(-1);
            }

            Neusoft.FrameWork.Management.PublicTrans.BeginTransaction();

            //Neusoft.FrameWork.Management.Transaction trans = new Neusoft.FrameWork.Management.Transaction(this.invoiceServiceManager.Connection);
            //trans.BeginTransaction();

            this.invoiceServiceManager.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans);
            int iReturn = -1;

            iReturn = this.invoiceServiceManager.InsertInvoiceChange(invoiceChange);
            if (iReturn < 0)
            {
                MessageBox.Show("插入发票变更表失败!" + this.invoiceServiceManager.Err);
                Neusoft.FrameWork.Management.PublicTrans.RollBack();
                return(-1);
            }
            iReturn = this.invoiceServiceManager.UpdateInvoiceUsedNO(invoiceChange.EndNO, invoice.AcceptOper.ID, invoice.AcceptTime);
            if (iReturn < 0)
            {
                MessageBox.Show("更新发票已用号码失败!" + this.invoiceServiceManager.Err);
                Neusoft.FrameWork.Management.PublicTrans.RollBack();
                return(-1);
            }
            Neusoft.FrameWork.Management.PublicTrans.Commit();
            MessageBox.Show("保存成功");
            this.QueryInvoice();
            return(0);
        }