Exemple #1
0
        public bool UpdateAdopter(tblAccount adopter)
        {
            Console.WriteLine(adopter.username);
            Console.WriteLine(adopter.password);
            Console.WriteLine(adopter.fullname);
            Console.WriteLine(adopter.address);
            var update = (from a in _db.tblAccount
                          where a.username == adopter.username
                          select a)
                         .SingleOrDefault();

            if (update != null)
            {
                update.username        = adopter.username;
                update.password        = adopter.password;
                update.fullname        = adopter.fullname;
                update.address         = adopter.address;
                update.phone           = adopter.phone;
                update.isInBlackList   = adopter.isInBlackList;
                update.reasonBlackList = adopter.reasonBlackList;
                update.roleID          = adopter.roleID;
                update.status          = adopter.status;
                update.image           = adopter.image;
                _db.SaveChanges();
                return(true);
            }
            return(false);
        }
Exemple #2
0
        //-> Create First Time : no account created yet
        public async Task <AccountViewDTO> Create(AccountNewDTO accountDTO, HttpRequestBase Request)
        {
            using (var transaction = db.Database.BeginTransaction())
            {
                try
                {
                    var tblPin = db.tblPins.FirstOrDefault(x => x.pins_Phone == accountDTO.acct_PhoneNumber &&
                                                           x.pins_isUsed == null && x.pins_Name == accountDTO.pin);
                    if (tblPin == null)
                    {
                        throw new HttpException(_ErrorCode, ConstantHelper.INVALID_PIN);
                    }
                    else
                    {
                        if (DateTime.Now.Subtract(tblPin.pins_Date.Value).Minutes > 3)
                        {
                            throw new HttpException(_ErrorCode, ConstantHelper.PIN_EXPIRED);
                        }
                    }

                    tblAccount eAcc = db.tblAccounts.FirstOrDefault(x => x.acct_PhoneNumber.Trim() == accountDTO.acct_PhoneNumber.Trim());
                    if (eAcc != null)
                    {
                        throw new HttpException(_ErrorCode, ConstantHelper.PHONE_EXIST);
                    }

                    eAcc = db.tblAccounts.FirstOrDefault(x => x.acct_Email.Trim() == accountDTO.acct_Email.Trim());
                    if (eAcc != null)
                    {
                        throw new HttpException(_ErrorCode, ConstantHelper.EMAIL_EXIST);
                    }

                    tblPin.pins_isUsed = "Y";

                    accountDTO = StringHelper.TrimStringProperties(accountDTO);
                    var account = (tblAccount)MappingHelper.MapDTOToDBClass <AccountNewDTO, tblAccount>(accountDTO, new tblAccount());
                    account.acct_CreatedDate = DateTime.Now;
                    account.acct_Status      = "Pending";

                    db.tblAccounts.Add(account);
                    await db.SaveChangesAsync();

                    List <sm_doc> documents = await DocumentHelper.SaveUploadFiles(db, ConstantHelper.TABLE_ACCOUNT_ID, account.acct_AccountID, Request);// tmp not useful , just reserve data for using in the furture

                    accountDTO.acct_AccountID = account.acct_AccountID;
                    var loanRequest = await SaveToLoanRequest(accountDTO);

                    transaction.Commit();
                    await db.Entry(loanRequest).ReloadAsync();

                    sendmail(loanRequest, account);
                    return(await SelectByID(account.acct_AccountID));
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    throw new Exception(ex.Message);
                }
            }
        }
Exemple #3
0
 public UpdatePetDiary(tblAccount user)
 {
     InitializeComponent();
     this.adopter = user;
     InitData();
     this.Text = "Update Pet Diary";
 }
Exemple #4
0
        /// <summary> Xóa tài khoản
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public int Delete(int Id)
        {
            try
            {
                tblAccount account = Context.tblAccounts.Where(e => e.Id == Id).FirstOrDefault();
                if (account != null)
                {
                    Context.tblAccounts.DeleteOnSubmit(account);
                    Context.SubmitChanges();// Cập nhật sự thay đổi của bảng.

                    // Trả về ID của tài khoản.
                    return(account.Id);
                }
                else
                {
                    return((int)EnumError.NOT_FOUND);// -404 Not found.
                }
            }
            catch (Exception ex)
            {
                string strErr = "Lỗi xóa tài khoản Id: " + Id;
                strErr += "\\n" + ex.ToString();
                Logs.LogWrite(strErr);
                return(-1);
            }
        }
 public AddManagerViewModel(AddManager addManagerOpen)
 {
     manager            = new tblManager();
     account            = new tblAccount();
     addManager         = addManagerOpen;
     qualificationsList = service.FillQualificationsList();
 }
Exemple #6
0
        /// <summary>Cập nhật trạng thái active (Khi click đường link trong mail)
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="Active_Code"></param>
        /// <returns></returns>
        public int UpdateActive(int Id, string Active_Code)
        {
            try
            {
                tblAccount account = Context.tblAccounts.Where(e => e.Id == Id && e.Active_Code == Active_Code).FirstOrDefault();
                if (account != null)
                {
                    account.State       = 1;
                    account.Active_Date = DateTime.Now;

                    Context.SubmitChanges();// Cập nhật sự thay đổi của bảng.

                    // Trả về ID của tài khoản.
                    return(account.Id);
                }
                else
                {
                    return((int)EnumError.NOT_FOUND);// -404 Not found.
                }
            }
            catch (Exception ex)
            {
                string strErr = "Lỗi cập nhật trạng thái hoạt động Id: " + Id;
                strErr += "\\n" + ex.ToString();
                Logs.LogWrite(strErr);
                return((int)EnumError.UPDATE_ERROR);
            }
        }
Exemple #7
0
 public AddEmployeeViewModel(AddEmployee addEmployeeOpen)
 {
     account         = new tblAccount();
     employee        = new tblEmployee();
     addEmployee     = addEmployeeOpen;
     engagementsList = service.GetAllEngagements();
 }
 public AdminHome(tblAccount user)
 {
     InitializeComponent();
     lbWelcome.Text = "Welcome " + user.fullname;
     this.admin     = user;
     this.Text      = "Admin Home";
 }
Exemple #9
0
        internal void AddEmployee(tblEmployee employee, tblAccount account, string dateOfBirth, tblEngagement Engagement)
        {
            using (HotelEntities1 context = new HotelEntities1())
            {
                DateTime date = DateTime.ParseExact(dateOfBirth, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);

                tblAccount newAccount = new tblAccount();
                newAccount.FullName    = account.FullName;
                newAccount.DateOfBirth = date;
                newAccount.Email       = account.Email;
                newAccount.UserName    = account.UserName;
                newAccount.Pass        = account.Pass;
                context.tblAccounts.Add(newAccount);
                context.SaveChanges();

                tblEmployee newManager = new tblEmployee();
                newManager.AccountID    = newAccount.AccountID;
                newManager.HotelFloor   = employee.HotelFloor;
                newManager.Gender       = employee.Gender;
                newManager.Cityzenship  = employee.Cityzenship;
                newManager.EngagementID = Engagement.EngagementID;
                newManager.Salary       = employee.Salary;
                context.tblEmployees.Add(newManager);
                context.SaveChanges();
            }
        }
Exemple #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdateAccount(AccountModel model)
        {
            try
            {
                tblAccount account = Context.tblAccounts.Where(e => e.Id == model.Id).FirstOrDefault();
                if (account != null)
                {
                    account.State  = model.State;
                    account.RoleId = model.RoleId;

                    Context.SubmitChanges();// Cập nhật sự thay đổi của bảng.

                    // Trả về ID của tài khoản.
                    return(account.Id);
                }
                else
                {
                    return((int)EnumError.NOT_FOUND);// -404 Not found.
                }
            }
            catch (Exception ex)
            {
                string strErr = "Lỗi cập nhật trạng thái hoạt động Id: " + model.Id;
                strErr += "\\n" + ex.ToString();
                Logs.LogWrite(strErr);
                return((int)EnumError.UPDATE_ERROR);
            }
        }
Exemple #11
0
        public List <tblAccount> GetData(tblAccount filterModel, int currentPageIndex, out int Total)
        {
            IEnumerable <tblAccount> result = null;
            bool isAllPropEmpty             = true;

            if (filterModel != null)
            {
                isAllPropEmpty = filterModel.GetType().GetProperties().All(p => string.IsNullOrWhiteSpace(Convert.ToString(p.GetValue(filterModel))));
            }

            if (isAllPropEmpty)
            {
                result = _repository.GetPagedList(null, _order => _order.Id, currentPageIndex, out Total);
            }
            else
            {
                //var predicate = PredicateBuilder.False<_Account>();
                //if (!string.IsNullOrEmpty(filterModel.FirstName))
                //    predicate = predicate.Or<_Account>(x => x.FirstName.Contains(filterModel.FirstName));
                //if (!string.IsNullOrEmpty(filterModel.LastName))
                //    predicate = predicate.Or<_Account>(x => x.LastName.Contains(filterModel.LastName));
                //predicate.Compile();
                result = _repository.GetPagedList(null, _order => _order.Id, currentPageIndex, out Total);
            }
            return(result.ToList());
        }
Exemple #12
0
        /// <summary>Thêm 1 tài khoản.
        /// </summary>
        /// <param name="model">Thông tin tài khoản.</param>
        /// <returns></returns>
        public int Insert(AccountModel model)
        {
            try
            {
                // Khởi tạo 1 account lấy các thông tin từ model.
                tblAccount account = new tblAccount()
                {
                    UserName      = model.UserName,
                    Email         = model.Email,
                    Password      = model.Password,
                    Register_Date = DateTime.Now,
                    Active_Code   = model.Active_Code,
                    Active_Date   = DateTime.Now,
                    State         = 1, // Tạm thời xử lý cho active luôn.
                    Del_Flag      = false,
                    RoleId        = model.RoleId
                };

                Context.tblAccounts.InsertOnSubmit(account); // Chèn vào bảng tblAccount.
                Context.SubmitChanges();                     // Cập nhật sự thay đổi của bảng.

                // Trả về ID của tài khoản vừa tạo.
                return(account.Id);
            }
            catch (Exception ex)
            {
                string strErr = "Lỗi đăng ký tài khoản: " + model.UserName;
                strErr += "\\n" + ex.ToString();
                Logs.LogWrite(strErr);

                return((int)EnumError.INSERT_ERROR); // Trả về lỗi insert.
            }
        }
        public async Task <string> AddUpdateAccount(AccountDomainModel account)
        {
            string status = "";

            if (account.acc_id > 0)
            {
                tblAccount accountToUpdate = await accountRepository.SingleOrDefault(c => c.acc_id == account.acc_id);

                if (accountToUpdate != null)
                {
                    accountToUpdate.name       = account.name;
                    accountToUpdate.AccType_id = account.AccType_id;
                    accountToUpdate.balance    = account.balance;
                    await accountRepository.Update(accountToUpdate);

                    status = "updated";
                }
            }
            else
            {
                tblAccount accountToAdd = new tblAccount();
                accountToAdd.name       = account.name;
                accountToAdd.AccType_id = account.AccType_id;
                accountToAdd.balance    = account.balance;
                await accountRepository.Insert(accountToAdd);

                status = "added";
            }
            return(status);
        }
Exemple #14
0
 public RegisterViewModel(Register registerOpen)
 {
     register   = registerOpen;
     account    = new tblAccount();
     genderList = new List <string> {
         "M", "Z"
     };
 }
 public void AddAccount(tblAccount Account)
 {
     using (OriginatorEntities db = new OriginatorEntities())
     {
         db.tblAccounts.Add(Account);
         db.SaveChanges();
     }
 }
 /// <summary>
 /// Returns an account with the userName and Pass from tblAccount in the database.
 /// </summary>
 /// <param name="userName"></param>
 /// <param name="password"></param>
 /// <returns></returns>
 public tblAccount GetAccount(string userName)
 {
     using (CompanyEntities context = new CompanyEntities())
     {
         tblAccount account = (from a in context.tblAccounts where a.UserName == userName select a).First();
         return(account);
     }
 }
Exemple #17
0
 internal tblManager GetManager(string userName)
 {
     using (HotelEntities1 context = new HotelEntities1())
     {
         tblAccount account = (from a in context.tblAccounts where a.UserName == userName select a).First();
         tblManager manager = (from m in context.tblManagers where m.AccountID == account.AccountID select m).First();
         return(manager);
     }
 }
 public RegisterViewModel(Register registerOpen)
 {
     account         = new tblAccount();
     register        = registerOpen;
     marrigeTypeList = service.GetAllMarrigeTypes();
     genderList      = new List <string> {
         "M", "Z", "N", "X"
     };
 }
        public void UnDeleteEmployee(string id)
        {
            DataClasses1DataContext db = new DataClasses1DataContext();
            tblAccount oldAccount      = (from table in db.tblAccounts where table.userID == id select table).Single();

            oldAccount.status = "activated";
            db.SubmitChanges();
            db.Dispose();
        }
        public void AddNewEmployee(tblUser user, tblAccount account)
        {
            DataClasses1DataContext db = new DataClasses1DataContext();

            db.tblUsers.InsertOnSubmit(user);
            db.tblAccounts.InsertOnSubmit(account);
            db.SubmitChanges();
            db.Dispose();
        }
 internal tblAdministrator GetAdmin(string userName, string password)
 {
     using (CompanyEntities context = new CompanyEntities())
     {
         tblAccount       account = GetAccount(userName, password);
         tblAdministrator admin   = (from e in context.tblAdministrators where e.AccountID == account.AccountID select e).First();
         return(admin);
     }
 }
 internal tblManager GetManager(string userName)
 {
     using (CompanyEntities context = new CompanyEntities())
     {
         tblAccount account = (from a in context.tblAccounts where a.UserName == userName select a).First();
         tblManager manager = (from e in context.tblManagers where e.AccountID == account.AccountID select e).First();
         return(manager);
     }
 }
 internal tblEmployee GetEmployee(string userName, string password)
 {
     using (CompanyEntities context = new CompanyEntities())
     {
         tblAccount  account  = GetAccount(userName, password);
         tblEmployee employee = (from e in context.tblEmployees where e.AccountID == account.AccountID select e).First();
         return(employee);
     }
 }
 public AddManagerViewModel(AddManager addManagerOpen, tblAccount acountAdd)
 {
     account = acountAdd;
     manager = new tblManager();
     responsibilityLevelList = new List <int> {
         1, 2, 3
     };
     addManager = addManagerOpen;
 }
Exemple #25
0
 internal tblEmployee GetEmployee(string userName)
 {
     using (HotelEntities context = new HotelEntities())
     {
         tblAccount  account  = (from a in context.tblAccounts where a.UserName == userName select a).First();
         tblEmployee employee = (from e in context.tblEmployees where e.AccountID == account.AccountID select e).First();
         return(employee);
     }
 }
Exemple #26
0
        public SavingResult SaveNewRecord(tblAccount SaveModel)
        {
            SavingResult res = new SavingResult();

            //-- Perform Validation
            //res.ExecutionResult = eExecutionResult.ValidationError;
            //res.ValidationError = "Validation error message";
            //return res;

            //--
            using (dbVisionEntities db = new dbVisionEntities())
            {
                //tblAccount SaveModel;
                if (SaveModel.AccountName == "")
                {
                    res.ValidationError = "Can not accept blank value. Please enter BankAccount Name.";
                    res.ExecutionResult = eExecutionResult.ValidationError;
                    return(res);
                }
                else if (IsDuplicateBankAcNo(SaveModel.AccountName, SaveModel.AccountID, db))
                {
                    res.ValidationError = "Can not accept duplicate value. The BankAccount Name is already exists.";
                    res.ExecutionResult = eExecutionResult.ValidationError;
                    return(res);
                }

                if (SaveModel.AccountID == 0) // New Entry
                {
                    SaveModel.AccountType = (int)Model.Account.eAccountType.BankAccount;
                    SaveModel.rcuid       = Model.CommonProperties.LoginInfo.LoggedinUser.UserID;
                    SaveModel.CompanyID   = Model.CommonProperties.LoginInfo.LoggedInCompany.CompanyID;
                    SaveModel.rcdt        = DateTime.Now;
                    db.tblAccounts.Add(SaveModel);
                }
                else
                {
                    SaveModel.reuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID;
                    SaveModel.redt  = DateTime.Now;
                    db.tblAccounts.Attach(SaveModel);
                    db.Entry(SaveModel).State = System.Data.Entity.EntityState.Modified;
                }

                //--
                try
                {
                    db.SaveChanges();
                    res.PrimeKeyValue   = SaveModel.AccountID;
                    res.ExecutionResult = eExecutionResult.CommitedSucessfuly;
                }
                catch (Exception ex)
                {
                    CommonFunctions.GetFinalError(res, ex);
                }
            }
            return(res);
        }
Exemple #27
0
    public static DateTime?Return_Last_Login(int account_id)
    {
        DateTime?last_login = null;

        tblAccount a = ModelLayer.GetAccount(account_id);

        last_login = a.dLastUpdated;

        return(last_login);
    }
Exemple #28
0
        public static tblAccount TotblAccount(this VMAccount model)
        {
            tblAccount table = new tblAccount();

            table.Id          = model.Id;
            table.AccountName = model.AccountName;
            table.Description = model.Description;
            table.Source      = model.Source;
            return(table);
        }
Exemple #29
0
        public override void FillSelectedRecordInContent(object RecordToFill)
        {
            tblAccount EditingRecord = DALObject.FindSaveModelByPrimeKey(((BankAccountEditListModel)RecordToFill).BankAccountID);

            txtBankAcName.Text       = EditingRecord.AccountName;
            txtBankAcNo.Text         = EditingRecord.BankAccountNo;
            lookupBank.EditValue     = EditingRecord.BankNameID;
            lookupBranch.EditValue   = EditingRecord.BranchID;
            lookupCurrency.EditValue = EditingRecord.CurrencyID;
        }
        public IHttpActionResult GettblAccount(int id)
        {
            tblAccount tblAccount = db.tblAccounts.Find(id);

            if (tblAccount == null)
            {
                return(NotFound());
            }

            return(Ok(tblAccount));
        }