Example #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sql"></param>
 /// <returns></returns>
 public int ExecuteNonQuery(string sql)
 {
     if (_trans != null)
     {
         return(_trans.FromSql(sql).ExecuteNonQuery());
     }
     return(DBSession.CurrentSession.FromSql(sql).ExecuteNonQuery());
 }
Example #2
0
        /// <summary>
        /// 保存用户
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public bool SaveExt(Mes_Sys_User obj)
        {
            int result = -1;

            try
            {
                using (DbTrans trans = this.CurDbSession.BeginTransaction())
                {
                    //1.保存用户
                    if (obj.ID > 0)
                    {
                        result = trans.Update <Mes_Sys_User>(obj);
                    }
                    else
                    {
                        result = trans.Insert <Mes_Sys_User>(obj);
                    }

                    if (result <= 0)
                    {
                        trans.Rollback();
                        return(false);
                    }

                    //2.保存用户角色、部门关系表
                    string sql = @"DELETE FROM Mes_Sys_Map WHERE UserID ='{0}';
                        INSERT INTO Mes_Sys_Map(UserID,RoleID,OrgID,RecordStatus,Creater,CreatedTime)VALUES('{0}',{1},{2},1,'{3}',GETDATE())";
                    sql    = string.Format(sql, obj.UserID, obj.RoleID, obj.OrgID, obj.Creater);
                    result = trans.FromSql(sql).ExecuteNonQuery();
                    if (result <= 0)
                    {
                        trans.Rollback();
                        return(false);
                    }

                    //提交事务
                    trans.Commit();
                }
            }
            catch (System.Exception ex)
            {
                throw ex;
            }

            return(true);
        }
Example #3
0
        /// <summary>
        /// 结算会员洗码费
        /// </summary>
        /// <param name="model"></param>
        /// <param name="head"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public bool SettleWashF(ClientSearc model, HeadMessage head, out ErrorMessage error)
        {
            error       = new ErrorMessage();
            error.ErrNo = "0004";
            DbTrans trans = null;

            try
            {
                string strSql = Common.SqlTemplateCommon.GetSql("SetWashFlag");
                string opSql  = Common.SqlTemplateCommon.GetSql("SettleWashF");
                if (string.IsNullOrEmpty(strSql) || string.IsNullOrEmpty(opSql))
                {
                    error.ErrMsg = "服务端没有读取到SetWashFlag数据模板,请联系管理员";
                    return(false);
                }
                string billID = Guid.NewGuid().ToString().Replace("-", "");
                if (string.IsNullOrEmpty(model.C_ID) || string.IsNullOrEmpty(model.StartDate) || string.IsNullOrEmpty(model.EndDate))
                {
                    error.ErrMsg = "没有接收到正确的请求参数";
                    return(false);
                }
                strSql = strSql.Replace("${BillID}", billID);
                strSql = strSql.Replace("${ClientID}", model.C_ID);
                strSql = strSql.Replace("${SettleDate}", model.StartDate);
                strSql = strSql.Replace("${EndDate}", model.StartDate);

                opSql = opSql.Replace("${CreateID}", head.LoginID);
                opSql = opSql.Replace("${ClientID}", model.C_ID);
                opSql = opSql.Replace("${BillID}", billID);
                opSql = opSql.Replace("${IP}", head.Ip);
                opSql = opSql.Replace("${Address}", Common.CommonHelper.ipToAddr(head.Ip));
                opSql = opSql.Replace("${Operator}", head.Account);
                opSql = opSql.Replace("${StartDate}", model.StartDate);
                opSql = opSql.Replace("${EndDate}", model.EndDate);

                trans = Db.Context_SqlServer.BeginTransaction();
                SettleModel settle = trans.FromSql(strSql).ToFirst <SettleModel>();
                if (settle != null)
                {
                    opSql        = opSql.Replace("${Counts}", settle.C_Counts.ToString());
                    opSql        = opSql.Replace("${Point}", ((int)settle.C_Amount).ToString());
                    opSql        = opSql.Replace("${WashRate}", settle.C_WashR);
                    opSql        = opSql.Replace("${WashSum}", settle.C_WashS.ToString());
                    error.ErrMsg = "洗码费结算成功";

                    trans.FromSql(opSql).ToDataSet();
                    trans.Commit();
                    return(true);
                }
                else
                {
                    error.ErrMsg = "没有可结算的洗码费";
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Common.LogHelper.WriteLog(typeof(ClientListDAL), ex);
                error.ErrMsg = ex.Message.Replace("\r", "").Replace("\n", "");
                trans.Rollback();
                return(false);
            }
            finally
            {
                if (trans != null)
                {
                    trans.Close();
                    trans.Dispose();
                }
            }
        }
Example #4
0
    protected void Edit_Users(object sender, EventArgs e)
    {
        if (!CommonManager.Web.CheckPostSource())
        {
            return;
        }

        if (UserID == 0)
        {
            return;
        }
        DataRow row = new BLL.Member().GetInfo(UserID.ToString());

        if (row == null)
        {
            return;
        }

        using (DbTrans trans = DbSession.Default.BeginTrans())
        {
            try
            {
                #region 对TUsers表的修改
                if (txtNickName.Text.Trim() == "")
                {
                    CommonManager.Web.RegJs(this, "alert('昵称不能为空!');location.href=location.href;", false);
                    return;
                }
                string        nickName = txtNickName.Text.Trim();
                StringBuilder sql      = new StringBuilder("update TUsers set ");
                sql.Append(" Sex=@Sex,");
                sql.Append(" Disabled=@Disabled,");
                sql.Append(" NickName=@NickName ");
                if (!string.IsNullOrEmpty(txtPassWord.Text.Trim()))
                {
                    sql.Append(" ,Pass=@Password");
                }
                if (!string.IsNullOrEmpty(txtTwoPassWord.Text.Trim()))
                {
                    sql.Append(" ,TwoPassword=@TwoPassword");
                }
                sql.Append(" where UserID=@UserID;");

                SqlSection sect = trans.FromSql(sql.ToString())
                                  .AddInputParameter("@Sex", DbType.Int16, rdolSex.SelectedItem.Value)
                                  .AddInputParameter("@Disabled", DbType.Int32, rdolDisabled.SelectedItem.Value)
                                  .AddInputParameter("@UserID", DbType.Int32, UserID)
                                  .AddInputParameter("@NickName", DbType.Int32, nickName);


                if (!string.IsNullOrEmpty(txtPassWord.Text.Trim()))
                {
                    sect.AddInputParameter("@Password", DbType.String, Utility.Common.md5(txtPassWord.Text.Trim()) /*CommonManager.String.EncryptMD5SystemDefaultMethod(txtPassWord.Text.Trim(),false,true)*/);
                }

                if (!string.IsNullOrEmpty(txtTwoPassWord.Text.Trim()))
                {
                    sect.AddInputParameter("@TwoPassword", DbType.String, Utility.Common.md5(txtTwoPassWord.Text.Trim()) /*CommonManager.String.EncryptMD5SystemDefaultMethod( txtTwoPassWord.Text.Trim(), false, true )*/);
                }

                sect.Execute();
                #endregion

                #region 判断是否需要修改TMatchTable
                if (row["Master"].ToString() != ddlMaster.SelectedItem.Value)
                {
                    sql = new StringBuilder();
                    if (ddlMaster.SelectedItem.Value == "3")
                    {
                        sql.Append("update TMatchTable set MasterPower=268435455 where UserID=@UserID;");
                    }
                    else if (ddlMaster.SelectedItem.Value == "0")
                    {
                        sql.Append("update TMatchTable set MasterPower=0 where UserID=@UserID;");
                    }
                    trans.FromSql(sql.ToString()).AddInputParameter("@UserID", DbType.Int32, UserID).Execute();
                }
                #endregion

                #region 计算VIP时间
                int addvip = (int)row["VipTime"];                //得到原来的时间,秒数

                if (rdolVip.SelectedIndex != -1 || (!string.IsNullOrEmpty(txtCustomVIP.Text.Trim())))
                {
                    int tmp = 0;
                    if (rdolVip.SelectedIndex != -1)                     //预设值优先
                    {
                        tmp = int.Parse(rdolVip.SelectedItem.Value);
                    }
                    else
                    {
                        if (!CommonManager.String.IsInteger(txtCustomVIP.Text.Trim()))
                        {
                            CommonManager.Web.RegJs(this, "alert('自定义天数必须为数字!');location.href=location.href;", false);
                            return;
                        }
                        tmp = (int.Parse(txtCustomVIP.Text.Trim()) * 24 * 3600);
                    }

                    //如果不是取消vip,则补齐时间差
                    if (tmp > 0)
                    {
                        DateTime curVIP = (DateTime)row["VipTime2"];                        //得到原来时间的DateTime格式
                        if (curVIP == new DateTime(1970, 1, 1, 8, 0, 0))
                        {
                            //从未设置过vip时间,则用当前时间与初始时间的时间差加上要增加的时间。
                            addvip = (int)(DateTime.Now - new DateTime(1970, 1, 1, 8, 0, 0)).TotalSeconds + tmp;
                        }
                        else if (curVIP < DateTime.Now)
                        {
                            //有过vip,但已到期,则补齐时间差
                            addvip += (int)(DateTime.Now - curVIP).TotalSeconds + tmp;
                        }
                        else
                        {
                            //有vip,且未到期,则在原来基础上增加
                            addvip += tmp;
                        }
                    }
                    else
                    {
                        //取消vip
                        addvip = 0;
                    }
                }
                #endregion

                Int64 mon;
                Int64 bmon;

                #region 判断是否需要插入金币修改表
                if (!Int64.TryParse(txtWalletMoney.Text.Trim(), out mon))
                {
                    CommonManager.Web.RegJs(this, "alert('钱包金币数必须为数字,或超出整数范围');location.href=location.href;", false);
                    return;
                }
                if (!Int64.TryParse(txtBankMoney.Text.Trim(), out bmon))
                {
                    CommonManager.Web.RegJs(this, "alert('银行金币数必须为数字,或超出整数范围');location.href=location.href;", false);
                    return;
                }
                if (!CommonManager.String.IsInteger(txtFascination.Text.Trim()))
                {
                    CommonManager.Web.RegJs(this, "alert('魅力数必须为数字!');location.href=location.href;", false);
                    return;
                }
                string newWM = string.IsNullOrEmpty(txtWalletMoney.Text.Trim()) ? "0" : txtWalletMoney.Text.Trim();
                string newBM = string.IsNullOrEmpty(txtBankMoney.Text.Trim()) ? "0" : txtBankMoney.Text.Trim();

                #region Old code

                /*
                 * if( row["WalletMoney"].ToString() != newWM )
                 * {
                 *      sql = new StringBuilder();
                 *      sql.Append( "insert into Web_MoneyChangeLog (userid,username,frontmoney,aftermoney,changetype,addtime,adduser)" );
                 *      sql.Append( " values (@UserID,@UserName,@OldWalletMoney,@WalletMoney,0,getdate(),@AdminName);" );
                 *
                 *      trans.FromSql( sql.ToString() )
                 *                      .AddInputParameter( "@UserID", DbType.Int32, UserID )
                 *                      .AddInputParameter( "@UserName", DbType.String, row["UserName"].ToString() )
                 * .AddInputParameter("@OldWalletMoney", DbType.Int32, row["WalletMoney"])
                 * .AddInputParameter("@WalletMoney", DbType.Int32, newWM)
                 *                      .AddInputParameter( "@AdminName", DbType.Int16, AdminInfo["UserName"].ToString() )
                 *                      .Execute();
                 *      //int dvalue = int.Parse( newWM ) - (int)row["WalletMoney"];
                 *      //if( dvalue > 0 )
                 *      //{
                 *      //    MoneyOperator.Default.Add_Web_Record_MoneyIncrease( dvalue, Session["AdminName"].ToString() + "管理员手动给玩家" + row["UserName"].ToString() + "添加钱包金币" );
                 *      //}
                 *      //else
                 *      //{
                 *      //    MoneyOperator.Default.Add_Web_Record_MoneyDecrease( Math.Abs( dvalue ), Session["AdminName"].ToString() + "管理员手动减去玩家" + row["UserName"].ToString() + "钱包金币" );
                 *      //}
                 * }
                 * if( row["BankMoney"].ToString() != newBM )
                 * {
                 *      sql = new StringBuilder();
                 *      sql.Append( "insert into Web_MoneyChangeLog (userid,username,frontmoney,aftermoney,changetype,addtime,adduser)" );
                 *      sql.Append( " values (@UserID,@UserName,@OldBankMoney,@BankMoney,0,getdate(),@AdminName);" );
                 *
                 *      trans.FromSql( sql.ToString() )
                 *                      .AddInputParameter( "@UserID", DbType.Int32, UserID )
                 *                      .AddInputParameter( "@UserName", DbType.String, row["UserName"].ToString() )
                 * .AddInputParameter("@OldBankMoney", DbType.Int32, row["WalletMoney"])
                 * .AddInputParameter("@BankMoney", DbType.Int32, newBM)
                 *                      .AddInputParameter( "@AdminName", DbType.Int16, AdminInfo["UserName"].ToString() )
                 *                      .Execute();
                 *
                 *      //int dvalue = int.Parse( newBM ) - (int)row["BankMoney"];
                 *      //if( dvalue > 0 )
                 *      //{
                 *      //    MoneyOperator.Default.Add_Web_Record_MoneyIncrease( dvalue, Session["AdminName"].ToString() + "管理员手动给玩家" + row["UserName"].ToString() + "添加银行金币" );
                 *      //}
                 *      //else
                 *      //{
                 *      //    MoneyOperator.Default.Add_Web_Record_MoneyDecrease( Math.Abs( dvalue ), Session["AdminName"].ToString() + "管理员手动减去玩家" + row["UserName"].ToString() + "银行金币" );
                 *      //}
                 *
                 * }
                 */
                #endregion

                if (row["WalletMoney"].ToString() != newWM || row["BankMoney"].ToString() != newBM)                     //如果修改金币,则插入金币变化日志
                {
                    Int64  startMoney  = Convert.ToInt64(row["WalletMoney"]) + Convert.ToInt64(row["BankMoney"]);
                    Int64  changeMoney = (Convert.ToInt64(newWM) + Convert.ToInt64(newBM)) - startMoney;
                    string remark      = ChineseMessage.adminManageNameMessage + AdminUserName + " " + ChineseMessage.adminManageIdMessage + AdminUserID;
                    BLL.Member.WriteMoneyExChangeLog(UserID.ToString(), startMoney, changeMoney, (int)Library.MoneyChangeType.管理员修改金币, remark);
                }

                #endregion

                #region 对TUserInfo表的修改
                sql = new StringBuilder();
                sql.Append("update TUserInfo set ");
                sql.Append(" Member=@Member,");
                sql.Append(" Master=@Master,");
                sql.Append(" WalletMoney=@WalletMoney,");
                sql.Append(" BankMoney=@BankMoney,");
                sql.Append(" Fascination=@Fascination,");
                sql.Append(" Viptime=@Viptime,");
                sql.Append(" UserType=@UserType,");
                sql.Append(" Trader=@Trader");
                sql.Append(" where UserID=@UserID;");
                trans.FromSql(sql.ToString())
                .AddInputParameter("@Member", DbType.Int32, ddlMember.SelectedItem.Value)
                .AddInputParameter("@Master", DbType.Int32, ddlMaster.SelectedItem.Value)
                .AddInputParameter("@WalletMoney", DbType.Int32, newWM)
                .AddInputParameter("@BankMoney", DbType.Int32, newBM)
                .AddInputParameter("@Fascination", DbType.Int32, string.IsNullOrEmpty(txtFascination.Text.Trim()) ? "0" : txtFascination.Text.Trim())
                .AddInputParameter("@UserType", DbType.Int32, ddlUserType.SelectedItem.Value)
                .AddInputParameter("@Viptime", DbType.Int32, addvip)
                .AddInputParameter("@Trader", DbType.Int32, rdoIsTrader.SelectedValue)
                .AddInputParameter("@UserID", DbType.Int32, UserID)
                .Execute();
                #endregion

                #region 对Web_Users表的修改
                if (!CommonManager.String.IsInteger(txtLotteries.Text.Trim()))
                {
                    CommonManager.Web.RegJs(this, "alert('" + UiCommon.StringConfig.GoldName + "数必须为数字!');location.href=location.href;", false);
                    return;
                }
                sql = new StringBuilder();
                sql.Append("update Web_Users set ");
                sql.Append(" Pwd_anw=@Pwd_anw,");
                //sql.Append( " Pwd_ques=@Pwd_ques," );
                sql.Append(" ZJ_type=@ZJ_type,");
                sql.Append(" ZJ_Number=@ZJ_Number,");
                sql.Append("RealName=@RealName,");
                sql.Append(" Lotteries=@Lotteries ");
                sql.Append(" where UserID=@UserID;");


                trans.FromSql(sql.ToString())
                .AddInputParameter("@Pwd_anw", DbType.String, txtPwd_anw.Text.Trim())
                .AddInputParameter("@ZJ_Number", DbType.String, txtZJ_Number.Text.Trim())
                .AddInputParameter("@ZJ_type", DbType.Int16, ddlZJ_Type.SelectedItem.Value)
                .AddInputParameter("@RealName", DbType.String, txtUserRealName.Text.Trim())
                .AddInputParameter("@Lotteries", DbType.Int32, txtLotteries.Text.Trim())
                .AddInputParameter("@UserID", DbType.Int32, UserID)
                .Execute();
                #endregion

                trans.Commit();

                CommonManager.Web.RegJs(this, "alert('修改成功!');location.href=location.href;", false);
            }
            catch (Exception ex)
            {
                trans.Rollback();
                CommonManager.Web.RegJs(this, "alert('发生错误,错误信息:" + ex.Message + "。\\r\\n未对数据库进行任何操作。');location.href=location.href;", false);
            }
        }
    }
    protected void btnModfyMoney_Click(object sender, EventArgs e)
    {
        if (!CommonManager.Web.CheckPostSource())
        {
            return;
        }
        if (!IsValid)
        {
            return;
        }

        if (AgencyInfo == null)
        {
            return;
        }

        long old_account = (long)AgencyInfo["Account"];

        if (!CommonManager.String.IsInteger(tbxAccount.Text.Trim()))
        {
            CommonManager.Web.RegJs(this, "alert('输入的金币数必须为数字!');location.href=location.href;", false);
            return;
        }
        if (Convert.ToInt64(tbxAccount.Text.Trim()) < 0)
        {
            CommonManager.Web.RegJs(this, "alert('输入的金币数必须为大于0的数字!');location.href=location.href;", false);
            return;
        }
        long new_account = string.IsNullOrEmpty(tbxAccount.Text.Trim()) ? 0L : long.Parse(UiCommon.StringConfig.MoneyCheng100(tbxAccount.Text.Trim()));

        long range = new_account - old_account;

        if (range != 0)
        {
            using (DbTrans trans = DbSession.Default.BeginTrans())
            {
                try
                {
                    trans.FromSql("update Web_Agency set Account=@Account Where AgencyID=@AgencyID")
                    .AddInputParameter("@Account", DbType.Int64, new_account)
                    .AddInputParameter("@AgencyID", DbType.Int32, AgencyInfo["AgencyID"])
                    .Execute();

                    //记录日志
                    string sql = "insert into Web_AgencyAccountLog (AdminID,AgencyID,MoneyB,Range,MoneyA,InputDate) values (@AdminID,@AgencyID,@MoneyB,@Range,@MoneyA,getdate()); ";
                    sql += " exec Web_pAgencyMoneyChangeLogAdd @AgencyID,'',@MoneyB,@Range,@MoneyA," + (int)BLL.AgencyMoneyLog.LogType.管理员改金币 + @",'" + BLL.AgencyMoneyLog.LogType.管理员改金币.ToString() + @"','操作人" + AdminUserName + "(后台管理员)'";

                    trans.FromSql(sql)
                    .AddInputParameter("@AdminID", DbType.Int32, AdminUserID)
                    .AddInputParameter("@AgencyID", DbType.Int32, AgencyInfo["AgencyID"])
                    .AddInputParameter("@MoneyB", DbType.Int64, old_account)
                    .AddInputParameter("@Range", DbType.Int64, range)
                    .AddInputParameter("@MoneyA", DbType.Int64, new_account)
                    .Execute();

                    trans.Commit();

                    //new BLL.AdminLog().Add( UiCommon.AdminLoginInfo.UserName, "修改了代理[" + AgencyInfo["AgencyName"].ToString() + "]的金币为" + UiCommon.StringConfig.MoneyChu100( new_account ) + ",变动幅度为" + UiCommon.StringConfig.MoneyChu100( range ) );

                    CommonManager.Web.RegJs(this, "alert('修改成功!');location.href='" + Utility.Common.UrlValue + "';", false);
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    CommonManager.Web.RegJs(this, "alert('修改失败!错误原因:" + Server.HtmlEncode(ex.Message) + "');", false);
                    return;
                }
            }
            return;
        }
        CommonManager.Web.RegJs(this, "alert('修改成功!');location.href='" + Utility.Common.UrlValue + "';", false);
    }