Esempio n. 1
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     string loginname = this.txtLoginName.Text.Trim();
     string loginpwd = this.txtLoginPwd.Text.Trim();
     string name = this.txtName.Text.Trim();
     //            bool viewreport = this.ddlViewReport.SelectedValue.Equals("yes") ? true : false;
     //            bool changepartnerpwd = this.ddlChangePartnerPwd.SelectedValue.Equals("yes") ? true : false;
     //            bool createpartneraccount = this.ddlCreatePartnerAccount.SelectedValue.Equals("yes") ? true : false;
     UserInfo userInfo = new UserInfo();
     if (!String.IsNullOrEmpty(hdUId.Value))
     {
         userInfo.Id = Convert.ToInt32(hdUId.Value);
     }
     userInfo.LoginName = loginname;
     userInfo.LoginPwd = loginpwd;
     userInfo.Name = name;
     userInfo.ViewReport = false;
     userInfo.ChangePartnerPwd = true;
     userInfo.IsPublicGroup = false;
     userInfo.CreditAvailable = Convert.ToInt32(txtCredit.Text);
     userInfo.CreatePartnerAccount = true;
     userInfo.CreateSourceUser = cbSource.Checked;
     userInfo.CreatePublicUser = cbPublic.Checked;
     userInfo.ParentId = (Session["currentUser"] as AutoBwsModel.UserInfo).Id;
     UserCredit creditInfo = new UserCredit();
     //info.ExpiredTime = DateTime.Now.AddDays(Convert.ToDouble(AutoBwsBLL.Config.CreditConfig.GetInstance().Getperiod()));
     creditInfo.TrueUserId = 0;
     AutoBwsBLL.AdminBLL adminBll = new AutoBwsBLL.AdminBLL();
     if (this.lblAddOrDetail2.Text.ToLower().Contains("add"))
     {
         if (adminBll.AddNewAdmin_checkLoginName(loginname))
         {
             Common.yvonYmPrompt.AlertError("This admin account already exists!", this.Page, "cleanyvon");
         }
         else
         {
             if (adminBll.AddNewAdminWithCredits(userInfo, creditInfo, Convert.ToInt32(txtCredit.Text)))
             {
                 Common.yvonYmPrompt.AlertSuccess("Admin account created!", this.Page, "cleanyvon");
             }
             else
             {
                 Common.yvonYmPrompt.AlertError("Failed to create admin account!", this.Page);
             }
         }
     }
     else
     {
         if (adminBll.UpdateAdmin(userInfo))
         {
             Common.yvonYmPrompt.AlertSuccess("Admin account updated!", this.Page, "cleanyvon");
             HttpContext.Current.Response.Redirect("~/files/AdminList.aspx");
         }
         else
         {
             Common.yvonYmPrompt.AlertError("Failed to update admin account!", this.Page);
         }
     }
 }
Esempio n. 2
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string loginname = txtloginName.Text.Trim();
            UserInfo userInfo = null;
            string loginpwd = txtloginPwd.Text.Trim();
            string name = txtName.Text.Trim();
            userInfo = new UserInfo();
            userInfo.LoginName = loginname;
            userInfo.LoginPwd = loginpwd;
            userInfo.Name = name;
            userInfo.AllowAddGhost = RadioBtnAllow.Checked;
            userInfo.IsPublicGroup = RadioBtnForbidden.Checked;
            userInfo.IsAllowTesting = cbAllowTesting.Checked;
            userInfo.ParentId = (Session["currentUser"] as UserInfo).Id;
            userInfo.CreditUsed = 0;
            userInfo.CreditAvailable = 0;
            userInfo.ExpiryDate = cbAllowTesting.Checked ? DateTime.Now.AddDays(Convert.ToInt32(ConfigurationManager.AppSettings["TrialDuration"])) : DateTime.Now;

            if (lblPartner1.Text.Contains("ADD"))
            {
                if (PartnerBLL.AddNewPartner_checkLoginName(loginname))
                {
                    Common.yvonYmPrompt.AlertError("This user already exists!", Page);
                    return;
                }
                else
                {
                    if (PartnerBLL.AddNewPartner(userInfo))
                    {
                        // todo: adding user and this (adding package) should be done within 1 transaction!
                        // Set package level, testing users have level 1 for each package, non-testing users have level 0 from each package;
                        int newId = PartnerBLL.getPartnerDetail(loginname).Id;
                        AutoBwsBLL.Credit.CreditManager cm = new AutoBwsBLL.Credit.CreditManager();
                        cm.FreePackage(newId, 1, 1);
                        cm.FreePackage(newId, 2, 1);

                        Common.yvonYmPrompt.AlertSuccess("User account created!", Page, "cleanyvon");
                    }
                    else
                    {
                        Common.yvonYmPrompt.AlertError("Failed to create user account!", Page);
                    }
                }
            }
            else
            {
                if (PartnerBLL.UpdatePartner(userInfo))
                {
                    Common.yvonYmPrompt.AlertSuccess("User account updated!", this.Page, "cleanyvon");
                    HttpContext.Current.Response.Redirect("~/files/PartnerList.aspx");
                }
                else
                {
                    Common.yvonYmPrompt.AlertError("Failed to update user account!", this.Page);
                }
            }
        }
Esempio n. 3
0
        public void bindGVLoginAgent()
        {
            string userType = getUserType(Page);
            List<Agent> agentList = new List<Agent>();
            DataTable tb = bvBLL.getLoginFailureAgent();
            if ("P".Equals(userType))
            {
                divAgent.Visible = false;
            }

            if (null != tb && tb.Rows.Count > 0)
            {
                for (int i = 0; i < tb.Rows.Count; i++)
                {
                    Agent agent = new Agent();
                    agent.Id = Convert.ToInt32(tb.Rows[i]["id"]);
                    agent.LoginName = Convert.ToString(tb.Rows[i]["loginName"]);
                    UserInfo partner = new UserInfo();
                    partner.ParentId = Convert.ToInt32(tb.Rows[i]["parentId"]);
                    partner.LoginName = Convert.ToString(tb.Rows[i]["Partner"]);
                    agent.Partner = partner;
                    if (tb.Rows[i]["loginTime"] != DBNull.Value)
                    {
                        agent.LoginTime = Convert.ToDateTime(tb.Rows[i]["loginTime"]);
                    }
                    agent.Result = Convert.ToString(tb.Rows[i]["result"]);
                    agent.Remark = Convert.ToString(tb.Rows[i]["remark"]);
                    if (userType.EndsWith("S"))
                    {
                        agentList.Add(agent);
                    }
                    else if (userType.EndsWith("A"))
                    {
                        UserInfo currentUser = (Session["currentUser"]) as UserInfo;
                        if (null != currentUser && currentUser.Id == partner.ParentId)
                        {
                            agentList.Add(agent);
                        }
                    }
                    else
                    {
                        UserInfo currentUser = (Session["currentUser"]) as UserInfo;
                        if (null != currentUser && currentUser.LoginName == partner.LoginName)
                        {
                            agentList.Add(agent);
                        }
                    }
                }
            }

            this.GVLoginAgent.DataSource = agentList;
            this.GVLoginAgent.DataBind();
        }
Esempio n. 4
0
 public bool AddNewAdminWithCredits(UserInfo userInfo, UserCredit credit, int numberOfCredits)
 {
     bool flag = false;
     MySqlParameter[] parms = new MySqlParameter[]
                              	{
                              		new MySqlParameter("@yaccountType", MySqlDbType.VarChar, 20), //账户类型
                              		new MySqlParameter("@yloginName", MySqlDbType.VarChar, 20), //登录名
                              		new MySqlParameter("@yloginPwd", MySqlDbType.VarChar, 20), //密码
                              		new MySqlParameter("@yname", MySqlDbType.VarChar, 12), //姓名
                              		new MySqlParameter("@yviewReport", MySqlDbType.Bit, 1), //是否可以查看报表
                              		new MySqlParameter("@ycreatParterAccount", MySqlDbType.Bit, 1), //是否可以创建User
                              		new MySqlParameter("@ycreateSource", MySqlDbType.Bit, 1), //是否可以创建Source User
                              		new MySqlParameter("@ycreatePublic", MySqlDbType.Bit, 1), //是否可以创建Public User
                              		new MySqlParameter("@ychangePartnerPwd", MySqlDbType.Bit, 1), //是否可以修改User的密码
                              		new MySqlParameter("@yloginOrNot", MySqlDbType.Bit, 1),
                              		new MySqlParameter("@ParentId", MySqlDbType.Int16, 4),
                              		new MySqlParameter("@Credit", MySqlDbType.Int16, 4),
                              		new MySqlParameter("@BeginDateTime", MySqlDbType.DateTime, 4),
                              		new MySqlParameter("@EndDateTime", MySqlDbType.DateTime, 4),
                              		new MySqlParameter("@ExpiredTime", MySqlDbType.DateTime, 4),
                              		new MySqlParameter("@State", MySqlDbType.Int16, 4),
                              		new MySqlParameter("@numberOfCredits", MySqlDbType.Int16, 4)
                              	};
     parms[0].Value = "admin";
     parms[1].Value = userInfo.LoginName.ToLower();
     parms[2].Value = userInfo.LoginPwd.ToLower();
     parms[3].Value = userInfo.Name.ToLower();
     parms[4].Value = userInfo.ViewReport;
     parms[5].Value = userInfo.CreatePartnerAccount;
     parms[6].Value = userInfo.CreateSourceUser;
     parms[7].Value = userInfo.CreatePublicUser;
     parms[8].Value = userInfo.ChangePartnerPwd;
     parms[9].Value = false;
     parms[10].Value = userInfo.ParentId;
     parms[11].Value = userInfo.CreditAvailable;
     parms[12].Value = credit.BeginDateTime;
     parms[13].Value = credit.EndDateTime;
     parms[14].Value = credit.ExpiredTime;
     parms[15].Value = credit.State;
     parms[16].Value = numberOfCredits;
     try
     {
         DBHelper.ExecuteNonQuery(connectStr, CommandType.StoredProcedure, "addNewAdminWithCredits", parms);
     }
     catch
     {
         throw;
     //                return false;
     //                throw new Exception(ex.ToString());
     }
     return true;
 }
Esempio n. 5
0
 public UserInfo getAdminDetail(string loginName)
 {
     DataTable dt = adminSService.AddNewAdmin_checkLoginName(loginName);
     UserInfo ui = new UserInfo();
     ui.Name = Convert.ToString(dt.Rows[0]["name"]);
     ui.LoginName = loginName;
     ui.LoginPwd = Convert.ToString(dt.Rows[0]["loginPwd"]);
     ui.ViewReport = Convert.ToBoolean(dt.Rows[0]["viewReport"]);
     ui.CreatePartnerAccount = Convert.ToBoolean(dt.Rows[0]["creatParterAccount"]);
     ui.CreateSourceUser = Convert.ToBoolean(dt.Rows[0]["createSourceUser"]);
     ui.CreatePublicUser = Convert.ToBoolean(dt.Rows[0]["createPublicUser"]);
     ui.ChangePartnerPwd = Convert.ToBoolean(dt.Rows[0]["changePartnerPwd"]);
     ui.Id = Convert.ToInt32(dt.Rows[0]["id"]);
     return ui;
 }
Esempio n. 6
0
 public static UserInfo getPartnerDetail(string loginName)
 {
     DataTable dt = pService.AddNewPartner_checkLoginName(loginName);
     UserInfo ui = new UserInfo();
     if (null == dt)
     {
         return ui;
     }
     ui.Id = Convert.ToInt32(dt.Rows[0]["id"]);
     ui.Name = Convert.ToString(dt.Rows[0]["name"]);
     ui.LoginName = loginName;
     ui.LoginPwd = Convert.ToString(dt.Rows[0]["loginPwd"]);
     ui.AllowAddGhost = Convert.ToBoolean(dt.Rows[0]["allowAddGhost"]);
     ui.IsPublicGroup = Convert.ToBoolean(dt.Rows[0]["isPublicGroup"]);
     return ui;
 }
Esempio n. 7
0
        public bool AddNewPartner(UserInfo userInfo, StringBuilder c_ids)
        {
            bool flag = false;
            using (MySql.Data.MySqlClient.MySqlConnection con = new MySqlConnection(connectStr))
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                MySqlTransaction mts = con.BeginTransaction();
                MySqlParameter[] parms = new MySqlParameter[]
                                         	{
                                     		new MySqlParameter("@yaccountType", MySqlDbType.VarChar, 20), //账户类型
                                            new MySqlParameter("@yparentId", MySqlDbType.Int32, 20), //创建者用户信息在userInfo表中的主键值
                                     		new MySqlParameter("@yloginName", MySqlDbType.VarChar, 20), //登录名
                                     		new MySqlParameter("@yloginPwd", MySqlDbType.VarChar, 20), //密码
                                     		new MySqlParameter("@yname", MySqlDbType.VarChar, 12), //姓名
                                     		new MySqlParameter("@yAllowAddGhost", MySqlDbType.Bit),
                                     		new MySqlParameter("@yisPublicGroup", MySqlDbType.Bit)
                                         	};
                parms[0].Value = "partner";
                parms[1].Value = userInfo.ParentId;
                parms[2].Value = userInfo.LoginName.ToLower();
                parms[3].Value = userInfo.LoginPwd.ToLower();
                parms[4].Value = userInfo.Name;
                parms[5].Value = userInfo.AllowAddGhost;
                parms[6].Value = userInfo.IsPublicGroup;
                try
                {
                    //if (DBHelper.ExecuteNonQuery(connectStr, CommandType.StoredProcedure, "addNewPartner", parms) != 0) flag = true;
                    int userid = Convert.ToInt32(DBHelper.ExecuteScalar(mts, CommandType.StoredProcedure, "addNewPartner", parms));
                    StringBuilder sb = new StringBuilder();
                    sb.Append("Update tab_UserCredit set TrueUserId=").Append(userid).Append(" where Id in ")
                        .Append(c_ids.ToString());
                    DBHelper.ExecuteNonQuery(mts, CommandType.Text, sb.ToString());
                    flag = true;

                    mts.Commit();
                }
                catch (Exception e)
                {
                    mts.Rollback();
                    flag = false;
                }
            }
            return flag;
        }
Esempio n. 8
0
 public void bindGVBetStatus()
 {
     string jurisdiction = AutoBwsWeb.Common.BasePage.getUserType(this.Page);
     List<Player> playerList = new List<Player>();
     DataTable tb = bvBLL.getBetFailure();
     if (null != tb && tb.Rows.Count > 0)
     {
         for (int i = 0; i < tb.Rows.Count; i++)
         {
             Player player = new Player();
             player.Id = Convert.ToInt32(tb.Rows[i]["betId"]);
             player.LoginName = Convert.ToString(tb.Rows[i]["UserId"]);
             UserInfo partner = new UserInfo();
             partner.ParentId = Convert.ToInt32(tb.Rows[i]["parentId"]);
             partner.LoginName = Convert.ToString(tb.Rows[i]["PartnerName"]);
             player.Partner = partner;
             player.Logintime = Convert.ToDateTime(tb.Rows[i]["loginTime"]);
             player.Result = Convert.ToString(tb.Rows[i]["result"]);
             player.Remark = Convert.ToString(tb.Rows[i]["remarks"]);
             if (jurisdiction.EndsWith("S"))
             {
                 playerList.Add(player);
             }
             else if (jurisdiction.EndsWith("A"))
             {
                 UserInfo currentUser = (Session["currentUser"]) as UserInfo;
                 if (null != currentUser && currentUser.Id == partner.ParentId)
                 {
                     playerList.Add(player);
                 }
             }
             else
             {
                 UserInfo currentUser = (Session["currentUser"]) as UserInfo;
                 if (null != currentUser && currentUser.LoginName == partner.LoginName)
                 {
                     playerList.Add(player);
                 }
             }
         }
     }
     this.GVBetStatus.DataSource = bvBLL.getBetFailure();
     this.GVBetStatus.DataBind();
 }
Esempio n. 9
0
 public bool AddNewAdmin(UserInfo userInfo)
 {
     bool flag = false;
     MySqlParameter[] parms = new MySqlParameter[]
                              	{
                              		new MySqlParameter("@yaccountType", MySqlDbType.VarChar, 20), //账户类型
                              		new MySqlParameter("@yloginName", MySqlDbType.VarChar, 20), //登录名
                              		new MySqlParameter("@yloginPwd", MySqlDbType.VarChar, 20), //密码
                              		new MySqlParameter("@yname", MySqlDbType.VarChar, 12), //姓名
                              		new MySqlParameter("@yviewReport", MySqlDbType.Bit, 1), //是否可以查看报表
                              		new MySqlParameter("@ycreatParterAccount", MySqlDbType.Bit, 1), //是否可以创建User
                              		new MySqlParameter("@ycreateSource", MySqlDbType.Bit, 1), //是否可以创建Source User
                              		new MySqlParameter("@ycreatePublic", MySqlDbType.Bit, 1), //是否可以创建Public User
                              		new MySqlParameter("@ychangePartnerPwd", MySqlDbType.Bit, 1), //是否可以修改User的密码
                              		new MySqlParameter("@yloginOrNot", MySqlDbType.Bit, 1),
                              		new MySqlParameter("@ParentId", MySqlDbType.Int16, 4)
                              	}; //是否已登录
     //new MySqlParameter("@yaccountOpenOrClosed", MySqlDbType.Bit, 1)     //此账户是否已关闭
     parms[0].Value = "admin";
     parms[1].Value = userInfo.LoginName.ToLower();
     parms[2].Value = userInfo.LoginPwd.ToLower();
     parms[3].Value = userInfo.Name.ToLower();
     parms[4].Value = userInfo.ViewReport;
     parms[5].Value = userInfo.CreatePartnerAccount;
     parms[6].Value = userInfo.CreateSourceUser;
     parms[7].Value = userInfo.CreatePublicUser;
     parms[8].Value = userInfo.ChangePartnerPwd;
     parms[9].Value = false;
     // parms[8].Value = false;
     parms[10].Value = userInfo.ParentId;
     try
     {
         if (DBHelper.ExecuteNonQuery(connectStr, CommandType.StoredProcedure, "addNewAdmin", parms) != 0) flag = true;
     }
     catch
     {
         throw; // new Exception(ex.ToString());
     }
     return flag;
 }
Esempio n. 10
0
 public bool AddNewPartner(UserInfo userInfo)
 {
     bool flag = false;
     MySqlParameter[] parms = new MySqlParameter[]
                              	{
                              		new MySqlParameter("@yaccountType", MySqlDbType.VarChar, 20), //账户类型
                                     new MySqlParameter("@yparentId", MySqlDbType.Int32, 20), //创建者用户信息在userInfo表中的主键值
                              		new MySqlParameter("@yloginName", MySqlDbType.VarChar, 20), //登录名
                              		new MySqlParameter("@yloginPwd", MySqlDbType.VarChar, 20), //密码
                              		new MySqlParameter("@yname", MySqlDbType.VarChar, 12), //姓名
                              		new MySqlParameter("@yAllowAddGhost", MySqlDbType.Bit),
                              		new MySqlParameter("@yisPublicGroup", MySqlDbType.Bit),
                                     new MySqlParameter("@yisAllowTesting", MySqlDbType.Bit),
                              		new MySqlParameter("@yloginOrNot", MySqlDbType.Bit),
                                     new MySqlParameter("@yexpiryDate", MySqlDbType.DateTime)
                              	};
     parms[0].Value = "partner";
     parms[1].Value = userInfo.ParentId;
     parms[2].Value = userInfo.LoginName.ToLower();
     parms[3].Value = userInfo.LoginPwd.ToLower();
     parms[4].Value = userInfo.Name;
     parms[5].Value = userInfo.AllowAddGhost;
     parms[6].Value = userInfo.IsPublicGroup;
     parms[7].Value = userInfo.IsAllowTesting;
     parms[8].Value = false;
     parms[9].Value = userInfo.ExpiryDate;
     try
     {
         if (DBHelper.ExecuteNonQuery(connectStr, CommandType.StoredProcedure, "addNewPartner", parms) != 0) flag = true;
     }
     catch
     {
         throw;
     }
     return flag;
 }
Esempio n. 11
0
 /// <summary>
 /// 获取User列表
 /// </summary>
 /// <returns></returns>
 public IList<UserInfo> GetUserList()
 {
     //MySqlConnection con = new MySqlConnection(connectStr);
     IList<UserInfo> adminList = new List<UserInfo>();
     using (con)
     {
         MySqlTransaction mts = con.BeginTransaction();
         try
         {
             StringBuilder sb = new StringBuilder();
             //sb.Append("SELECT * FROM ")
             //.Append(" (select * from UserInfo Where accountType='admin') as A ")
             //.Append(" inner join tab_UserCredit AS B on A.Id=B.UserId");
             sb.Append(
                 "select A.*,B.Name as AdminName from (select * from UserInfo Where accountType='partner') as A ")
                 .Append(" left join UserInfo B on A.ParentId=B.Id ");
             DataSet ds = DBHelper.ExecuteDataset(mts, CommandType.Text, sb.ToString());
             foreach (DataRow item in ds.Tables[0].Rows)
             {
                 var uinfo = new UserInfo();
                 uinfo.Id = int.Parse(item["Id"].ToString());
                 uinfo.Name = item["Name"].ToString();
                 uinfo.LoginName = item["LoginName"].ToString();
                 uinfo.ParentId = Convert.ToInt32(item["ParentId"]);
                 uinfo.AdminName = item["AdminName"].ToString();
                 uinfo.IsPublicGroup = (item["IsPublicGroup"].ToString() == "0" ||
                                        string.IsNullOrEmpty(item["IsPublicGroup"].ToString()))
                                       	? false
                                       	: true;
                 uinfo.AdminName = item["AdminName"].ToString() ;
                 uinfo.IsAllowTesting = (item["IsAllowTesting"].ToString() == "0" ||
                                        string.IsNullOrEmpty(item["IsPublicGroup"].ToString()))
                                       	? false
                                       	: true;
                 //uinfo.CreditList = new List<AutoBwsModel.Credit.UserCredit>(); //代码没有问题,貌似是新建CREDIT的时候给USER了一个CREDIT目前还未检查   ---已废弃
                 uinfo.CreditAvailable = Convert.ToDouble(item["CreditAvailable"].ToString());
                 uinfo.CreditUsed = Convert.ToDouble(item["CreditUsed"].ToString());
                 //    DBHelper.ExecuteDataset(mts, CommandType.Text,
                 //                            "SELECT * FROM tab_UserCredit where TrueUserId=" + item["Id"].ToString()).Tables[0];
                 //foreach (DataRow r in readerDt.Rows)
                 //{
                 //    var credit = SetModel(r);
                 //    uinfo.CreditList.Add(credit);
                 //}
                 adminList.Add(uinfo);
             }
             mts.Commit();
         }
         catch (Exception ex)
         {
             mts.Rollback();
             throw new ApplicationException(ex.Message);
         }
     }
     return adminList;
 }
Esempio n. 12
0
 /// <summary>
 /// 更新用户的点数,同时更新当前用户所在的ADMIN的点数
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="CreditCount"></param>
 public void UpdateCreditForUser(int userId, double CreditCount, bool PlusOrReduction, UserInfo currentAdmin)
 {
     string Symbol = PlusOrReduction ? "+" : "-";
     using (con)
     {
         MySql.Data.MySqlClient.MySqlTransaction ts = con.BeginTransaction();
         try
         {
             DBHelper.ExecuteNonQuery(ts, CommandType.Text,
                                      string.Format(
                                         "update userinfo set creditAvailable=creditAvailable{0}{1},isAllowTesting=0 where id={2}",
                                      	Symbol, CreditCount, userId));
             if (PlusOrReduction)
             {
                 DBHelper.ExecuteNonQuery(ts, CommandType.Text,
                                          string.Format(
                                          	"update userinfo set creditAvailable=creditAvailable-{0},creditUsed=creditUsed+{0} where id={1}",
                                          	CreditCount, currentAdmin.Id));
             }
             else
             {
                 DBHelper.ExecuteNonQuery(ts, CommandType.Text,
                                          string.Format(
                                          	"update userinfo set creditAvailable=creditAvailable+{0},creditUsed=creditUsed-{0} where id={1}",
                                          	CreditCount, currentAdmin.Id));
             }
             ts.Commit();
         }
         catch
         {
             ts.Rollback();
         }
     }
 }
Esempio n. 13
0
 public bool AddNewAdmin(UserInfo userInfo)
 {
     return adminSService.AddNewAdmin(userInfo);
 }
Esempio n. 14
0
 /// <summary>
 /// 获取ADMIN列表
 /// </summary>
 /// <returns></returns>
 public IList<UserInfo> GetAdminList()
 {
     //MySqlConnection con = new MySqlConnection(connectStr);
     IList<UserInfo> adminList = new List<UserInfo>();
     using (con)
     {
         MySqlTransaction mts = con.BeginTransaction();
         try
         {
             StringBuilder sb = new StringBuilder();
             //sb.Append("SELECT * FROM ")
             //.Append(" (select * from UserInfo Where accountType='admin') as A ")
             //.Append(" inner join tab_UserCredit AS B on A.Id=B.UserId");
             sb.Append("select * from UserInfo Where accountType='admin' ");
             DataSet ds = DBHelper.ExecuteDataset(mts, CommandType.Text, sb.ToString());
             foreach (DataRow item in ds.Tables[0].Rows)
             {
                 var uinfo = new UserInfo();
                 uinfo.Id = int.Parse(item["Id"].ToString());
                 uinfo.Name = item["Name"].ToString();
                 uinfo.LoginName = item["LoginName"].ToString();
                 //	uinfo.CreditList = new List<AutoBwsModel.Credit.UserCredit>();
                 uinfo.CreditAvailable = Convert.ToDouble(item["CreditAvailable"].ToString());
                 //var readerDt =
                 //    DBHelper.ExecuteDataset(mts, CommandType.Text,
                 //                            "SELECT * FROM tab_UserCredit where UserId=" + item["Id"].ToString()).Tables[0];
                 //foreach (DataRow r in readerDt.Rows)
                 //{
                 //    var credit = SetModel(r);
                 //    uinfo.CreditList.Add(credit);
                 //}
                 adminList.Add(uinfo);
             }
             mts.Commit();
         }
         catch
         {
             mts.Rollback();
         }
     }
     return adminList;
 }
Esempio n. 15
0
 public bool AddNewAdminWithCredits(UserInfo userInfo, UserCredit credit, int numberOfCredits)
 {
     return adminSService.AddNewAdminWithCredits(userInfo, credit, numberOfCredits);
 }
Esempio n. 16
0
        public bool UpdateAdmin(UserInfo userInfo)
        {
            bool isSuccess = false;
            MySqlParameter[] parms = new MySqlParameter[]
                                     	{
            //                                                     new MySqlParameter("@yaccountType", MySqlDbType.VarChar,20),           //账户类型
                                     		new MySqlParameter("@yid", MySqlDbType.Int16, 20), //登录名
                                     		new MySqlParameter("@yloginPwd", MySqlDbType.VarChar, 20), //密码
                                     		new MySqlParameter("@yname", MySqlDbType.VarChar, 12), //姓名
            //                                                     new MySqlParameter("@yviewReport", MySqlDbType.Bit,1),                 //是否可以查看报表
            //                                                     new MySqlParameter("@ycreatParterAccount", MySqlDbType.Bit,1),         //是否可以创建User
                                     		new MySqlParameter("@ycreateSource", MySqlDbType.Bit, 1), //是否可以创建Source User
                                     		new MySqlParameter("@ycreatePublic", MySqlDbType.Bit, 1) //是否可以创建Public User
            //                                                     new MySqlParameter("@ychangePartnerPwd", MySqlDbType.Bit,1)           //是否可以修改User的密码
            //                                                     new MySqlParameter("@yloginOrNot", MySqlDbType.Bit,1),
            //                                                     new MySqlParameter("@ystate",MySqlDbType.Bit,1)
                                     	};
            //            parms[0].Value = "admin";
            parms[0].Value = userInfo.Id;
            parms[1].Value = userInfo.LoginPwd.ToLower();
            parms[2].Value = userInfo.Name.ToLower();
            parms[3].Value = userInfo.CreateSourceUser;
            parms[4].Value = userInfo.CreatePublicUser;
            //            parms[4].Value = userInfo.ViewReport;
            //            parms[5].Value = userInfo.CreatePartnerAccount;
            //            parms[8].Value = userInfo.ChangePartnerPwd;
            //            parms[9].Value = false;
            //            parms[10].Value = userInfo.State;

            try
            {
                if (DBHelper.ExecuteNonQuery(connectStr, CommandType.StoredProcedure, "updateAdmin", parms) != 0)
                    isSuccess = true;
            }
            catch
            {
                return false;
            //                throw;
            }

            return isSuccess;
        }
Esempio n. 17
0
        public UserInfo checkLogin(string loginName, string loginPwd)
        {
            MySqlParameter[] parms = new MySqlParameter[]
                                     	{
                                     		new MySqlParameter("@yloginName", MySqlDbType.VarChar, 20),
                                     		new MySqlParameter("@yloginPwd", MySqlDbType.VarChar, 20)
                                     	};
            parms[0].Value = loginName;
            parms[1].Value = loginPwd;
            UserInfo userInfo = null;
            DataTable dt = null;
            try
            {
                DataSet ds = DBHelper.ExecuteDataset(connectStr, CommandType.StoredProcedure, "loginByLoginNameAndloginPwd", parms);
                if (ds != null && ds.Tables.Count > 0)
                {
                    dt = ds.Tables[0];
                    if (dt.Rows.Count > 0)
                    {
                        userInfo = new UserInfo();
                        userInfo.Name = Convert.ToString(dt.Rows[0]["name"]); //姓名
                        userInfo.ViewReport = Convert.ToBoolean(dt.Rows[0]["viewReport"] == DBNull.Value ? false : true); //是否有查看报表的权限
                        userInfo.ChangePartnerPwd = Convert.ToBoolean(dt.Rows[0]["changePartnerPwd"] == DBNull.Value ? false : true);
                        //是否有修改Partner密码的权限
                        userInfo.CompanyRelated = Convert.ToBoolean(dt.Rows[0]["companyRelated"] == DBNull.Value ? false : true);
                        //companyRelated
                        userInfo.CreatePartnerAccount = Convert.ToBoolean(dt.Rows[0]["creatParterAccount"] == DBNull.Value ? false : true);
                        //是否有新建Partner的权限
                        userInfo.AccountType = Convert.ToString(dt.Rows[0]["accountType"]); //账户类型
                        userInfo.LoginName = loginName;
                        userInfo.LoginPwd = loginPwd;

                        // Michael
                        //dean 这两句代码咋的呢,一个属性表示两个意思?我先注释一条哈
                        userInfo.CreditAvailable = Convert.ToDouble(dt.Rows[0]["creditAvailable"]);
                        userInfo.CreditUsed = Convert.ToInt32(dt.Rows[0]["creditUsed"] == DBNull.Value ? 0 : dt.Rows[0]["creditUsed"]);//dean add
                    //	userInfo.CreditAvailable = Convert.ToDouble(dt.Rows[0]["creditUsed"].ToString());
                        userInfo.ExpiryDate = Convert.ToDateTime(dt.Rows[0]["expiryDate"]==DBNull.Value?DateTime.Parse("1900-1-1"):dt.Rows[0]["expiryDate"]);
                        // Michael

                        userInfo.P1 = Convert.ToInt32(dt.Rows[0]["P1"] == DBNull.Value ? 0 : dt.Rows[0]["P1"]);
                        userInfo.P2 = Convert.ToInt32(dt.Rows[0]["P2"] == DBNull.Value ? 0 : dt.Rows[0]["P2"]);
                        userInfo.P3 = Convert.ToInt32(dt.Rows[0]["P3"] == DBNull.Value ? 0 : dt.Rows[0]["P3"]);
                        userInfo.LoginOrNot = true; //是否登录
                        userInfo.AccountType = Convert.ToString(dt.Rows[0]["accountType"]); //账户类型
                        userInfo.Agreelaw = Convert.ToBoolean(dt.Rows[0]["agreedLaw"]);
                        userInfo.State = dt.Rows[0]["state"].ToString();

                        userInfo.IsPublicGroup = (dt.Rows[0]["IsPublicGroup"].ToString() == "0" ||
                                                  string.IsNullOrEmpty(dt.Rows[0]["IsPublicGroup"].ToString()))
                                                 	? false
                                                 	: true;
                        userInfo.Id = Convert.ToInt32(dt.Rows[0]["Id"].ToString());

                        //modified by dean
                        userInfo.CreditList = new List<AutoBwsModel.Credit.UserCredit>();

                        StringBuilder str = new StringBuilder();
                        str.Append("SELECT * FROM tab_UserCredit")
                            .Append(" where {0}=").Append(userInfo.Id);
                        switch (userInfo.AccountType)
                        {
                            case "admin":
                                str = str.Replace("{0}", "UserId");
                                break;
                            case "partner":

                                str = str.Replace("{0}", "TrueUserId"); // ;// string.Format(str.ToString(), "TrueUserId");
                                break;
                            case "superadmin":
                                str.Remove(0, str.Length);
                                str.Append("SELECT * FROM tab_UserCredit");
                                break;
                        }
                        DataSet dsC = DBHelper.ExecuteDataset(connectStr, CommandType.Text, str.ToString());
                        foreach (DataRow r in dsC.Tables[0].Rows)
                        {
                            var credit = AutoBwsServics.Credit.CreditService.SetModel(r);
                            userInfo.CreditList.Add(credit);
                        }
                        //   userInfo.CreditList.Add(uinfo);
                    }
                }
                return userInfo;
            }
            catch
            {
                throw;
            }
        }
Esempio n. 18
0
 public bool UpdateAdmin(UserInfo admin)
 {
     return adminSService.UpdateAdmin(admin);
 }
Esempio n. 19
0
 public static bool AddNewPartner(UserInfo userInfo)
 {
     return pService.AddNewPartner(userInfo);
 }
Esempio n. 20
0
 public static bool AddNewPartner(UserInfo userInfo, StringBuilder ids)
 {
     return pService.AddNewPartner(userInfo, ids);
 }
Esempio n. 21
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (HttpContext.Current.Session["currentUser"] == null)
         HttpContext.Current.Response.Redirect("~/Default.aspx");
     else
         loginName = ((UserInfo)Session["currentUser"]).LoginName;
     user = Session["currentUser"] as UserInfo;
     accountType = user.AccountType;
     today = Convert.ToString(DateTime.Today.ToShortDateString());
     Yesterday = Convert.ToString(DateTime.Today.AddDays(-1).ToShortDateString());
     jurisdiction = AutoBwsWeb.Common.BasePage.getUserType(this.Page);
     if (!IsPostBack) bindGridViewPV(DateTime.MinValue, DateTime.MaxValue);
 }
Esempio n. 22
0
        public bool UpdatePartner(UserInfo userInfo)
        {
            bool isSuccess = false;
            MySqlParameter[] parms = new MySqlParameter[]
                                     	{
                                     		new MySqlParameter("@yaccountType", MySqlDbType.VarChar, 20), //账户类型
                                     		new MySqlParameter("@yloginName", MySqlDbType.VarChar, 20), //登录名
                                     		new MySqlParameter("@yloginPwd", MySqlDbType.VarChar, 20), //密码
                                     		new MySqlParameter("@ycompanyRelated", MySqlDbType.Bit, 1),
                                     		new MySqlParameter("@yip", MySqlDbType.VarChar, 20),
                                     		new MySqlParameter("@ystate", MySqlDbType.Bit, 1),
                                     		new MySqlParameter("@yisPublicGroup", MySqlDbType.Bit, 1)
                                     	}; //是否已登录
            //new MySqlParameter("@yaccountOpenOrClosed", MySqlDbType.Bit, 1)      //此账户是否已关闭
            parms[0].Value = userInfo.AccountType;
            parms[1].Value = userInfo.LoginName.ToLower();
            parms[2].Value = userInfo.LoginPwd.ToLower();
            parms[3].Value = userInfo.CompanyRelated;
            parms[4].Value = userInfo.Ip;
            parms[5].Value = userInfo.State;
            parms[6].Value = userInfo.IsPublicGroup;

            try
            {
                if (DBHelper.ExecuteNonQuery(connectStr, CommandType.StoredProcedure, "updatePartner", parms) != 0)
                    isSuccess = true;
            }
            catch
            {
                throw;
            }
            return isSuccess;
        }
Esempio n. 23
0
 public static bool UpdatePartner(UserInfo partner)
 {
     return pService.UpdatePartner(partner);
 }