コード例 #1
0
ファイル: Form1.cs プロジェクト: eniseirem/MemoryKeeper
 private void btnLogin_Click(object sender, EventArgs e)
 {
     if (CheckItems())
     {
         var currentUser = _db.Users.Where(x =>
                                           x.Email.ToLower() == txtEmail.Text.ToLower()
                                           ).FirstOrDefault();
         if (currentUser != null)
         {
             if (currentUser.Password.ToLower().Equals(TxtPassword.Text.ToLower()))
             {
                 var frm = new frmMainPage();
                 frm.Show();
                 this.Hide();
             }
             else
             {
                 errorProvider1.SetError(TxtPassword, "Password is incorrec");
                 MessageBox.Show("Password is incorrect!", "Error");
             }
         }
         else
         {
             MessageBox.Show("This user is not include in Database", "Error");
         }
     }
     else
     {
         MessageBox.Show("Your Email or password is incorrect!", "Error");
     }
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: eniseirem/MemoryKeeper
        private void btnNewUser_Click(object sender, EventArgs e)
        {
            if (CheckItems())
            {
                _db.Users.Add(new User
                {
                    Id          = Guid.NewGuid().ToString(),
                    Email       = txtEmail.Text,
                    Password    = TxtPassword.Text,
                    CreatedDate = DateTime.Now
                });

                if (_db.SaveChanges() > 0)
                {
                    MessageBox.Show("Successful!", "This Record created as Successful");
                    var frm = new frmMainPage();
                    frm.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Failed!", "This record cant create!");
                }
            }
        }
コード例 #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var date = Convert.ToDateTime(DateTime.Now.ToShortDateString());

            if (!_db.Memories.Where(x => x.CreatedDate.Equals(date)).Any())
            {
                if (CheckItems())
                {
                    OpenFileDialog opFile = new OpenFileDialog();
                    opFile.Title  = "Select a Image";
                    opFile.Filter = "jpg files (*.jpg)|*.jpg|All files (*.*)|*.*";

                    var newFileName = "default.png";

                    if (!string.IsNullOrEmpty(pbMemory.ImageLocation))
                    {
                        var filePath = pbMemory.ImageLocation.ToString();
                        var fileName = Path.GetFileName(filePath);
                        newFileName = Guid.NewGuid().ToString() + Path.GetExtension(filePath);
                        File.Copy(filePath, Path.GetDirectoryName(Application.ExecutablePath) + @"\files\img\" + newFileName);
                    }

                    _db.Memories.Add(new DaraBaseTablesClassses.Memory
                    {
                        Id          = Guid.NewGuid().ToString(),
                        Description = rTxtDescription.Text,
                        ImagePath   = newFileName,
                        Rate        = Convert.ToInt32(nudRate.Value),
                        UserId      = _db.Users.FirstOrDefault().Id,
                        CreatedDate = Convert.ToDateTime(DateTime.Now.ToShortDateString())
                    });
                    if (_db.SaveChanges() > 0)
                    {
                        MessageBox.Show("This process was Successful", "Success");
                        this.Close();
                        var frm = new frmMainPage();
                        frm.Show();
                    }
                    else
                    {
                        MessageBox.Show("This process was failed", "Failed");
                    }
                }
            }
            else
            {
                MessageBox.Show("You cant save a Journal at same date", "Failed");
            }
        }
コード例 #4
0
        private void FrmCreateNewMemory_FormClosing(object sender, FormClosingEventArgs e)
        {
            var frm = new frmMainPage();

            frm.Show();
        }