Esempio n. 1
0
        //login

        public Account isAuthenticated(string username, string passwd)
        {
            var list = Repositoty.GetAccountByUsenameAsync(username).Result.ToList();

            //test
            if (username == "*****@*****.**")
            {
                if (list.Exists(p => p.passwd == passwd))
                {
                    return(list.FirstOrDefault());
                }
            }

            string encryptedpass = ExtensionTools.GetMD5(passwd);

            foreach (var item in list)
            {
                if (item.passwd.Equals(encryptedpass))
                {
                    return(item);
                }
            }
            return(null);
        }
        /// <summary>
        /// Handle the clicking of the extend button.
        /// </summary>
        private void btnExtend_Click(object sender, EventArgs e)
        {
            // Set the cursor to indicate the program is busy.
            Cursor.Current = Cursors.WaitCursor;

            // Verify that the file actually exists.
            if (File.Exists(this.txtWordDoc.Text) == true && String.IsNullOrEmpty(this.cmbStyles.Text) == false)
            {
                // Check if a backup needs to be made.
                if (chkBackup.Checked == true)
                {
                    // Find a file name that is not in use yet for the backup.
                    FileInfo fi = new FileInfo(this.txtWordDoc.Text);

                    string dir  = fi.DirectoryName;
                    string file = Path.GetFileNameWithoutExtension(fi.FullName) + "_orig";
                    string ext  = Path.GetExtension(fi.FullName);

                    int cnt = 1;

                    string backup = Path.Combine(dir, file + ext);

                    while (File.Exists(backup) == true)
                    {
                        backup = Path.Combine(dir, file + "_" + cnt++ + ext);
                    }

                    File.Copy(this.txtWordDoc.Text, backup);
                }

                // Do the extension.
                try
                {
                    bool success = ExtensionTools.ExtendBibliography(this.txtWordDoc.Text, this.map[this.cmbStyles.Text]);

                    // Give the user a hint to the result of the extension attempt.
                    if (success == true)
                    {
                        MessageBox.Show("Bibliography extension successful.", "Extension result",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Bibliography extension failed. Either there was no" +
                                        "bibliography or it was not a BibWord bibliography.",
                                        "Extension result", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch (FileFormatException)
                {
                    MessageBox.Show("Not a valid Word 2007 file.", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                if (File.Exists(this.txtWordDoc.Text) == false)
                {
                    MessageBox.Show("File does not exist.", "Invalid file",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    MessageBox.Show("No style selected.", "Invalid style selection",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }

            // Set the cursor back to default.
            Cursor.Current = Cursors.Default;
        }
Esempio n. 3
0
        public async Task <bool> SignUpAsync(RegisterMerchantModelView model)
        {
            string idMer, idAcc;
            var    tran = this.ShoeEcommerceDBContext.Database.BeginTransaction();

            try
            {
                //merchant
                idMer = await this.GetNextIdAsync();

                this.Create(new Merchant()
                {
                    idMerchant = idMer,
                    fstname    = model.fstname,
                    lstname    = model.lstname,
                    storename  = model.storename,
                    phone      = model.phone,
                    website    = model.website,
                    stt        = false
                });
                await this.SaveAsync();

                //account Merchant
                var accRepos = new AccountRepository(this.ShoeEcommerceDBContext);
                idAcc = await accRepos.GetNextId();

                accRepos.Create(new Account()
                {
                    idAccount   = idAcc,
                    username    = model.username,
                    passwd      = ExtensionTools.GetMD5(model.password),
                    avt_path    = ExtensionTools.GetFullMerchantPath(model.avt_path),
                    rate        = 1,
                    rankVip     = "default",
                    CreatedDate = DateTime.Now,
                    idCustomer  = "noone",
                    IdMerchant  = idMer,
                    //chờ admin kiểm duyệt
                    stt = false
                });
                await accRepos.SaveAsync();

                //email
                var emailRepos = new EmailRepository(this.ShoeEcommerceDBContext);
                emailRepos.Create(new Email()
                {
                    id        = await emailRepos.GetNextIdAsync(),
                    email     = model.email,
                    IdAccount = idAcc,
                    stt       = true
                });
                await emailRepos.SaveAsync();

                //address
                var addressRepos = new AddressRepository(this.ShoeEcommerceDBContext);
                addressRepos.Create(new Address()
                {
                    id            = await addressRepos.GetNextId(),
                    add_Info      = model.add_Info,
                    City_Provine  = model.City_Provine,
                    District_town = model.District_town,
                    subDistrict   = model.subDistrict,
                    idAccount     = idAcc,
                    stt           = true
                });
                await addressRepos.SaveAsync();

                //Thêm thông báo cho addmin
                var Add_on = new RegisterNotifyRepsitory(this.ShoeEcommerceDBContext);
                Add_on.Create(new RegisterNotify()
                {
                    id          = await Add_on.GetNextIdAsync(),
                    id_Acc      = idAcc,
                    id_Mer      = idMer,
                    Checked     = false,
                    createdDate = DateTime.Now,
                    stt         = true
                });
                await Add_on.SaveAsync();


                tran.Commit();
                tran.Dispose();
                return(true);
            }
            catch (Exception ex)
            {
                tran.Rollback();
                tran.Dispose();
                return(false);
            }
        }
 /// <summary>
 /// Background worker thread.
 /// </summary>
 private void Worker_DoWork(object sender, DoWorkEventArgs e)
 {
     // Load information about all the bibliography styles.
     e.Result = ExtensionTools.LoadBibliographyStylesInformation(this.styleDir, this.worker);
 }
Esempio n. 5
0
        public async Task <bool> RegisterAsync(RegisterModelView modelView)
        {
            string idcus;
            string idAcc;
            var    tran = this.ShoeEcommerceDBContext.Database.BeginTransaction();

            try
            {
                //customer
                var cusRepo = new CustomerRepository(this.ShoeEcommerceDBContext);
                idcus = await cusRepo.GetNextId();

                var cus = new Customer()
                {
                    idCustomer = idcus,
                    fstname    = modelView.fstname,
                    lstname    = modelView.lstname,
                    phone      = modelView.phone,
                    stt        = true
                };
                cusRepo.Create(cus);
                await cusRepo.SaveAsync();

                //account
                idAcc = await GetNextId();

                var acc = new Account()
                {
                    idAccount   = idAcc,
                    username    = modelView.username,
                    passwd      = ExtensionTools.GetMD5(modelView.password),
                    avt_path    = ExtensionTools.GetFullPath(modelView.avt_path),
                    rankVip     = "default",
                    rate        = 1,
                    IdMerchant  = "noone",
                    idCustomer  = idcus,
                    CreatedDate = DateTime.Now,
                    stt         = true
                };
                Create(acc);
                await SaveAsync();

                //email
                var EmailRepo = new EmailRepository(this.ShoeEcommerceDBContext);
                EmailRepo.Create(new Email()
                {
                    id        = await EmailRepo.GetNextIdAsync(),
                    email     = modelView.email,
                    IdAccount = idAcc,
                    stt       = true
                });
                await EmailRepo.SaveAsync();

                //Address
                var AddressRepos = new AddressRepository(this.ShoeEcommerceDBContext);
                AddressRepos.Create(new Address()
                {
                    id            = await AddressRepos.GetNextId(),
                    add_Info      = modelView.add_Info,
                    City_Provine  = modelView.City_Provine,
                    District_town = modelView.District_town,
                    subDistrict   = modelView.subDistrict,
                    idAccount     = idAcc,
                    stt           = true
                });
                await AddressRepos.SaveAsync();

                tran.Commit();
                tran.Dispose();
                return(true);
            }
            catch (Exception ex)
            {
                tran.Rollback();
                tran.Dispose();
                return(false);
            }
        }