Example #1
0
        public async Task Register()
        {
            RegisterModel model = JsonConvert.DeserializeObject <RegisterModel>(new System.IO.StreamReader(Request.Body).ReadLine());
            CUser         user  = _context.CUser.FirstOrDefault(u => u.Login == model.Login || u.Email == model.Email);

            if (user == null)
            {
                _context.CUser.Add(new CUser {
                    Login = model.Login, Email = model.Email, Password = _crypt.GetHash(model.Password), FirstName = model.FirstName, LastName = model.LastName
                });
                await _context.SaveChangesAsync();

                var identity = GetIdentity(model.Login, model.Password);
                var response = GenerateToken(identity);

                Response.ContentType = "application/json";
                await Response.WriteAsync(JsonConvert.SerializeObject(response, new JsonSerializerSettings {
                    Formatting = Formatting.Indented
                }));

                return;
            }
            else
            {
                Response.ContentType = "application/json";
                Response.StatusCode  = 400;
                await Response.WriteAsync("Пользователь с таким" + user.Login == model.Login? "логином" : "Email" + " уже существует");

                return;
            }
        }
 protected void SubmitBtn_Click()
 {
     CUser user = new CUser();
     List<CUser> userList = new List<CUser>();
     userList=user.GetUserById(Convert.ToInt32(Session["user_id"]));
     MD5 md5hash = MD5.Create();
     if (userList.Count > 0 )
     {
         try
         {
             bool found = false;
             foreach (CUser u in userList)
             {
                 if (u.user_password == user.GetMd5Hash(md5hash, old_password.Text))
                 {
                     user.user_id = Convert.ToInt32(Session["user_id"]);
                     user.updated_by = (string)Session["user_name"];
                     user.user_password = user.GetMd5Hash(md5hash, new_password.Text);
                     user.UpdatePassword();
                     found = true;
                     ltrlmsg.Text = "<div class=\"alert alert-success\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button> Password Update Success</div>";
                 }
             }
             if (found == false)
             {
                 ltrlmsg.Text = "<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button> Old Password Error</div>";
             }
         }
         catch (Exception ex)
         {
             ltrlmsg.Text = "<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button> " + ex.Message + "</div>";
         }
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request["lang"] != null)
            {
                if (Request["lang"] == "en")
                {
                    Session["lang"] = "en";
                }
                else
                {
                    Session["lang"] = "my";
                }
            }
            if (HttpContext.Current.Request.Cookies["user_email"]!=null && Session["user_name"]==null)
            {
                CUser userObj = new CUser();
                List<CUser> lstUser=new List<CUser>();
                lstUser=userObj.GetUserByEmail(HttpContext.Current.Request.Cookies["user_email"].Value);
                if (lstUser.Count() > 0)
                {
                    RegisterSession(lstUser);
                    //throw new Exception("cookies");
                }

            }

            if ((string)Session["user_email"] == null)
            {
                Response.Redirect("Login.aspx");
            }

            //initz initObj = new initz();
            //List<Dictionary<string, Object>> primary_nav = new List<Dictionary<string, object>>();
            //primary_nav = initObj.primary_nav;
        }
Example #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["User"] == null)
        {
            Response.Redirect("../Login.aspx");
            Response.End();
        }
        m_User = (CUser)Session["User"];

        m_Table = m_User.FriendMgr.Table;

        if (Request.Params["Action"] == "GetData")
        {
            GetData();
            Response.End();
        }
        else if (Request.Params["Action"] == "Add")
        {
            Add();
            Response.End();
        }
        else if (Request.Params["Action"] == "Delete")
        {
            Delete();
            Response.End();
        }
        else if (Request.Params["Action"] == "GetFriendState")
        {
            GetFriendState();
            Response.End();
        }
    }
Example #5
0
        private void btOK_Click(object sender, EventArgs e)
        {
            string sUser = txtUser.Text.Trim();
            string sPwd  = txtPwd.Text.Trim();

            if (sUser == "")
            {
                MessageBox.Show("请输入帐号!");
                return;
            }

            CUserMgr userMgr = Program.Ctx.UserMgr;

            CUser user = Program.Ctx.UserMgr.FindByName(sUser);

            if (user == null)
            {
                MessageBox.Show("帐号错误!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            if (user.Pwd != sPwd)
            {
                MessageBox.Show("帐号错误!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }

            Program.User = user;

            DialogResult = DialogResult.OK;
        }
Example #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["User"] == null)
        {
            Response.Redirect("../Login.aspx");
            Response.End();
        }
        m_User = (CUser)Session["User"];

        string to_id = Request["to_id"];

        if (string.IsNullOrEmpty(to_id))
        {
            Response.Write("没有好友!");
            Response.End();
        }
        m_FriendUser = (CUser)Global.GetCtx(Session["TopCompany"].ToString()).UserMgr.Find(new Guid(to_id));
        if (m_FriendUser == null)
        {
            Response.Write("没有好友!");
            Response.End();
        }


        if (Request.Params["Action"] == "Send")
        {
            Send();
            Response.End();
        }
        else if (Request.Params["Action"] == "GetMessage")
        {
            GetMessage();
            Response.End();
        }
    }
Example #7
0
        private void LoadUserData()
        {
            lvUserList.Items.Clear();
            CUserBO oUserBO = new CUserBO();
            CResult oResult = new CResult();
            CUser   oUser   = new CUser();

            oResult = oUserBO.ReadAllUserData(oUser);
            if (oResult.IsSuccess)
            {
                foreach (CUser obj in oResult.Data as ArrayList)
                {
                    ListViewItem oItem = new ListViewItem();
                    oItem.Text = obj.User_OID.ToString();
                    oItem.SubItems.Add(obj.User_UserID).ToString();

                    // oItem.SubItems.Add(obj.User_UserName).ToString();
                    oItem.SubItems.Add(obj.User_UserType).ToString();
                    oItem.SubItems.Add(obj.User_Branch).ToString();
                    oItem.SubItems.Add(obj.User_UserStatus).ToString();
                    oItem.SubItems.Add(obj.User_Passward).ToString();
                    lvUserList.Items.Add(oItem);
                }



                //dgvUserList.DataSource = oResult.Data;
            }
            else
            {
                MessageBox.Show(oResult.ErrMsg.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #8
0
    public virtual bool InsertNew(CDatabase db, CUser user, T obj)
    {
        Clear();
        string strQuery = GetInsertQuery(user, obj);

        if (strQuery == "")
        {
            return(false);
        }

        int ID = 0;

        try
        {
            using (MySqlCommand cmd = new MySqlCommand(strQuery, db.connection))
                cmd.ExecuteNonQuery();

            ID = GetLastInsertIndex(db);
        }
        catch (Exception e)
        {
            Debug.Assert(false, e.ToString());
            return(false);
        }
        return((ID > 0) && Load(db, ID, user));
    }
 private void lblSave_Click(object sender, EventArgs e)
 {
     if (txtPwd2.Text.Equals(txtPwd3.Text))
     {
         if (flag == true)
         {
             FileStream fs     = new FileStream(filename, FileMode.Open, FileAccess.Read);
             Byte[]     mybyte = new byte[fs.Length];
             fs.Read(mybyte, 0, mybyte.Length);
             fs.Close();
             user = new CUser("null", CUser.doSome.Update);
             if (user.Update(txtEmail.Text, txtName.Text, txtPhone.Text, txtSex.Text, txtAddress.Text, txtPwd2.Text, mybyte, lblPwd2.Visible))
             {
                 MessageBox.Show("修改成功!!");
             }
         }
         else
         {
             user = new CUser(UserEmail, CUser.doSome.initialization);
             Byte[] mybyte = user.getUserPic(user.CUserEmail);
             user = new CUser("null", CUser.doSome.Update);
             if (user.Update(txtEmail.Text, txtName.Text, txtPhone.Text, txtSex.Text, txtAddress.Text, txtPwd2.Text, mybyte, lblPwd2.Visible))
             {
                 MessageBox.Show("修改成功!!");
             }
         }
     }
     else
     {
         MessageBox.Show("两次密码不相等!!");
         txtPwd2.Focus();
     }
 }
Example #10
0
        public async Task <ActionResult <CUser> > PostCUser(CUser cUser)
        {
            _context.CUser.Add(cUser);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCUser", new { id = cUser.Id }, cUser));
        }
Example #11
0
        public async Task <IActionResult> PutCUser(int id, CUser cUser)
        {
            if (id != cUser.Id)
            {
                return(BadRequest());
            }

            _context.Entry(cUser).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CUserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #12
0
        public void LoadUserTest()
        {
            CUser user = new CUser(Guid.NewGuid(), "Casey", "Kelpinski", "*****@*****.**", "password");

            user.Load();
            Assert.IsTrue(user.Id != null);
        }
Example #13
0
        public ActionResult List(int pageNum = 0)
        {
            if (Request.IsAuthenticated)
            {
                CUser  clUser = new CUser(LocalData.UserId(), LocalData.CSDbUsers(), LocalData.LogPath());
                STUser stUser;
                string msg;
                clUser.GetRecordByUserId(LocalData.UserId(), out stUser, out msg);
                if (!stUser.oldpass)
                {
                    STTransactVP param;
                    if (Session["TRANSACTPARAM"] != null)
                    {
                        param = (STTransactVP)Session["TRANSACTPARAM"];
                    }
                    else
                    {
                        param = new STTransactVP();
                    }

                    if (!SharedModel.IsConnect(LocalData.CSDbTransacts1(), out msg) &&
                        !SharedModel.IsConnect(LocalData.CSDbTransacts2(), out msg))
                    {
                        ViewData["ERROR"] = "No connection to DB";
                        ViewData["MSG"]   = msg;

                        //return RedirectToAction("Index", "Error");
                        return(View("Index"));
                    }
                    else
                    {
                        string[] arr = new[] { "'", "\"", "--" };
                        if (CheckerField.CheckField(arr, param.maskedpan, param.maskedpos))
                        {
                            ViewData["MSG"] = "One or more fields contain invalid characters.";
                            return(View("Errors"));
                        }
                        else
                        {
                            List <TransactModels> lst = TransactModelsRepository.Instance.GetListTransact(param);
                            ViewData["PageNum"]    = pageNum;
                            ViewData["ItemsCount"] = lst.Count;
                            ViewData["PageSize"]   = pageSize;
                            ViewData["STRPARAM"]   = param.strdata;

                            return(View(TransactModelsRepository.Instance.GetListTransact(pageSize, pageNum, param)));
                        }
                    }
                }
                else
                {
                    return(RedirectToAction("ChangePassword", "Account"));
                }
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["User"] == null)
        {
            Response.End();
        }
        m_User = (CUser)Session["User"];

        string vid = Request["vid"];

        if (string.IsNullOrEmpty(vid))
        {
            Response.End();
        }
        string vdid = Request["vdid"];

        if (string.IsNullOrEmpty(vdid))
        {
            Response.End();
        }
        m_View = (CView)Global.GetCtx(Session["TopCompany"].ToString()).ViewMgr.Find(new Guid(vid));
        if (m_View == null)
        {
            Response.End();
        }
        m_ViewDetail = (CViewDetail)m_View.ViewDetailMgr.Find(new Guid(vdid));
        if (m_ViewDetail == null)
        {
            Response.End();
        }
        m_Table = (CTable)Global.GetCtx(Session["TopCompany"].ToString()).TableMgr.Find(m_ViewDetail.FW_Table_id);

        //检查权限
        if (!CheckAccess())
        {
            Response.End();
        }

        if (Session["EditMultMasterDetailViewRecord"] == null)
        {
            Response.End();
        }

        SortedList <Guid, CBaseObject> arrP = (SortedList <Guid, CBaseObject>)Session["EditMultMasterDetailViewRecord"];
        CBaseObject objP = (CBaseObject)arrP.Values[0];

        m_BaseObjectMgr = objP.GetSubObjectMgr(m_Table.Code, typeof(CBaseObjectMgr));

        if (Request.Params["Action"] == "GetData")
        {
            GetData();
            Response.End();
        }
        else if (Request.Params["Action"] == "Delete")
        {
            Delete();
            Response.End();
        }
    }
Example #15
0
    protected void Login_Click(object sender, EventArgs e)
    {
        if (IsValid)
        {
            var cUser = new CUser();
            var user  = cUser.Get(tbUsername.Text.Trim());
            if (user != null)
            {
                if (CCryptography.DecryptCipherTextToPlainText(user.Password.Trim()) == tbPassword.Text.Trim())
                {
                    if (user.IsActive)
                    {
                        btLogin.Enabled = false;

                        Session["UserId"]         = user.UserId;
                        Session["SiteLocationId"] = user.SiteLocationId;
                        var siteLocation = (new CSiteLocation()).Get(user.SiteLocationId);
                        if (siteLocation != null)
                        {
                            Session["SiteId"]           = siteLocation.SiteId;
                            Session["SiteName"]         = new CSite().Get(siteLocation.SiteId)?.Abbreviation;
                            Session["SiteLocationName"] = siteLocation.Name;
                        }
                        Session["UserName"]       = cUser.GetUserName(user);
                        Session["UserPositionId"] = user.UserPositionId;
                        var userPosition = (new CUserPosition()).Get(user.UserPositionId);
                        if (userPosition != null)
                        {
                            Session["UserGroupId"] = userPosition.UserGroupId;
                        }

                        var userPermissionModelList = (new CUserPermission()).GetUserPermissionModelList(user.UserId);
                        Session["UserPermissionModelList"] = userPermissionModelList;

                        RadAjaxPanel1.Redirect("~/Dashboard");
                    }
                    else
                    {
                        ShowMessage("Your account is disabled<br /><br />Please contact administrator.");
                    }

                    // set cookie
                    WriteCookie("IsKeepSign", RadButtonKeepSign.Checked ? "1" : "0");
                    if (RadButtonKeepSign.Checked)
                    {
                        WriteCookie("Username", tbUsername.Text.Trim());
                    }
                }
                else
                {
                    ShowMessage("Wrong Password<br /><br />Please try again!");
                }
            }
            else
            {
                ShowMessage("Invalid Login Id<br /><br />Please try again!");
            }
        }
    }
Example #16
0
 public ActionResult Registration(CUser aUser)
 {
     if (aUser != null)
     {
         return(RedirectToAction("JoinOK", aUser));
     }
     return(View(aUser));
 }
Example #17
0
    //////////////////////////////////////////////////////////////////////
    public CUser GetUser(int userID)
    {
        CUser user = null;

        lock (m_Users)
            m_Users.TryGetValue(userID, out user);
        return(user);
    }
Example #18
0
        //helper
        private DataAccess getDA()
        {
            GenericCompany company = new GenericCompany("12345");//load default company
            CUser          user    = new CUser(company, "*****@*****.**");
            DataAccess     da      = new DataAccess(company, user);

            return(da);
        }
Example #19
0
 private void display(CUser p_user)
 {
     _txt帳號.Text          = p_user.f_userid帳號;
     _txt密碼.Text          = p_user.f_password密碼;
     _txt姓名.Text          = p_user.f_username姓名;
     _ddl所別.SelectedValue = p_user.f_branchid所別;
     _ddl等級.SelectedValue = p_user.f_lvl等級.ToString();
 }
Example #20
0
 /// <summary>
 /// get the user by the internal ID -used internally
 /// </summary>
 /// <param name="id">internal DB id</param>
 /// <returns>a populated user object</returns>
 public CUser getUserById(int id)
 {
     if (user == null)
     {
         user = new CUser(company, id);
     }
     return(db.getUserById(user));
 }
Example #21
0
 public override bool Load(CDatabase db, int ID, CUser user)
 {
     if (!Load(db, GetLoadQuery(ID, user)))
     {
         return(false);
     }
     return(true);
 }
Example #22
0
        private void display工單(CWork p_work)
        {
            _lbl工單種類.Text  = p_work.f_type工單種類;
            _lbl工單種類1.Text = p_work.f_type工單種類;

            _lbl工單單號.Text  = p_work.f_workid工單單號;
            _lbl工單單號1.Text = p_work.f_workid工單單號;
            _lbl引擎號碼.Text  = p_work.f_engo引擎號碼;
            _lbl引擎號碼1.Text = p_work.f_engo引擎號碼;

            CUser l_user顧客名稱 = _context.CFactoryManager.CUserFactory.get高都員工檔(p_work.f_customerid顧客名稱);

            if (l_user顧客名稱 == null)
            {
                _lbl顧客名稱.Text  = p_work.f_customerid顧客名稱;
                _lbl顧客名稱1.Text = p_work.f_customerid顧客名稱;
            }
            else
            {
                _lbl顧客名稱.Text  = p_work.f_customerid顧客名稱 + "(" + l_user顧客名稱.f_username姓名 + ")";
                _lbl顧客名稱1.Text = p_work.f_customerid顧客名稱 + "(" + l_user顧客名稱.f_username姓名 + ")";;
            }


            _lbl洗車種類.Text = p_work.f_workType洗車種類 + "(" +
                            _context.CFactoryManager.CWorkTypeFactory.
                            getCWorkTypeBy代碼(p_work.f_workType洗車種類).f_typename洗車種類名稱 + ")";
            _lbl洗車種類1.Text = _lbl洗車種類.Text;
            _lbl金額.Text    = p_work.f_money金額.ToString();
            _lbl金額1.Text   = p_work.f_money金額.ToString();
            _lbl備註.Text    = p_work.f_memo備註;
            _lbl備註1.Text   = p_work.f_memo備註;

            if ("F1000".Equals(p_work.f_edituser開單人員))
            {
                p_work.f_edituser開單人員 = "F1001";
            }
            CUser l_user = _context.CFactoryManager.CUserFactory.get高都員工檔(p_work.f_edituser開單人員);

            if (!"".Equals(p_work.f_seruser服務專員))
            {
                _lbl開單人員.Text  = p_work.f_edituser開單人員 + "(" + l_user.f_username姓名 + ")" + " 專員:" + p_work.f_seruser服務專員;
                _lbl開單人員1.Text = p_work.f_edituser開單人員 + "(" + l_user.f_username姓名 + ")" + " 專員:" + p_work.f_seruser服務專員;
            }
            else
            {
                _lbl開單人員.Text  = p_work.f_edituser開單人員 + "(" + l_user.f_username姓名 + ")";
                _lbl開單人員1.Text = p_work.f_edituser開單人員 + "(" + l_user.f_username姓名 + ")";
            }
            _lbl開單日期.Text  = p_work.f_editdate開單日期;
            _lbl開單日期1.Text = p_work.f_editdate開單日期;
            _lbl介紹人.Text   = p_work.f_introducer介紹人;
            _lbl介紹人1.Text  = p_work.f_introducer介紹人;
            _lbl保險代碼.Text  = p_work.f_insuranceid保險代碼;
            _lbl保險代碼1.Text = p_work.f_insuranceid保險代碼;
            _lbl工單所別.Text  = p_work.f_branchid工單所別;
            _lbl工單所別1.Text = p_work.f_branchid工單所別;
        }
Example #23
0
 /// <summary>
 /// 验证密码
 /// </summary>
 /// <param name="userid"></param>
 /// <param name="pwd"></param>
 /// <param name="outmsg"></param>
 /// <returns></returns>
 public static bool CheckLoginPwd(int userid, string pwd, out string outmsg)
 {
     if (IsDevelopment)
     {
         outmsg = "成功";
         return(true);
     }
     return(CUser.CheckLoginPwd(userid, pwd, out outmsg));
 }
Example #24
0
        public DataSet[] GetUserYearRequests(int iUserId, int iYearId)
        {
            DataSet[] dsArrayReturn = new DataSet[2];
            DataSet   ds            = CUser.GetUserVacationsAndDaysOff(iUserId, iYearId);

            dsArrayReturn[0] = ds;
            dsArrayReturn[1] = CalendarDates(ds);
            return(dsArrayReturn);
        }
Example #25
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["User"] == null)
     {
         Response.Write("<script>window.location='login.aspx'</script>");
         Response.End();
     }
     m_User = (CUser)Session["User"];
 }
Example #26
0
 private void TextBoxName_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     if (((TextBox)sender).IsReadOnly)
     {
         _user = null;
         ((TextBox)sender).Text       = "Имя абитуриента";
         ((TextBox)sender).IsReadOnly = false;
     }
 }
Example #27
0
        public void Add()
        {
            try
            {
                //veriables
                decimal quan;
                double  pps;

                //parse
                decimal.TryParse(txtQuantity.Text, out quan);
                double.TryParse(txtPPS.Text, out pps);

                //new transaction
                CCryptoTran tran = new CCryptoTran();

                //contents
                tran.StockId           = tran.GetGuid(cboName.SelectedValue.ToString());
                tran.TransDate         = DTP.SelectedDate.Value;
                tran.Quantity          = quan;
                tran.PricePerSharePaid = pps;

                //if
                if ((bool)rdoBuy.IsChecked)
                {
                    tran.Buy = true;
                }
                if ((bool)rdoSell.IsChecked)
                {
                    tran.Buy = false;
                }

                //insert
                //tran.Insert(cboName.SelectedValue.ToString());

                MessageBox.Show("Transaction successfuly added", "Yay!");

                //email
                CUser u = new CUser();
                //u.SendEmail();

                //close form
                //this.Close();
                // I have decided to not close the form after adding a transaction
                // for usability reasons. It is annoying to enter multiple transactions
                // and clicking to open the dialog box again and again

                txtPPS.Text      = string.Empty;
                txtQuantity.Text = string.Empty;
                DTP = null;
                rdoBuy.IsChecked  = false;
                rdoSell.IsChecked = false;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #28
0
        public async Task Hi(IDialogContext context, LuisResult result)
        {
            string     msg1 = "Hello {0} !" + "\r\nWelcome to {1}, I'm your VirtualAssistance and here to get you started.";
            DataAccess da   = getDA();
            CUser      user = da.getUserByEmail("*****@*****.**");
            await context.PostAsync(string.Format(msg1, user.Username, user.Company.CompanyName));

            context.Wait(MessageReceived);
        }
Example #29
0
 //ф-ия отключения клиента от сервера
 public void Disconnect()
 {
     m_userInGame.Remove(this.m_user);
     sendMessageAllUsers(m_userInGame, this.m_user.getUserName(), false);
     MessageBox.Show("Игрок " + this.m_user.getUserName() + " отсоединился");
     this.m_user = null;
     //Закрываем канал связи с текущим пользователем
     OperationContext.Current.Channel.Close();
 }
Example #30
0
 public FormPay(string goodId, string userEmail, int num)
 {
     InitializeComponent();
     good     = new JDGood(goodId);
     user     = new CUser(userEmail, CUser.doSome.initialization);
     this.num = num;
     price    = Convert.ToDouble(good.GoodPrice);
     balance  = Convert.ToDouble(user.CUserBalance);
 }
Example #31
0
        /* what to impletement the ************************************************************************************************
         * Step 1: Confirm Subscription
         *
         *  for Onboarding
         * *************************************************************************************************************************/

        //get the user by the email that they tell use
        public CUser getUserByEmail(string email)
        {
            if (user == null)
            {
                user = new CUser(company, email);
            }

            return(db.getUserByEmail(user));
        }
Example #32
0
 // GET: Crypto/Create
 public ActionResult Create()
 {
     if (Session["user"] == null)
     {
         CUser user = new CUser();
         return(View(user));
     }
     return(RedirectToAction("Index", "Home"));
 }
Example #33
0
 public IActionResult Index(CUser ur)
 {
     if (ModelState.IsValid)
     {
         cdal.InsertUser(ur);
         ViewData["Message"] = " The New User Name " + ur.DESCRIPTION + " Is Saved Succesfully!";
     }
     return(View(ur));
 }
        public static string Submit(string user_name,string user_password, bool ischecked)
        {
            string strErr = "";
            TextBox txt_login_email;
            TextBox txt_login_password;
            Page page = (Page)HttpContext.Current.Handler;
            if (user_name.Trim() == "" || user_password.Trim() == "")
            {
                strErr = "<div class='alert alert-danger'><i class='fa fa-bell-o'></i>  Username/Email or Password still empty! </div>";
            }
            else
            {

                //           string str_login_email = Microsoft.Security.Application.Encoder.JavaScriptEncode(user_name);
                //           string str_login_password = Microsoft.Security.Application.Encoder.JavaScriptEncode(user_password);

                using (MD5 md5Hash = MD5.Create())
                {
                    CUser userObj = new CUser();
                    string hash = userObj.GetMd5Hash(md5Hash, user_password);
                    List<CUser> lstUser = new List<CUser>();
                    lstUser = userObj.Login(user_name, hash);
                    if (lstUser.Count() > 0)
                    {
                        Login objLogin = new Login();
                        objLogin.RegisterSession(lstUser);
                        if (ischecked == true)
                        {
                            Login objLogin2 = new Login();
                            objLogin2.RegisterCookie(lstUser);
                        }
                    }
                    else
                    {
                        strErr = "<div class='alert alert-danger'><i class='fa fa-bell-o'></i>  Username/Email and Password is wrong! </div>";
                    }
                }

            }
            return strErr;
        }
Example #35
0
 //ф-ия подключения клиента к серверу
 public bool Connect(string name)
 {
     if (validateUselNickname(m_userInGame, name))
     {
         //Получаем интерфейс обратного вызова
         IClientServiceCallback callback = OperationContext.Current.GetCallbackChannel<IClientServiceCallback>();
         sendMessageAllUsers(m_userInGame, name, true);
         //Создаем новый экземпляр пользователя и заполняем все его поля
         CUser curUser = new CUser(name, callback);
         curUser.setStateConnect(true);
         //добавляем юзера
         m_userInGame.Add(curUser);
         this.m_user = curUser;
         MessageBox.Show("Игрок " + name + " присоединился");
         return true;
     }
     else
     {
         return false;
     }
 }
Example #36
0
        /// <summary>
        /// select the user by the user name
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public List<CUser> Sel_User(string name)
        {
            if (name == null || name.Length <= 0)
                return null;
            List<CUser> userlist = new List<CUser>();

            MySqlCommand com;
            MySqlDataReader reader;
            string cmd = "SELECT * FROM user where UserName ='******'";
            try
            {
                connect.Open();
                com = new MySqlCommand(cmd, connect);
                reader = com.ExecuteReader();
                while (reader.Read())
                {
                    CUser user = new CUser();
                    user.ID = Convert.ToInt32(reader[0].ToString());
                    user.UserName = reader[1].ToString();
                    user.PassWord = reader[2].ToString();
                    if (reader[3].ToString().Length > 0)
                    {
                        user.UserType = Convert.ToInt32(reader[3].ToString());
                    }
                    userlist.Add(user);
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
                return null;
            }
            finally
            {
                connect.Close();
            }
            return userlist;
        }
Example #37
0
File: CUser.cs Project: TheJP/Stne
 public void GetRelation(CUser User) { }
Example #38
0
 /// <summary>
 /// 根据user的id进行删除
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public bool Delete_User(CUser user)
 {
     List<string> listcmd = new List<string>();
     try
     {
         string cmd = "DELETE FROM user where ID = " + user.ID;
         listcmd.Add(cmd);
         ExectueCmd(listcmd);
     }
     catch (System.Exception ex)
     {
         Console.WriteLine(ex.Message);
         return false;
     }
     return true;
 }
Example #39
0
        /// <summary>
        /// insert a CUser to the table
        /// </summary>
        /// <param name="user"></param>
        /// <returns>
        /// user.ID
        /// true/false
        /// </returns>
        public bool Insert_User(ref CUser user)
        {
            MySqlDataReader reader;
            try
            {
                string strcmd = "INSERT INTO user(UserName,PassWord,UserType) values('"+user.UserName+"','"+
                    user.PassWord+"', "+user.UserType+")";
                connect.Open();
                MySqlCommand cmd = new MySqlCommand();
                cmd.Connection = connect;
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = strcmd;

                strcmd = "SELECT MAX([ID]) AS MAXID FROM User";
                cmd.ExecuteNonQuery();
                cmd.CommandText = strcmd;
                reader = cmd.ExecuteReader();
                reader.Read();
                user.ID = Convert.ToInt32(reader[0].ToString());
            }
            catch (System.Exception ex)
            {
            	Console.WriteLine(ex.Message);
                return false;
            }
            finally
            {
                connect.Close();
            }
            return true;
        }
Example #40
0
        private CUser m_user; //текущий пользователь

        #endregion Fields

        #region Methods

        //она вроде как не нужна уже
        public void addServerName(string servername)
        {
            CUser user = new CUser(servername, null);
            m_userInGame.Add(user);
        }
        public ActionResult Register(CRegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    //throw new Exception("我自訂錯誤");
                    CDbContext dc = new CDbContext();

                    CUser u = new CUser();
                    u.userid = model.Username;
                    u.pwd = model.Password;

                    dc.users.Add(u);
                    dc.SaveChanges();
                    return RedirectToAction("Login", "CAccount");
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex.Message);
                    return View(model);
                }
            }

            return View();
        }