Inheritance: System.Web.UI.MasterPage
Ejemplo n.º 1
0
        private void newPhnoField_Leave(object sender, EventArgs e)
        {
            string       memberpath = @"C:\projects\book_zoned\Database\members.txt";
            members      m          = new members();
            StreamReader sr         = new StreamReader(memberpath);
            string       currentLine;
            string       find = newPhnoField.Text;

            m.search = find;
            bool foundText = false;

            do
            {
                currentLine = sr.ReadLine();
                if (currentLine != null)
                {
                    foundText = currentLine.Contains(m.search);
                }
            } while (currentLine != null && !foundText);

            if (foundText)
            {
                error.SetError(this.newPhnoField, "PHONE NUMBER ALREADY EXISTS");
                newPhnoField.Clear();
            }
        }
Ejemplo n.º 2
0
        private void FrmHomePage_Load(object sender, EventArgs e)
        {
            //tag傳值
            member = (members)this.Tag;

            this.lblname.Text      = member.name;
            this.lblname1.Text     = member.name;
            this.lblbankmoney.Text = string.Format("{0:N2}", member.bankmoney);
            this.lblmoney.Text     = string.Format("{0:N2}", member.bankmoney);
            this.lblbank.Text      = string.Format("{0:N2}", member.bankmoney);
            //顯示超連結text及button text
            ((DataGridViewLinkColumn)dataGridView2.Columns["連接網頁"]).UseColumnTextForLinkValue   = true;
            ((DataGridViewButtonColumn)dataGridView2.Columns["交易"]).UseColumnTextForButtonValue = true;
            ((DataGridViewButtonColumn)dataGridView2.Columns["刪除"]).UseColumnTextForButtonValue = true;
            ((DataGridViewButtonColumn)dataGridView4.Columns["賣出"]).UseColumnTextForButtonValue = true;
            //載入圖片
            byte[] bytes = member.photo;
            if (bytes == null)
            {
                this.picBox.Image = this.picBox.ErrorImage;
            }
            else
            {
                System.IO.MemoryStream ms = new System.IO.MemoryStream(bytes);
                this.picBox.Image = Image.FromStream(ms);
            }
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Putmembers([FromRoute] int id, [FromBody] members members)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != members.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Ejemplo n.º 4
0
        public async Task <group> InsertGroupAsync(groupModel group)
        {
            group gp = new group();

            gp.group_name = group.group_name;
            gp.created_at = group.created_at;
            gp.created_by = group.created_by;
            _Context.group.Add(gp);

            foreach (var member in group.members)
            {
                members gpMember = new members();
                gpMember.groupID = gp.groupID;
                gpMember.userID  = member;
                _Context.member.Add(gpMember);
            }

            try
            {
                await _Context.SaveChangesAsync();
            }
            catch (System.Exception exp)
            {
                _Logger.LogError($"Error in {nameof(InsertGroupAsync)}: " + exp.Message);
            }
            return(gp);
        }
Ejemplo n.º 5
0
        private void eidBtn_Click(object sender, EventArgs e)
        {
            if (oldeidField.Text.Trim() != string.Empty && neweidField.Text.Trim() != string.Empty)
            {
                String oldeid = oldeidField.Text;
                String neweid = neweidField.Text;
                try
                {
                    members m = new members();

                    string memberpath = @"C:\projects\book_zoned\Database\members.txt";
                    m.oe = oldeid;
                    m.ne = neweid;

                    string str1 = File.ReadAllText(memberpath);

                    if (str1.Contains(m.oe))
                    {
                        string value = str1.Replace(m.oe, m.oe);
                        File.WriteAllText(memberpath, value);
                        MessageBox.Show("SUCCESFULLY CHANGED EMAIL ID");
                    }
                    else
                    {
                        error.SetError(this.neweidField, "ENTER THE PROPER EMAIL");
                        neweidField.Clear();
                    }
                }
                catch
                {
                }
            }
        }
Ejemplo n.º 6
0
        public ActionResult Addmember(members m, HttpPostedFileBase mem_trans)
        {
            //string btnName;

            if (ModelState.IsValid)
            {
                var    fileName = Path.GetFileName(mem_trans.FileName);
                string path     = Path.Combine(Server.MapPath("~/Uploads"), fileName);
                mem_trans.SaveAs(path);
                string std_trans2 = fileName;

                members teams = new members
                {
                    mem_gpa       = double.Parse(Request["mem_gpa"]),
                    mem_skills    = Request["mem_skills"],
                    mem_level     = Request["mem_level"],
                    mem_trans     = std_trans2,
                    teamleader_id = int.Parse(Session["userid"].ToString())
                };

                db.members.Add(teams);
                db.SaveChanges();
                ViewBag.btnName = "project";
                return(RedirectToAction("AddMember", "Student"));
            }

            //ViewBag.teamleader_id = new SelectList(db.teamleaders, "Id", "std_skills", projects.teamleader_id);
            return(View());
        }
Ejemplo n.º 7
0
        public async Task Put()
        {
            //Arrange
            var get = await controller.Get(1);

            var okgetResult = Assert.IsType <OkObjectResult>(get);
            var entity      = Assert.IsType <members>(okgetResult.Value);


            var newEntity = new members();

            newEntity.fname = "mary";
            //should test the equals Equatable for all these too
            var huh = entity.Equals(newEntity);

            entity.fname = "editMary";
            //Act
            var response = await controller.Put(1, entity);

            // Assert
            var okResult = Assert.IsType <OkObjectResult>(response);
            var result   = Assert.IsType <members>(okResult.Value);

            Assert.Equal(entity.fname, result.fname);
        }
Ejemplo n.º 8
0
        private void btnLogOn_Click(object sender, EventArgs e)
        {
            string account  = txtAccount.Text.Trim();
            string password = txtPassword.Text.Trim();

            password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(password, "SHA1");

            member = memberModel.LogOncheck(account, password);

            if (member != null)
            {
                this.txtAccount.Text  = "";
                this.txtPassword.Text = "";
                FrmHomePage frm = new FrmHomePage();
                frm.Tag = member;

                if (this.cbox.Checked)
                {
                    this.txtAccount.Text = member.account;
                }
                else
                {
                    this.txtAccount.Text = "";
                }
                frm.ShowDialog();
            }
            else
            {
                MessageBox.Show("請重新輸入帳號或密碼", "登入訊息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="MemberInDB"></param>
 /// <returns></returns>
 public void CopyMembersInfoToDB(members MemberInDB)
 {
     MemberInDB.name          = Name;
     MemberInDB.surname       = Surname;
     MemberInDB.year_of_birth = YearOfBirthInShort < 0 ? (short)0 : YearOfBirthInShort;
     MemberInDB.sex           = Sex;
 }
Ejemplo n.º 10
0
        private void RefreshDataGrid()
        {
            string query = "SELECT  ID, NAME, AUTH, PASSWORD FROM TB_MEMBERS";

            using (DataTable dt = DBSqlite.GetSelectData(query))
            {
                if (dt.Rows.Count > 0)
                {
                    MemberCollection.Clear();

                    foreach (DataRow dr in dt.Rows)
                    {
                        members user = new members()
                        {
                            IsSelect = false,
                            ID       = dr["ID"].ToString(),
                            NAME     = dr["NAME"].ToString(),
                            AUTH     = dr["AUTH"].ToString(),
                            PASSWORD = dr["PASSWORD"].ToString()
                        };

                        MemberCollection.Add(user);
                    }
                }
            }
        }
Ejemplo n.º 11
0
        private string generateDefaultPassword(members entity)
        {
            //WUDefau1t+numbercharInlastname+first2letterFirstName
            string generatedPassword = "******" + entity.lname.Length + entity.fname.Substring(0, 2);

            return(generatedPassword);
        }
Ejemplo n.º 12
0
        public async Task <members> InsertGroupMemberAsync(int Groupid, int MembersID)
        {
            var member = _Context.member.SingleOrDefault(c => c.groupID == Groupid && c.userID == MembersID);

            if (member == null)
            {
                members newMember = new members
                {
                    groupID = Groupid,
                    userID  = MembersID
                };

                _Context.member.Add(newMember);
                await _Context.SaveChangesAsync();

                return(newMember);
            }
            else
            {
                _Context.member.Attach(member);
                await _Context.SaveChangesAsync();

                return(member);
            }
        }
Ejemplo n.º 13
0
        private void addBtn_Click(object sender, EventArgs e)
        {
            if (oldAddField.Text.Trim() != string.Empty && newAddField.Text.Trim() != string.Empty)
            {
                String oldad = oldAddField.Text;
                String newad = newAddField.Text;
                try
                {
                    members m = new members();

                    string memberpath = @"C:\projects\book_zoned\Database\members.txt";
                    m.oa = oldad;
                    m.na = newad;

                    string str1 = File.ReadAllText(memberpath);

                    if (str1.Contains(m.oa))
                    {
                        string value = str1.Replace(m.oa, m.na);
                        File.WriteAllText(memberpath, value);
                        MessageBox.Show("SUCCESFULLY CHANGED ADDRESS");
                    }
                    else
                    {
                        error.SetError(this.newAddField, "ENTER THE PROPER ADDRESS");
                        newAddField.Clear();
                    }
                }
                catch
                {
                    MessageBox.Show("SOMETHING IS WRONG");
                }
            }
        }
Ejemplo n.º 14
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                members newmember = new members();

                string account       = txtAccount.Text.Trim();
                string password      = txtPassword.Text.Trim();
                string passwordcheck = txtPasswordCheck.Text.Trim();
                string name          = txtName.Text.Trim();

                bool Account  = Accountcheck(account);
                bool Password = Passwordcheck(password);



                const int money = 1000000;

                //組鍵參考system.web
                password      = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(password, "SHA1");
                passwordcheck = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(passwordcheck, "SHA1");

                if (Account && Password && password == passwordcheck)
                {
                    byte[] bytes = null;
                    if (bytes != null)
                    {
                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
                        this.picBox.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
                        bytes = ms.GetBuffer();
                    }

                    newmember.account   = account;
                    newmember.password  = password;
                    newmember.name      = name;
                    newmember.bankmoney = money;
                    newmember.photo     = bytes;

                    if (memberModel.create(newmember) > 0)
                    {
                        MessageBox.Show("註冊成功", "註冊", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("此身份證字號已註冊", "註冊", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBox.Show("格式不符,請重新輸入帳號或密碼", "註冊", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 15
0
        private void nameBtn_Click(object sender, EventArgs e)
        {
            if (nameField.Text.Trim() != string.Empty)
            {
                try
                {
                    string memberpath = @"C:\projects\book_zoned\Database\members.txt";
                    if (!File.Exists(memberpath))
                    {
                        File.Create(memberpath).Close();
                    }
                    members m    = new members();
                    string  name = nameField.Text;

                    m.name = name;
                    string       search = name;
                    StreamReader sr     = new StreamReader(memberpath);
                    string       currentLine;
                    bool         foundText = false;
                    do
                    {
                        currentLine = sr.ReadLine();
                        if (currentLine != null)
                        {
                            foundText = currentLine.Contains(search);
                        }
                    } while (currentLine != null && !foundText);

                    if (foundText)
                    {
                        string[] result = currentLine.Split('|');
                        string   phno   = result[7];
                        string   add    = result[5];
                        string   email  = result[8];
                        oldAddField.Text  = add;
                        oldeidField.Text  = email;
                        oldPhnoField.Text = phno;

                        dataBox.Text = currentLine;
                        MessageBox.Show("RECORD FOUND");
                    }
                    else
                    {
                        MessageBox.Show("RECORD NOT FOUND");
                        dataBox.Clear();
                    }
                    sr.Close();
                }
                catch
                {
                }
            }

            else
            {
                MessageBox.Show("NO FIELS SHOULD BE LEFT BLANK", "ERROR", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 16
0
        public async Task <IActionResult> ApproveNWISDataFile(int dataFileId)
        {
            try
            {
                data_file aDataFile      = null;
                approval  anEntity       = null;
                Int32     loggedInUserId = 0;

                if (dataFileId <= 0)
                {
                    return(new BadRequestObjectResult("Invalid input parameters"));
                }
                anEntity = new approval();

                //get logged in user
                var loggedInMember = LoggedInUser();
                if (loggedInMember == null)
                {
                    return(new BadRequestObjectResult("Invalid input parameters"));
                }
                loggedInUserId = loggedInMember.member_id;

                aDataFile = agent.Select <data_file>().Include(d => d.instrument).FirstOrDefault(d => d.data_file_id == dataFileId);
                if (aDataFile == null)
                {
                    return(new BadRequestObjectResult("invalid data file id"));
                }

                //get event coordinator to set as approver for NWIS datafile

                members eventCoor = agent.Select <members>().Include(m => m.events).FirstOrDefault(m => m.events.Any(e => e.event_id == aDataFile.instrument.event_id));
                if (eventCoor == null)
                {
                    return(new BadRequestObjectResult("invalid input parameters"));
                }

                //set time and user of approval
                anEntity.approval_date = DateTime.UtcNow;
                anEntity.member_id     = eventCoor.member_id;
                anEntity = await agent.Add <approval>(anEntity);

                //set datafile approvalID
                aDataFile.approval_id     = anEntity.approval_id;
                aDataFile.last_updated    = DateTime.Now;
                aDataFile.last_updated_by = loggedInUserId;

                await agent.Update <data_file>(aDataFile.data_file_id, aDataFile);

                //sm(agent.Messages);
                return(Ok(anEntity));
            }
            catch (Exception ex)
            {
                //sm(agent.Messages);
                return(await HandleExceptionAsync(ex));
            }
        }
Ejemplo n.º 17
0
        public ActionResult SignUp(
            [Bind(Include = "email,passwd,first_name,last_name,fst_add,snd_add,trd_add,photo,memberType")]
            members members, HttpPostedFileBase photo)
        {
            if (Session["crrUsername"] != null)
            {
                return(Logout());
            }

            if (ModelState.IsValid)
            {
                if (new MembersController().GetLoginDetails(members.email) == null)
                {
                    if (photo != null)
                    {
                        var pic  = Path.GetFileNameWithoutExtension(photo.FileName);
                        var ext  = Path.GetExtension(photo.FileName);
                        var path = Path.Combine(
                            Server.MapPath("~/Content/img/profile/"), pic + ext);
                        if (System.IO.File.Exists(path))
                        {
                            pic += "_1";
                            path = Path.Combine(
                                Server.MapPath("~/Content/img/profile/"), pic + ext);
                        }

                        // file is uploaded
                        photo.SaveAs(path);
                        members.photo = pic + ext;
                    }
                    else
                    {
                        members.photo = "default.jpg";
                    }


                    var sqlResult = new MembersController().InsertNewMember(members);
                    if (sqlResult == 1)
                    {
                        Session.Clear();
                        Session["crrUsername"] = members.email;
                        Session["crrUser"]     = members.first_name + " " + members.last_name;
                        Session.Timeout        = 15;
                        return(Index());
                    }

                    ViewBag.SQlError = "Member Registration Failed. " + sqlResult + " record has been updated.";
                }
                else
                {
                    ViewBag.SQlError = "Existed Username/Email Address.";
                }
            }

            return(View(members));
        }
Ejemplo n.º 18
0
        private void confirmBtn_Click(object sender, EventArgs e)
        {
            string bookpath     = @"C:\projects\book_zoned\Database\books.txt";
            string issuepath    = @"C:\projects\book_zoned\Database\issued.txt";
            string searchstring = bookIdField.Text;
            books  b            = new books();

            b.search = searchstring;


            StreamReader sread = new StreamReader(issuepath);

            string  thisline;
            string  lcn = libcardnoField.Text;
            members m   = new members();

            m.lcn = lcn;
            string searchS   = m.lcn;
            bool   foundText = false;

            do
            {
                thisline = sread.ReadLine();
                if (thisline != null)
                {
                    foundText = thisline.Contains(searchS);
                }
            }while (thisline != null && !foundText);
            sread.Close();

            if (foundText)
            {
                var oldLines = File.ReadAllLines(issuepath);
                var newLines = oldLines.Where(line => !line.Contains(b.search));
                File.WriteAllLines(issuepath, newLines);

                var oldLines1 = File.ReadAllLines(bookpath);
                var newLines1 = oldLines1.Where(line => !line.Contains(b.search));
                File.WriteAllLines(bookpath, newLines1);
            }


            List <string> book_line = File.ReadAllLines(bookpath).ToList();
            string        write     = hideBox.Text;

            book_line.Add(write.TrimStart());
            File.WriteAllLines(bookpath, book_line);
            MessageBox.Show("UPDATED SUCCESSFULLY", "SUCCESS", MessageBoxButtons.OK, MessageBoxIcon.Information);

            var lines = File.ReadAllLines(bookpath).Where(arg => !string.IsNullOrWhiteSpace(arg));

            File.WriteAllLines(bookpath, lines);

            dataBox.Clear();
        }
Ejemplo n.º 19
0
 //유저 생성
 private void CreateUser(members newUser)
 {
     if (ConfirmUserID(newUser))
     {
         InsertUser(newUser);
     }
     else
     {
         MessageBox.Show("이미 등록된 아이디 입니다.");
     }
 }
Ejemplo n.º 20
0
        [Authorize(Policy = "Restricted")] //("Admin", "Manager")
        public async Task <IActionResult> Post([FromBody] members entity)
        {
            try
            {
                if (string.IsNullOrEmpty(entity.fname) || string.IsNullOrEmpty(entity.lname) || string.IsNullOrEmpty(entity.username) ||
                    string.IsNullOrEmpty(entity.phone) || string.IsNullOrEmpty(entity.email) || entity.agency_id < 0)
                {
                    return(new BadRequestObjectResult(new Error(errorEnum.e_badRequest, "You are missing one or more required parameter.")));
                }

                if (string.IsNullOrEmpty(entity.password))
                {
                    entity.password = generateDefaultPassword(entity);
                }
                else
                {
                    entity.password = Encoding.UTF8.GetString(Convert.FromBase64String(entity.password));
                }

                if (entity.role_id <= 0)
                {
                    entity.role_id = agent.Select <roles>().SingleOrDefault(r => r.role_name == FieldRole).role_id;
                }

                entity.salt     = Cryptography.CreateSalt();
                entity.password = Cryptography.GenerateSHA256Hash(entity.password, entity.salt);

                var loggedInMember = LoggedInUser();
                if (loggedInMember == null)
                {
                    return(new BadRequestObjectResult("Invalid input parameters"));
                }

                entity.last_updated    = DateTime.Now;
                entity.last_updated_by = loggedInMember.member_id;

                if (!isValid(entity))
                {
                    return(new BadRequestResult());                  // This returns HTTP 404
                }
                var x = await agent.Add <members>(entity);

                //remove info not relevant
                x.salt     = string.Empty;
                x.password = string.Empty;

                return(Ok(x));
            }
            catch (Exception ex)
            {
                return(await HandleExceptionAsync(ex));
            }
        }
Ejemplo n.º 21
0
 public CMemberKeys(string name    = GlobalDefines.DEFAULT_XML_STRING_VAL,
                    string surname = GlobalDefines.DEFAULT_XML_STRING_VAL,
                    CMemberAndPart MemberAndPart = null)
 {
     Name    = name;
     Surname = surname;
     if (MemberAndPart != null)
     {
         Member        = MemberAndPart.Member;
         Participation = MemberAndPart.Participation;
     }
 }
Ejemplo n.º 22
0
        public async Task <IActionResult> Postmembers([FromBody] members members)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.members.Add(members);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("Getmembers", new { id = members.Id }, members));
        }
 public static int Signup()
 {
     members newMn = new members();
     Console.Write("Whats your name: ");
    
     newMn.name_ = Console.ReadLine();
     Console.Write("Whats your age: ");
     newMn.age_ = Convert.ToInt32(Console.ReadLine());
     Console.Write("Whats yor salary income: ");
     newMn.salary_ = Convert.ToDouble(Console.ReadLine());
     
     
     return 1;
 }
Ejemplo n.º 24
0
        internal int create(members formData)
        {
            members result = db.members.Where(m => m.account == formData.account).FirstOrDefault();

            if (result == null)
            {
                db.members.Add(formData);
                return(db.SaveChanges());
            }
            else
            {
                return(0);
            }
        }
Ejemplo n.º 25
0
        //유저 아이디 판별
        private bool ConfirmUserID(members newUser)
        {
            string query = "SELECT ID FROM TB_MEMBERS WHERE ID = '" + newUser.ID + "'";

            using (DataTable dt = DBSqlite.GetSelectData(query))
            {
                if (dt.Rows.Count <= 0)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 26
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                member = (members)this.Tag;
                string oldpassword = txtoldpassword.Text.Trim();
                oldpassword = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(oldpassword, "SHA1");
                string newpassword = txtnewpassword.Text.Trim();

                string newpasswordcheck = txtnewpasswoedcheck.Text.Trim();



                if (oldpassword == member.password)
                {
                    if (newpassword != "" && newpasswordcheck != "")
                    {
                        newpassword      = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(newpassword, "SHA1");
                        newpasswordcheck = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(newpasswordcheck, "SHA1");
                        if (newpassword == newpasswordcheck)
                        {
                            members Loginmember = db.members.Where(m => m.account == member.account).FirstOrDefault();
                            Loginmember.password = newpassword;

                            db.SaveChanges();
                            MessageBox.Show("密碼變更成功!!", "密碼變更", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show("新密碼與新密碼確認不一致!!", "密碼變更", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("請輸入新密碼", "密碼變更", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("舊密碼輸入錯誤!!", "密碼變更", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public async Task <IActionResult> Postmembers([FromBody] members members)
        {
            string username = format(members.username);
            string password = format(members.password);
            //Skoða hvort að það er til usernameið og rétt paswword
            var result = _context.members.Where(s => s.username == username && dotNetCoreAzure.Pages.decrypter.cryption.Decrypt(s.password) == password).ToList();

            if (result.Count > 0)
            {
                return(Ok(new { result.Last().Id, result.Last().username, result.Last().name, result.Last().role }));
            }
            else
            {
                return(BadRequest(new { status = "Wrong credentials" }));
            }
        }
Ejemplo n.º 28
0
        //ADD
        public static bool Addmember(members member)
        {
            Context.members.Add(member);
            try
            {
                Context.SaveChanges();
            }
            catch (DbUpdateException dbEx)
            {
                return false;
            }
            catch (DbEntityValidationException ex)
            {
                foreach (DbEntityValidationResult item in ex.EntityValidationErrors)
                {
                    // Get entry
                    DbEntityEntry entry = item.Entry;
                    string entityTypeName = entry.Entity.GetType().Name;

                    // Display or log error messages
                    foreach (DbValidationError subItem in item.ValidationErrors)
                    {
                        string message = string.Format("Error '{0}' occurred in {1} at {2}",
                                 subItem.ErrorMessage, entityTypeName, subItem.PropertyName);
                        Console.WriteLine(message);
                    }

                    // Rollback changes
                    switch (entry.State)
                    {
                        case EntityState.Added:
                            entry.State = EntityState.Detached;
                            break;
                        case EntityState.Modified:
                            entry.CurrentValues.SetValues(entry.OriginalValues);
                            entry.State = EntityState.Unchanged;
                            break;
                        case EntityState.Deleted:
                            entry.State = EntityState.Unchanged;
                            break;
                    }
                }
                return false;
            }
            Context.Entry(member).Reload();
            return true;
        }
Ejemplo n.º 29
0
        private void lcnBtn_Click(object sender, EventArgs e)
        {
            if (lcnField.Text.Trim() != string.Empty)
            {
                members m = new members();

                string memberpath = @"C:\projects\book_zoned\Database\members.txt";
                string lcnNo      = lcnField.Text;

                try
                {
                    StreamReader sr = new StreamReader(memberpath);
                    string       currentLine;
                    string       searchString = lcnNo;
                    m.search = searchString;
                    bool foundText = false;

                    do
                    {
                        currentLine = sr.ReadLine();
                        if (currentLine != null)
                        {
                            foundText = currentLine.Contains(m.search);
                        }
                    }while (currentLine != null && !foundText);

                    if (foundText)
                    {
                        dispBox.Text = currentLine;
                        MessageBox.Show("RECORD FOUND", "SUCCESS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("RECORD NOT FOUND", "FAILED", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                        dispBox.Clear();
                    }
                }
                catch
                {
                }
            }
            else
            {
                MessageBox.Show("LIBRARY CARD NUMBER FIELD MUST BE LEFT", "RETRY", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
            }
        }
        public async Task <IActionResult> Postmembers([FromBody] members member)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var members = await _context.members.FindAsync(member.Id);

            if (members == null)
            {
                return(NotFound(new { status = "there is no user with this id" }));
            }
            _context.members.Remove(members);
            await _context.SaveChangesAsync();

            return(Ok(new { status = "User has been deleted" }));
        }
Ejemplo n.º 31
0
 public bool AddMem(int userid, int serverid)
 {
     try
     {
         members s = new members
         {
             server_id = serverid,
             user_id   = userid
         };
         _ent.members.Add(s);
         _ent.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Ejemplo n.º 32
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Site_Settings.NavigationSection == 1)
            {
                // right side navigation
                NavigationClass = "chnl_right_nav";
                BodyClass = "chnl_left_mn";
            }    

            btn_login.Text = Resources.vsk.update;

            if (Request.Params["u"] != null && Request.Params["k"] != null)
            {
                // validate user info
                members _members= new members();
                string username = Server.UrlDecode(Request.Params["u"].ToString());
                string key =Server.UrlDecode(Request.Params["k"].ToString());

                if (!_members.Check_Key(username, key))
                {
                    Response.Redirect(Config.GetUrl("forgotpassword.aspx?status=invalid"));
                    return;
                }

                string ipaddress = Request.ServerVariables["REMOTE_ADDR"].ToString();
                if (BlockIPBLL.Validate_IP(ipaddress))
                {
                    Response.Redirect(Config.GetUrl("IPBlocked.aspx"));
                    return;
                }

                lbl_username.Text = username;
            }
            else
            {
                Response.Redirect(Config.GetUrl("forgotpassword.aspx"));
            }
        }
    }
Ejemplo n.º 33
0
        // UPDATE
        public static int UpdateMember(members member)
        {
            members memberToUpdate = GetMemberById(member.Id);

            memberToUpdate.FirstName = member.FirstName;
            memberToUpdate.SurName = member.SurName;
            memberToUpdate.Email = member.Email;
            memberToUpdate.Phone = member.Phone;
            memberToUpdate.IsContact = member.IsContact;
            memberToUpdate.Associations_Id = member.Associations_Id;

            int affectedRows;

            try
            {
                affectedRows = Context.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
                foreach (DbEntityValidationResult item in ex.EntityValidationErrors)
                {
                    // Get entry

                    DbEntityEntry entry = item.Entry;
                    string entityTypeName = entry.Entity.GetType().Name;

                    // Display or log error messages

                    foreach (DbValidationError subItem in item.ValidationErrors)
                    {
                        string message = string.Format("Error '{0}' occurred in {1} at {2}",
                                 subItem.ErrorMessage, entityTypeName, subItem.PropertyName);
                        Console.WriteLine(message);
                    }
                    // Rollback changes

                    switch (entry.State)
                    {
                        case EntityState.Added:
                            entry.State = EntityState.Detached;
                            break;
                        case EntityState.Modified:
                            entry.CurrentValues.SetValues(entry.OriginalValues);
                            entry.State = EntityState.Unchanged;
                            break;
                        case EntityState.Deleted:
                            entry.State = EntityState.Unchanged;
                            break;
                    }
                }
                return affectedRows = 0;
            }
            Context.Entry(memberToUpdate).Reload();
            return affectedRows;
        }
Ejemplo n.º 34
0
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        //避免js失效,后端验证
        string name = txtName.Text;
        if (txtName.Text == null || txtName.Text.Trim() == "")
        {
            LblStatus.Text = "请填写姓名";
            LblStatus.Visible = true;
            return;
        }
        string direction = txtDirection.Text;
        if (direction == null || direction == "")
        {
            LblStatus.Text = "请填写方向";
            LblStatus.Visible = true;
            return;
        }

        string content = txtIntroduction.InnerText;
        content = content.Replace("\n", "<br />"); // 尝试替换\n为<br />

        if (content == null || content.Trim() == "")
        {
            LblStatus.Text = "请填写简介";
            LblStatus.Visible = true;
            return;
        }

        string photo = uploadMemPho();
        if (photo == null || photo.Trim() == "")
        {
            LblStatus.Text = "请选择照片";
            LblStatus.Visible = true;
            return;
        }
        string ico = uploadMemIco();
        if (photo == null || photo.Trim() == "")
        {
            LblStatus.Text = "请选择头像";
            LblStatus.Visible = true;
            return;
        }

        //存储成员到members表
        using (var db = new ITStudioEntities())
        {
            var mem = new members();
            mem.grade = Convert.ToInt32(ddlGrade.SelectedValue);
            mem.photo = photo;
            mem.ico = ico;
            mem.name = name;
            mem.introduction = content;
            mem.direction = direction;
            mem.job = ddlDeparement.SelectedValue;
            db.members.Add(mem);
            db.SaveChanges();
        }
        ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('添加成功');</script>");
        txtName.Text = "";
        txtIntroduction.InnerText = "";
        ddlDeparement.SelectedValue = "程序开发";
    }
Ejemplo n.º 35
0
 .with(statements: MoveToMain, members: MoveToApplication);
Ejemplo n.º 36
0
        void _SetMemberLocation( Yotei yotei, members members )
        {
            // todo:ID順にソートする

            foreach( var member in members.member )
            {
                // ユーザー情報
                if( member.Item is MemberTypeUser )
                {
                    var	user	= (MemberTypeUser)member.Item;
                    foreach( var userAttr in user.AnyAttr )
                    {
                        yotei.Members.Add( userAttr.Value );
                    }
                }
                // 施設情報
                if( member.Item is MemberTypeFacility )
                {
                    var	facility	= (MemberTypeFacility)member.Item;
                    foreach( var facilityAttr in facility.AnyAttr )
                    {
                        yotei.Facilitys.Add( facilityAttr.Value );
                    }
                }
            }
        }