コード例 #1
0
        private void ProfileBTN_Click(object sender, EventArgs e)
        {
            MainUITabControl.SelectedTab = ProfileTAB;
            ToLet.Classes.User u = ToLet.DBDataProvider.DBDataProvider.getUserInfo(user, pass);
            Image propic         = ToLet.DBDataProvider.DBDataProvider.getProPic(user, pass);

            UserNameTB.Text       = u.UserName;
            FirstNameTB.Text      = u.FirstName;
            FirstNameTB.BackColor = Color.BurlyWood;
            LastNameTB.Text       = u.LastName;
            LastNameTB.BackColor  = Color.BurlyWood;
            MobileTB.Text         = "0" + u.MobileNo.ToString();
            EmailTB.Text          = u.Email;

            NidTB.Text              = u.NidNo;
            NidTB.BackColor         = Color.BurlyWood;
            AddressTB.Text          = u.Address;
            DateOfBirthTB.Text      = u.DOB;
            DateOfBirthTB.BackColor = Color.BurlyWood;
            ProfilePicPB.Image      = propic;

            EditPasswordTB.Text        = u.Password;
            ConfirmEditPasswordTB.Text = u.Password;

            SaveBTN.Visible            = false;
            EditProfileBTN.Visible     = true;
            BrowseNewProPicBTN.Visible = false;

            EditPasswordLBL.Visible = false;
            EditPasswordTB.Visible  = false;

            ConfirmEditPasswordLBL.Visible = false;
            ConfirmEditPasswordTB.Visible  = false;
        }
コード例 #2
0
        private void EditProfileBTN_Click(object sender, EventArgs e)
        {
            ToLet.Classes.User u = ToLet.DBDataProvider.DBDataProvider.getUserInfo(user, pass);

            MessageBox.Show("Except Red Fields");

            FirstNameTB.BackColor   = Color.Red;
            LastNameTB.BackColor    = Color.Red;
            NidTB.BackColor         = Color.Red;
            DateOfBirthTB.BackColor = Color.Red;
            UserNameTB.BackColor    = Color.Red;

            MobileTB.ReadOnly          = false;
            EmailTB.ReadOnly           = false;
            AddressTB.ReadOnly         = false;
            BrowseNewProPicBTN.Visible = true;

            EditPasswordLBL.Visible = true;

            EditPasswordTB.Visible  = true;
            EditPasswordTB.ReadOnly = false;
            EditPasswordTB.Text     = u.Password;

            ConfirmEditPasswordLBL.Visible = true;
            ConfirmEditPasswordTB.Visible  = true;
            ConfirmEditPasswordTB.ReadOnly = false;
            ConfirmEditPasswordTB.Text     = u.Password;

            SaveBTN.Visible        = true;
            EditProfileBTN.Visible = false;
        }
コード例 #3
0
        private void SubmitPB_Click(object sender, EventArgs e)
        {
            DataClasses1DataContext cntx = ToLet.Database.DBConnectionProvider.getDBConnection();

            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            UserImagePB.Image.Save(ms, UserImagePB.Image.RawFormat);
            //Image imag = Image.FromFile(opnfdlg.FileName);
            //imag.Save(ms, UserImagePB.Image.RawFormat);
            byte[] arrpic = ms.GetBuffer();

            ToLet.Database.DBConnectionProvider.getDBConnection();
            if (PassSUPTB.Text != CPassSUPTB.Text)
            {
                PassSUPTB.Text  = "";
                CPassSUPTB.Text = "";
                MessageBox.Show("Password not matched");
            }
            int parsedValue;

            if (this.SignupPANEL.Controls.OfType <TextBox>().Any(t => string.IsNullOrEmpty(t.Text)))
            {
                MessageBox.Show("Please fill up the form properly");
            }
            else if (!int.TryParse(MobileTB.Text, out parsedValue))
            {
                MessageBox.Show("MobileNo is a number only field");
                return;
            }

            else
            {
                if (MaleRB.Checked == true)
                {
                    ToLet.Classes.User u = new ToLet.Classes.User(FirstNameTB.Text, LastNameTB.Text, UNameSUPTB.Text, PassSUPTB.Text, EmailTB.Text, MaleRB.Text, DateOfBirthDTP.Text, NidTB.Text, AddressTB.Text, int.Parse(MobileTB.Text));
                    ToLet.DBDataProvider.DBDataProvider.InsertOnDB(u, arrpic);
                }
                else if (FemaleRB.Checked == true)
                {
                    ToLet.Classes.User u = new ToLet.Classes.User(FirstNameTB.Text, LastNameTB.Text, UNameSUPTB.Text, PassSUPTB.Text, EmailTB.Text, FemaleRB.Text, DateOfBirthDTP.Text, NidTB.Text, AddressTB.Text, int.Parse(MobileTB.Text));
                    ToLet.DBDataProvider.DBDataProvider.InsertOnDB(u, arrpic);
                }


                tabControl1.SelectedTab = LoginTAB;
                foreach (Control c in SignupPANEL.Controls)
                {
                    if (c is TextBox)
                    {
                        c.Text = string.Empty;
                    }
                }
                FemaleRB.Checked  = false;
                MaleRB.Checked    = false;
                UserImagePB.Image = Resources._019005_glossy_waxed_wood_icon_symbols_shapes_smiley_happy2;
            }
        }
コード例 #4
0
        public static void InsertOnDB(ToLet.Classes.User u, byte[] arrpic)
        {
            bool b = false;

            try
            {
                DataClasses1DataContext cntx         = ToLet.Database.DBConnectionProvider.getDBConnection();
                List <string>           usernamelist = DBDataList.checkDoubleusername(u.UserName);

                foreach (var values in usernamelist)
                {
                    if (values == u.UserName)
                    {
                        System.Windows.Forms.MessageBox.Show("Username already exists");
                        b = true;

                        break;
                    }
                }
                if (b == false)
                {
                    User user = new User();
                    user.UserName     = u.UserName;
                    user.Password     = u.Password;
                    user.UserCategory = "user";

                    UserInfo userinfo = new UserInfo();
                    userinfo.First_Name    = u.FirstName;
                    userinfo.Last_Name     = u.LastName;
                    userinfo.MobileNo      = u.MobileNo;
                    userinfo.Email         = u.Email;
                    userinfo.Nid_No        = u.NidNo;
                    userinfo.Address       = u.Address;
                    userinfo.Date_of_Birth = u.DOB;
                    userinfo.Gender        = u.Gender;

                    userinfo.Profile_Pic = arrpic;

                    cntx.Users.InsertOnSubmit(user);
                    user.UserInfos.Add(userinfo);
                    cntx.SubmitChanges();
                    System.Windows.Forms.MessageBox.Show("Congratulations!!!You have successfully registered");
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        }
コード例 #5
0
        private void PasswordTB_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                ToLet.Database.DBConnectionProvider.getDBConnection();

                ToLet.Classes.User u = new ToLet.Classes.User();

                u.UserName = UsernameTB.Text;
                u.Password = PasswordTB.Text;

                bool b = ToLet.DBDataProvider.DBDataProvider.LogInCheck(u.UserName, u.Password);

                if (b)
                {
                    this.Hide();

                    this.mainui = new MainUI(this, u.UserName);
                    Image propic = ToLet.DBDataProvider.DBDataProvider.getProPic(u.UserName, u.Password);
                    mainui.ProPB.Image     = propic;
                    mainui.ProPB.SizeMode  = PictureBoxSizeMode.StretchImage;
                    mainui.accountLBL.Text = u.UserName;
                    mainui.MainUIButtonPANEL.Controls.Add(mainui.accountLBL);
                    mainui.setuserpass(u.UserName, u.Password);
                    mainui.Show();
                }
                else
                {
                    if (u.UserName == "")
                    {
                        LoginPANEL.Controls.Add(userNameLBL2);
                    }
                    if (u.Password == "")
                    {
                        LoginPANEL.Controls.Add(passwordLBL2);
                    }
                    else
                    {
                        MessageBox.Show("Invalid username or password");
                    }
                }
            }
        }
コード例 #6
0
        public static ToLet.Classes.User getUserInfo(string user, string pass)
        {
            DataClasses1DataContext cntx = ToLet.Database.DBConnectionProvider.getDBConnection();
            var info = from p in cntx.UserInfos
                       join c in cntx.Users
                       on p.UserId equals c.UserId
                       where c.UserName == user && c.Password == pass
                       select new
            {
                p.First_Name,
                p.Last_Name,
                p.MobileNo,
                p.Nid_No,
                p.Email,
                p.Address,
                p.Date_of_Birth,
                c.UserName
            };


            ToLet.Classes.User u = new ToLet.Classes.User();

            foreach (var item in info)
            {
                u.FirstName = item.First_Name;
                u.LastName  = item.Last_Name;
                u.MobileNo  = item.MobileNo;
                u.NidNo     = item.Nid_No;
                u.Email     = item.Email;
                u.Address   = item.Address;
                u.DOB       = item.Date_of_Birth;
                u.UserName  = item.UserName;
            }


            return(u);
        }