예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="billKind"></param>
        /// <param name="OperatorId"></param>
        /// <param name="NewInvoiceNo"></param>
        /// <returns></returns>
        public static bool AdjustInvoiceNo(OPDBillKind billKind, int OperatorId, string NewInvoiceNo)
        {
            string strWhere = Tables.mz_invoice.STATUS + " = 0";

            strWhere += " and " + Tables.mz_invoice.EMPLOYEE_ID + " = " + OperatorId;
            strWhere += " and " + Tables.mz_invoice.INVOICE_TYPE + " = " + (int)billKind;

            MZ_INVOICE mz_invoice   = (MZ_INVOICE)MSAccessDb.GetModel("MZ_INVOICE", strWhere, typeof(MZ_INVOICE));
            long       newInvoiceNo = Convert.ToInt64(NewInvoiceNo);

            if (mz_invoice != null)
            {
                if (newInvoiceNo > Convert.ToInt64(mz_invoice.END_NO))
                {
                    throw new Exception("要调整的发票号不能超出本卷票的结束号!");
                }
                if (newInvoiceNo <= Convert.ToInt64(mz_invoice.CURRENT_NO))
                {
                    throw new Exception("要调整的发票号不能小于当前票号!");
                }
                //BindEntity<MZ_INVOICE>.CreateInstanceDAL( oleDb ).Update( strWhere , Tables.mz_invoice.CURRENT_NO + oleDb.EuqalTo( ) + newInvoiceNo );
                MSAccessDb.UpdateRecord(new string[] { Tables.mz_invoice.CURRENT_NO + " = " + newInvoiceNo },
                                        strWhere, typeof(MZ_INVOICE));
                return(true);
            }
            else
            {
                throw new Exception("没有找到当前在用发票记录!");
            }
        }
예제 #2
0
        private static int insert_mz_invoice(MZ_INVOICE mz_invoice)
        {
            string insert = "insert into " + "MZ_INVOICE" + "(" +
                            "" + Tables.mz_invoice.CURRENT_NO + "" + "," +
                            "" + Tables.mz_invoice.EMPLOYEE_ID + "" + "," +
                            "" + Tables.mz_invoice.END_NO + "" + "," +
                            "" + Tables.mz_invoice.ID + "" + "," +
                            "" + Tables.mz_invoice.INVOICE_TYPE + "" + "," +
                            "" + Tables.mz_invoice.PERFCHAR + "" + "," +
                            "" + Tables.mz_invoice.START_NO + "" + "," +
                            "" + Tables.mz_invoice.STATUS + "" + ")";
            string values = " values (" +
                            "" + mz_invoice.CURRENT_NO + "" + "," +
                            "" + mz_invoice.EMPLOYEE_ID + "" + "," +
                            "" + mz_invoice.END_NO + "" + "," +
                            "'" + mz_invoice.ID + "'" + "," +
                            "" + mz_invoice.INVOICE_TYPE + "" + "," +
                            "'" + mz_invoice.PerfChar + "'" + "," +
                            "" + mz_invoice.START_NO + "" + "," +
                            "" + mz_invoice.STATUS + "" + ")";

            int effectrow = Execute(insert + " " + values);

            return(mz_invoice.ID);
        }
예제 #3
0
        /// <summary>
        /// 删除发票卷
        /// </summary>
        /// <param name="VolumnID">发票卷号</param>
        /// <remarks>
        /// 对于在用的,已用的,停用的但之前有使用过的不能删除
        /// 备用的,停用的但还未使用的可以删除
        /// </remarks>
        /// <returns></returns>
        public static bool DeleteInvoiceVolumn(int VolumnID)
        {
            MZ_INVOICE invoice = (MZ_INVOICE)MSAccessDb.GetModel("MZ_INVOICE", Tables.mz_invoice.ID + "=" + VolumnID, typeof(MZ_INVOICE));

            if (invoice != null)
            {
                if (invoice.STATUS == 0)
                {
                    throw new Exception("该卷发票正在使用中,不能删除");
                }
                if (invoice.STATUS == 1)
                {
                    throw new Exception("该卷发票已经有使用记录,不能删除");
                }
                if (invoice.STATUS == 3 && invoice.START_NO != invoice.CURRENT_NO)
                {
                    throw new Exception("该卷发票已停用,但有部分票据已经使用过,不能删除!\r\n如果要使用未用的票据号,请将这段票据号重新分配");
                }
            }
            try
            {
                string sql = "delete * from mz_invoice where id=" + VolumnID;
                MSAccessDb.Execute(sql);
                return(true);
            }
            catch (Exception err)
            {
                throw new Exception("删除票卷发生错误!");
            }
        }
예제 #4
0
        /// <summary>
        /// 上传发票信息
        /// </summary>
        public void UploadDataWithInvoiceInfo()
        {
            if (_oleDb == null)
            {
                ConnectToRemoteDB( );
            }

            DataTable tbInvoice    = MSAccessDb.GetDataTable("select * from mz_invoice where upload_flag=0 and employee_id=" + _employeeId);
            int       invoiceCount = tbInvoice.Rows.Count;

            if (invoiceCount == 0)
            {
                if (UpLoadingEvent != null)
                {
                    UpLoadingEvent("没有需要上传的发票使用信息!\r\n");
                }
                return;
            }

            if (UpLoadingEvent != null)
            {
                UpLoadingEvent(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "开始上传个人发票使用记录!\r\n");
            }
            try
            {
                BeginTrans( );

                for (int invoiceIndex = 0; invoiceIndex < tbInvoice.Rows.Count; invoiceIndex++)
                {
                    int        localInvoiceId = Convert.ToInt32(tbInvoice.Rows[invoiceIndex][Tables.mz_invoice.ID]);
                    MZ_INVOICE mz_invoice     = new MZ_INVOICE( );
                    DataBind <MZ_INVOICE>(tbInvoice.Rows[invoiceIndex], mz_invoice);
                    string strWhere = Tables.mz_invoice.ID + _oleDb.EuqalTo( ) + localInvoiceId;
                    if (BindEntity <MZ_INVOICE> .CreateInstanceDAL(_oleDb).Exists(strWhere))
                    {
                        BindEntity <MZ_INVOICE> .CreateInstanceDAL(_oleDb).Update(mz_invoice);

                        MSAccessDb.Execute("update mz_invoice set upload_flag = 1 where id = " + localInvoiceId);
                    }
                    else
                    {
                        BindEntity <MZ_INVOICE> .CreateInstanceDAL(_oleDb).Add(mz_invoice);

                        int serverInvoiceId = mz_invoice.ID;
                        MSAccessDb.Execute("update mz_invoice set upload_flag = 1,id = " + serverInvoiceId + " where id = " + localInvoiceId);
                    }
                }
                CommitTrans( );
                if (UpLoadingEvent != null)
                {
                    UpLoadingEvent(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "上传个人发票使用记录成功!\r\n发票使用记录" + invoiceCount + "条\r\n\r\n");
                }
            }
            catch (Exception err)
            {
                RollbackTrans( );
                throw err;
            }
        }
예제 #5
0
        private static void update_mz_invoice(MZ_INVOICE mz_invoice)
        {
            string update = "update MZ_INVOICE set " +
                            Tables.mz_invoice.CURRENT_NO + "=" + mz_invoice.CURRENT_NO + "" + "," +
                            Tables.mz_invoice.STATUS + "=" + mz_invoice.STATUS + "" + " " +
                            ", upload_flag = 0 where " + Tables.mz_invoice.ID + "=" + mz_invoice.ID + " and " + Tables.mz_invoice.EMPLOYEE_ID + "=" + mz_invoice.EMPLOYEE_ID;

            Execute(update);
        }