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
 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. 3
0
 public bool AddNewAdminWithCredits(UserInfo userInfo, UserCredit credit, int numberOfCredits)
 {
     return adminSService.AddNewAdminWithCredits(userInfo, credit, numberOfCredits);
 }