public bool AddRecharge(string accountNo, string inTotal, string mome, int uId)
        {
            bool result = false;
            var  model  = new BanKAccountInfo().GetModel(accountNo);

            if (model.status == 1)
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("insert into BankAccountInList(");
                strSql.Append("AccountNo,InMoney,Memo,Type,Time,Status,EmplId)");

                strSql.Append(" values (");
                strSql.Append("@AccountNo,@InMoney,@Memo,@Type,@Time,@Status,@EmplId)");
                strSql.Append(";select @@IDENTITY");
                Database  db        = DatabaseFactory.CreateDatabase();
                DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
                db.AddInParameter(dbCommand, "AccountNo", DbType.AnsiString, accountNo);
                db.AddInParameter(dbCommand, "InMoney", DbType.Currency, inTotal);
                db.AddInParameter(dbCommand, "Memo", DbType.AnsiString, mome);
                db.AddInParameter(dbCommand, "Type", DbType.Byte, 1);
                db.AddInParameter(dbCommand, "Time", DbType.DateTime, DateTime.Now);
                db.AddInParameter(dbCommand, "Status", DbType.Byte, 0);
                db.AddInParameter(dbCommand, "EmplId", DbType.Int32, uId);

                using (DbConnection conn = db.CreateConnection())
                {
                    conn.Open();
                    DbTransaction trans = conn.BeginTransaction();
                    try
                    {
                        object obj = db.ExecuteScalar(dbCommand);

                        trans.Commit();
                        result = true;
                    }
                    catch
                    {
                        trans.Rollback();
                    }
                    conn.Close();
                }
            }
            return(result);
        }
        /// <summary>
        /// 取消
        /// </summary>
        /// <param name="accountNo"></param>
        /// <param name="inTotal"></param>
        /// <param name="mome"></param>
        /// <param name="uId"></param>
        /// <returns></returns>
        public bool CanCelRecharge(string inId, string accountNo, string inTotal, string mome, int uId)
        {
            bool result = false;
            var  model  = new BanKAccountInfo().GetModel(accountNo);

            if (model.status == 1)
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("insert into BankAccountInList(");
                strSql.Append("AccountNo,InMoney,Memo,Type,Time,Status,EmplId)");

                strSql.Append(" values (");
                strSql.Append("@AccountNo,@InMoney,@Memo,@Type,@Time,@Status,@EmplId)");
                strSql.Append(";select @@IDENTITY");
                Database  db        = DatabaseFactory.CreateDatabase();
                DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
                db.AddInParameter(dbCommand, "AccountNo", DbType.AnsiString, accountNo);
                db.AddInParameter(dbCommand, "InMoney", DbType.Currency, inTotal);
                db.AddInParameter(dbCommand, "Memo", DbType.AnsiString, mome);
                db.AddInParameter(dbCommand, "Type", DbType.Byte, 1);
                db.AddInParameter(dbCommand, "Time", DbType.DateTime, DateTime.Now);
                db.AddInParameter(dbCommand, "Status", DbType.Byte, 1);
                db.AddInParameter(dbCommand, "EmplId", DbType.Int32, uId);

                using (DbConnection conn = db.CreateConnection())
                {
                    conn.Open();
                    DbTransaction trans = conn.BeginTransaction();
                    try
                    {
                        int    res;
                        object obj = db.ExecuteScalar(dbCommand);
                        if (int.TryParse(obj.ToString(), out res))
                        {
                            StringBuilder strSql2 = new StringBuilder();
                            strSql2.Append("update BanKAccountInfo set ");
                            strSql2.Append("CurrentTotal=CurrentTotal" + inTotal);
                            strSql2.Append(" where AccountNo=@AccountNo ");
                            DbCommand dbCommand2 = db.GetSqlStringCommand(strSql2.ToString());
                            db.AddInParameter(dbCommand2, "AccountNo", DbType.AnsiString, accountNo);
                            db.ExecuteNonQuery(dbCommand2, trans);
                            StringBuilder strSql3 = new StringBuilder();
                            strSql3.Append("update BankAccountInList set ");
                            strSql3.Append("Status=0");
                            strSql3.Append(" where InId=@InId ");
                            DbCommand dbCommand3 = db.GetSqlStringCommand(strSql3.ToString());
                            db.AddInParameter(dbCommand3, "InId", DbType.Int32, inId);
                            db.ExecuteNonQuery(dbCommand3, trans);
                            trans.Commit();
                            result = true;
                        }
                        else
                        {
                            trans.Rollback();
                        }
                    }
                    catch
                    {
                        trans.Rollback();
                    }
                    conn.Close();
                }
            }
            return(result);
        }
예제 #3
0
        public string ChAcc(string cardNo, int empId, string newCardNo)
        {
            string   result = "1改卡失败";
            Database db     = DatabaseFactory.CreateDatabase();

            if (cardNo != newCardNo)
            {
                StringBuilder strSql3 = new StringBuilder();
                strSql3.Append("select count(1) from BankCardInfo where CardNo=@CardNo ");
                DbCommand dbCommand3 = db.GetSqlStringCommand(strSql3.ToString());
                db.AddInParameter(dbCommand3, "CardNo", DbType.AnsiString, newCardNo);
                object obj3 = db.ExecuteScalar(dbCommand3);
                if (obj3.ToString() == "0")
                {
                    var model = new BanKAccountInfo().GetModel(cardNo);
                    if (model != null)
                    {
                        using (DbConnection conn = db.CreateConnection())
                        {
                            conn.Open();
                            DbTransaction trans = conn.BeginTransaction();
                            try
                            {
                                StringBuilder strSql2 = new StringBuilder();
                                strSql2.Append("update  BankPayList set AccountNo=@NewCardNo where AccountNo=@CardNo;");
                                strSql2.Append("update  BankAccountOperateList set AccountNo=@NewCardNo where AccountNo=@CardNo;");
                                strSql2.Append("update  BankAccountInList set AccountNo=@NewCardNo where AccountNo=@CardNo;");
                                strSql2.Append("update  BanKAccountInfo set CardNo=@NewCardNo,AccountNo=@NewCardNo where AccountNo=@CardNo;");
                                strSql2.Append("update  BankCardInfo set CardNo=@NewCardNo where CardNo=@CardNo;");
                                DbCommand dbCommand2 = db.GetSqlStringCommand(strSql2.ToString());
                                db.AddInParameter(dbCommand2, "CardNo", DbType.AnsiString, cardNo);
                                db.AddInParameter(dbCommand2, "NewCardNo", DbType.AnsiString, newCardNo);
                                int obj = db.ExecuteNonQuery(dbCommand2, trans);
                                if (obj > 0)
                                {
                                    StringBuilder strSql5 = new StringBuilder();
                                    strSql5.Append("insert into BankAccountOperateList(");
                                    strSql5.Append("AccountNo,OpType,time,EmplId)");

                                    strSql5.Append(" values (");
                                    strSql5.Append("@AccountNo,@OpType,@time,@EmplId)");
                                    strSql5.Append(";select @@IDENTITY");
                                    DbCommand dbCommand5 = db.GetSqlStringCommand(strSql5.ToString());
                                    db.AddInParameter(dbCommand5, "AccountNo", DbType.AnsiString, newCardNo);

                                    db.AddInParameter(dbCommand5, "OpType", DbType.Byte, 6);
                                    db.AddInParameter(dbCommand5, "time", DbType.DateTime, DateTime.Now);
                                    db.AddInParameter(dbCommand5, "EmplId", DbType.Int32, empId);
                                    db.ExecuteNonQuery(dbCommand5, trans);

                                    result = "1";
                                    trans.Commit();
                                }
                            }
                            catch (Exception ee)
                            {
                                result = ee.Message;
                                trans.Rollback();
                            }
                            conn.Close();
                        }
                    }
                    else
                    {
                        result = "不能对该卡进行操作!";
                    }
                }
                else
                {
                    result = "该卡已经绑定其他帐号";
                }
            }
            else
            {
                result = "改卡失败";
            }
            return(result);
        }