Beispiel #1
0
        protected void ctlBankFormView_ItemUpdating(object sender, FormViewUpdateEventArgs e)
        {
            short  bankId = UIHelper.ParseShort(ctlBankFormView.DataKey.Value.ToString());
            DbBank dbBank = DbBankService.FindByIdentity(bankId);

            TextBox  txtBankNo  = ctlBankFormView.FindControl("ctlTxtBankNo") as TextBox;
            TextBox  txtComment = ctlBankFormView.FindControl("ctlTxtComment") as TextBox;
            CheckBox chkActive  = ctlBankFormView.FindControl("chkActive") as CheckBox;

            dbBank.BankNo  = txtBankNo.Text;
            dbBank.Comment = txtComment.Text;
            dbBank.Active  = chkActive.Checked;

            dbBank.UpdPgm  = ProgramCode;
            dbBank.UpdDate = DateTime.Now.Date;
            dbBank.UpdBy   = UserAccount.UserID;

            try
            {
                DbBankService.SaveOrUpdate(dbBank);

                // Cancel insert with DataSource.
                e.Cancel = true;
                ctlGridBank.DataCountAndBind();
                ctlBankModalPopupExtender.Hide();
                UpdatePanelGridView.Update();
            }
            catch
            { }
            //catch ( ServiceValidationException ex)
            //{
            //    ValidationErrors.MergeErrors(ex.ValidationErrors);
            //}
        }
 /// <summary>
 /// Save in operation history of given account the operation record
 /// </summary>
 /// <param name="accountId">account id (from database)</param>
 /// <param name="operationRecord">operation record to save</param>
 public void SaveOperationToHistory(int accountId, OperationRecord operationRecord)
 {
     using (var db = new DbBank())
     {
         db.Insert(new DbOperationRecord(accountId, operationRecord));
     }
 }
Beispiel #3
0
        protected void ctlBankFormView_ItemInserting(object sender, FormViewInsertEventArgs e)
        {
            DbBank dbBank = new DbBank();

            TextBox  txtBankNo  = ctlBankFormView.FindControl("ctlTxtBankNo") as TextBox;
            TextBox  txtComment = ctlBankFormView.FindControl("ctlTxtComment") as TextBox;
            CheckBox chkActive  = ctlBankFormView.FindControl("chkActive") as CheckBox;

            dbBank.BankNo  = txtBankNo.Text;
            dbBank.Comment = txtComment.Text;
            dbBank.Active  = chkActive.Checked;

            dbBank.UpdPgm  = ProgramCode;
            dbBank.CreDate = DateTime.Now.Date;
            dbBank.UpdDate = DateTime.Now.Date;
            dbBank.CreBy   = UserAccount.UserID;
            dbBank.UpdBy   = UserAccount.UserID;

            try
            {
                DbBankService.Save(dbBank);
                e.Cancel = true;
                ctlGridBank.DataCountAndBind();
                ctlBankModalPopupExtender.Hide();
                UpdatePanelGridView.Update();
            }
            catch
            { }
            //catch (ServiceValidationException ex)
            //{
            //    ValidationErrors.MergeErrors(ex.ValidationErrors);
            //}
        }
Beispiel #4
0
        /// <summary>
        /// Расчет комиссии банка
        /// </summary>
        /// <param name="senderBank"></param>
        /// <param name="senderInvoice"></param>
        /// <param name="recipientInvoice"></param>
        /// <param name="ammount"></param>
        /// <returns></returns>
        public static decimal CalcBankInterested(DbBank senderBank, DbInvoice senderInvoice, DbInvoice recipientInvoice, decimal ammount)
        {
            var percent = (IsInternalTransfer(senderInvoice, recipientInvoice))
                          ? senderBank.InterestInternalTransfer
                          : senderBank.InterestExternalTransfer;

            return(CalcPercent(ammount, percent));
        }
 /// <summary>
 /// Save account balance into database
 /// </summary>
 /// <param name="account">account which balance will be saved</param>
 public void SaveAccountBalance(IPublicAccount account)
 {
     using (var db = new DbBank())
     {
         db.Accounts
         .Where(p => p.InnerAccountNumber == account.AccountNumber.InnerNumber)
         .Set(p => p.BalanceValue, account.GetBalanceValue())
         .Update();
     }
 }
Beispiel #6
0
 public void Cleanup()
 {
     using (var db = new DbBank())
     {
         db.AccessTokens.Where(p => p.Token == NewAccessToken).Delete();
         db.Accounts.Where(p => p.InnerAccountNumber == ValidInnerAccountNumber)
         .Set(p => p.BalanceValue, PreviousBalanceValue)
         .Update();
         db.OperationRecord.Where(p => p.Title == NewOperationTitle).Delete();
     }
 }
Beispiel #7
0
        private static DbOperationRecord GetSavedOperation(OperationRecord operationRecord)
        {
            using (var db = new DbBank())
            {
                var query = from p in db.OperationRecord
                            where p.Title == operationRecord.Title
                            select p;

                return(query.ToList().FirstOrDefault());
            }
        }
Beispiel #8
0
 private static List <IUser> GetUsersFromDb()
 {
     using (var db = new DbBank())
     {
         var query = from p in db.Users
                     select p;
         return(query.ToList()
                .Select(user => CreateUser(user.Login, user.HashedPassword, user.Id))
                .ToList());
     }
 }
Beispiel #9
0
        private static decimal GetBalanceValue()
        {
            using (var db = new DbBank())
            {
                var query = from p in db.Accounts
                            where p.InnerAccountNumber == ValidInnerAccountNumber
                            select p;

                var account = query.ToList().FirstOrDefault();
                return(account?.BalanceValue ?? 0.0m);
            }
        }
Beispiel #10
0
 public static List <string> GetAccessTokenForUser(int id)
 {
     using (var db = new DbBank())
     {
         var query = from p in db.AccessTokens
                     where p.UserId == id
                     select p;
         return(query.ToList()
                .Select(token => token.Token)
                .ToList());
     }
 }
Beispiel #11
0
 private static List <OperationRecord> GetOperationRecords(int id)
 {
     using (var db = new DbBank())
     {
         var query = from p in db.OperationRecord
                     where p.AccountId == id
                     select p;
         return(query.ToList()
                .Select(GetOperationRecord)
                .ToList());
     }
 }
        /// <summary>
        /// Inserts Access Token into database
        /// </summary>
        /// <param name="userId">user id (stored in database)</param>
        /// <param name="accessToken">access token to save</param>
        public void SaveToken(int userId, string accessToken)
        {
            var token = new DbAccessToken
            {
                UserId = userId,
                Token  = accessToken
            };

            using (var db = new DbBank())
            {
                db.Insert(token);
            }
        }
Beispiel #13
0
 private static List <IAccount> GetAccountsForUser(int id)
 {
     using (var db = new DbBank())
     {
         var query = from p in db.Accounts
                     where p.UserId == id
                     select p;
         return(query.ToList()
                .Select(CreateAccount)
                .Cast <IAccount>()
                .ToList());
     }
 }
Beispiel #14
0
 /// <summary>
 /// Finds account id for a given inner account number
 /// </summary>
 /// <param name="innerAccountNumber">inner account number (without bank id and control sum)</param>
 /// <returns>account id</returns>
 public int GetAccountId(string innerAccountNumber)
 {
     using (var db = new DbBank())
     {
         var query = from p in db.Accounts
                     where p.InnerAccountNumber == innerAccountNumber
                     select p;
         var searchedAccount = query.ToList()
                               .FirstOrDefault();
         if (searchedAccount == null)
         {
             throw new FaultException("Internal Error");
         }
         return(searchedAccount.Id);
     }
 }
Beispiel #15
0
 /// <summary>
 /// Finds user id in database for a given login
 /// </summary>
 /// <param name="login">user login</param>
 /// <returns>user id</returns>
 public int GetUserId(string login)
 {
     using (var db = new DbBank())
     {
         var query = from p in db.Users
                     where p.Login == login
                     select p;
         var searchedUser = query.ToList()
                            .FirstOrDefault();
         if (searchedUser == null)
         {
             throw new FaultException("Internal Error");
         }
         return(searchedUser.Id);
     }
 }
Beispiel #16
0
        protected void ctlGridBank_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "BankEdit")
            {
                int   rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex;
                short bankId   = UIHelper.ParseShort(ctlGridBank.DataKeys[rowIndex].Value.ToString());

                ctlGridBank.EditIndex = rowIndex;
                IList <DbBank> bankList = new List <DbBank>();
                DbBank         bank     = DbBankService.FindByIdentity(bankId);

                bankList.Add(bank);

                ctlBankFormView.DataSource = bankList;
                ctlBankFormView.PageIndex  = 0;

                ctlBankFormView.ChangeMode(FormViewMode.Edit);
                ctlBankFormView.DataBind();

                UpdatePanelBankForm.Update();
                ctlBankModalPopupExtender.Show();
                BankLangGridViewFinish();
            }
            else if (e.CommandName == "Select")
            {
                int   rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
                short bankId   = UIHelper.ParseShort(ctlGridBank.DataKeys[rowIndex].Value.ToString());

                ctlBankLangGrid.DataSource = DbBankLangService.FindByBankId(bankId);
                ctlBankLangGrid.DataBind();

                if (ctlBankLangGrid.Rows.Count > 0)
                {
                    ctlSubmit.Visible          = true;
                    ctlCancel.Visible          = true;
                    ctlBankLangLangFds.Visible = true;
                }
                else
                {
                    ctlSubmit.Visible          = false;
                    ctlCancel.Visible          = false;
                    ctlBankLangLangFds.Visible = false;
                }
                ctlBankLangUpdatePanel.Update();
            }
        }
Beispiel #17
0
        protected void ctlSubmit_Click(object sender, EventArgs e)
        {
            IList <DbBankLang> bankLangList = new List <DbBankLang>();
            DbBank             bank         = new DbBank(UIHelper.ParseShort(ctlGridBank.SelectedValue.ToString()));

            foreach (GridViewRow row in ctlBankLangGrid.Rows)
            {
                TextBox  ctlBankName = (TextBox)ctlBankLangGrid.Rows[row.RowIndex].FindControl("ctlBankName");
                TextBox  ctlABBRName = (TextBox)ctlBankLangGrid.Rows[row.RowIndex].FindControl("ctlABBRName");
                TextBox  ctlComment  = (TextBox)ctlBankLangGrid.Rows[row.RowIndex].FindControl("ctlComment");
                CheckBox ctlActive   = (CheckBox)ctlBankLangGrid.Rows[row.RowIndex].FindControl("ctlActive");

                if (!string.IsNullOrEmpty(ctlBankName.Text) || !string.IsNullOrEmpty(ctlABBRName.Text) || !string.IsNullOrEmpty(ctlComment.Text))
                {
                    //modify by tom 28/01/2009
                    //SS.DB.DTO.DbLanguage lang = new SS.DB.DTO.DbLanguage(UIHelper.ParseShort(ctlBankLangGrid.DataKeys[row.RowIndex].Value.ToString()));
                    DbLanguage lang = new DbLanguage(UIHelper.ParseShort(ctlBankLangGrid.DataKeys[row.RowIndex].Value.ToString()));

                    DbBankLang bankLang = new DbBankLang();

                    bankLang.Language = lang;
                    bankLang.Bank     = bank;
                    bankLang.BankName = ctlBankName.Text;
                    bankLang.AbbrName = ctlABBRName.Text;
                    bankLang.Comment  = ctlComment.Text;
                    bankLang.Active   = ctlActive.Checked;

                    bankLang.CreBy   = UserAccount.UserID;
                    bankLang.CreDate = DateTime.Now;
                    bankLang.UpdBy   = UserAccount.UserID;;
                    bankLang.UpdDate = DateTime.Now;
                    bankLang.UpdPgm  = ProgramCode;

                    bankLangList.Add(bankLang);
                }
            }
            DbBankLangService.UpdateBankLang(bankLangList);

            ctlGridBank.DataCountAndBind();
            UpdatePanelGridView.Update();

            BankLangGridViewFinish();
        }
Beispiel #18
0
        protected void ctlBtnDeleteBank_Click(object sender, EventArgs e)
        {
            foreach (GridViewRow row in ctlGridBank.Rows)
            {
                if ((row.RowType == DataControlRowType.DataRow) && ((CheckBox)row.FindControl("ctlSelect")).Checked)
                {
                    short bankId = UIHelper.ParseShort(ctlGridBank.DataKeys[row.RowIndex].Value.ToString());
                    if (!((CheckBox)row.FindControl("ctlChkActive")).Checked)//ไม่ Active
                    {
                        try
                        {
                            BankLangGridViewFinish();
                            DbBank bank = DbBankService.FindProxyByIdentity(bankId);
                            ScgDbDaoProvider.DbBankLangDao.DeleteAllBankLang(bankId);
                            DbBankService.Delete(bank);
                            UpdatePanelGridView.Update();
                        }
                        catch (Exception ex)
                        {
                            if (((System.Data.SqlClient.SqlException)(ex.GetBaseException())).Number == 547)
                            {
                                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertInUseData",
                                                                        "alert('Bank ID : " + bankId.ToString() + " is Active. Can't Delete It');", true);
                            }
                        }
                    }
                    else//Active
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertActiveData",
                                                                "alert('Bank ID :" + bankId.ToString() + " is Active. Can't Delete It');", true);
                    }
                }
            }

            ctlGridBank.DataCountAndBind();
        }
Beispiel #19
0
        /// <summary>
        /// Создать уведомления
        /// </summary>
        /// <param name="senderInvoiceType"></param>
        /// <param name="senderBank"></param>
        /// <returns></returns>
        public static IList <Notification> CreateNotifications(DbInvoiceType senderInvoiceType, DbBank senderBank)
        {
            var result = new List <Notification>
            {
                new Notification
                {
                    Type = senderInvoiceType.AdditionalActionsType.ToString()
                },
                new Notification
                {
                    Type = senderBank.AdditionalActionsType.ToString()
                }
            };

            return(result);
        }
Beispiel #20
0
        protected override void Seed(OperationsDbContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data.

            if (!context.Banks.Any())
            {
                // Banks
                var sberbank = new DbBank
                {
                    Id   = Guid.Parse("{569E5810-82BD-498C-AB21-2E1E8593A7F0}"),
                    Name = "Сбербанк",
                    InterestInternalTransfer = 0,
                    InterestExternalTransfer = 1,
                    AdditionalActionsType    = DbAdditionalActionsType.SendTransactionsTaxOffice
                };

                var vtbbank = new DbBank
                {
                    Id   = Guid.Parse("{00C7DA8B-A7BE-446D-AD5F-E41AF650B576}"),
                    Name = "Втб",
                    InterestInternalTransfer = 0,
                    InterestExternalTransfer = 2,
                    AdditionalActionsType    = DbAdditionalActionsType.SendTransactionPartnerBank
                };

                var alfabank = new DbBank
                {
                    Id   = Guid.Parse("{264848B8-4782-4FC1-A265-D255CDE56911}"),
                    Name = "Альфабанк",
                    InterestInternalTransfer = 1,
                    InterestExternalTransfer = 2.5m,
                    AdditionalActionsType    = DbAdditionalActionsType.DisplayWindowConfirmingOperation
                };

                var banks = new List <DbBank>
                {
                    sberbank, vtbbank, alfabank
                };

                banks.ForEach(s => context.Banks.AddOrUpdate(p => p.Name, s));


                // DbInvoiceType
                var individual = new DbInvoiceType {
                    Id = Guid.NewGuid(), Name = "Физическое лицо",
                };
                var legal = new DbInvoiceType {
                    Id = Guid.NewGuid(), Name = "Юридическое лицо",
                };
                var nonresident = new DbInvoiceType {
                    Id = Guid.NewGuid(), Name = "Нерезидент",
                };

                var invoiceTypes = new List <DbInvoiceType>
                {
                    individual,
                    legal,
                    nonresident,
                };

                invoiceTypes.ForEach(s => context.InvoiceTypes.AddOrUpdate(p => p.Name, s));

                var matrix = new List <DbMatrixInvoiceTypes>
                {
                    new DbMatrixInvoiceTypes {
                        Id = Guid.Parse("{A538953A-169C-400D-B686-CEFD66FE9332}"), SenderTypeId = individual.Id, RecipientTypeId = individual.Id, Interest = 0
                    },
                    new DbMatrixInvoiceTypes {
                        Id = Guid.Parse("{1B829439-7FF2-46DA-95FC-0A4955F0E1E3}"), SenderTypeId = individual.Id, RecipientTypeId = legal.Id, Interest = 2
                    },
                    new DbMatrixInvoiceTypes {
                        Id = Guid.Parse("{8D42D820-26BF-49D2-9D40-399FFD48CB6C}"), SenderTypeId = individual.Id, RecipientTypeId = nonresident.Id, Interest = 4
                    },

                    new DbMatrixInvoiceTypes {
                        Id = Guid.Parse("{0401A91C-33CD-40ED-A667-EB29B47D1110}"), SenderTypeId = legal.Id, RecipientTypeId = individual.Id, Interest = 0
                    },
                    new DbMatrixInvoiceTypes {
                        Id = Guid.Parse("{776E4438-C0C1-47A5-B6BF-58277A00D021}"), SenderTypeId = legal.Id, RecipientTypeId = legal.Id, Interest = 3
                    },
                    new DbMatrixInvoiceTypes {
                        Id = Guid.Parse("{D192504D-5C29-47D8-97FC-DCE72E5B7F8E}"), SenderTypeId = legal.Id, RecipientTypeId = nonresident.Id, Interest = 6
                    },

                    new DbMatrixInvoiceTypes {
                        Id = Guid.Parse("{60121C40-3823-463A-9186-E307507C7A5C}"), SenderTypeId = nonresident.Id, RecipientTypeId = individual.Id, Interest = 0
                    },
                    new DbMatrixInvoiceTypes {
                        Id = Guid.Parse("{A32CCDDE-640D-4328-8914-665BE96B96B8}"), SenderTypeId = nonresident.Id, RecipientTypeId = legal.Id, Interest = 4
                    },
                    new DbMatrixInvoiceTypes {
                        Id = Guid.Parse("{C996F506-8453-487D-80FE-F41991041368}"), SenderTypeId = nonresident.Id, RecipientTypeId = nonresident.Id, Interest = 6
                    },
                };

                matrix.ForEach(s => context.Matrices.AddOrUpdate(p => p.Id, s));

                var invoices = new List <DbInvoice>
                {
                    new DbInvoice
                    {
                        BankId        = sberbank.Id,
                        InvoiceTypeId = individual.Id,
                        Ammount       = 1000,
                        Number        = "58000000000000000001",
                    },
                    new DbInvoice
                    {
                        BankId        = sberbank.Id,
                        InvoiceTypeId = individual.Id,
                        Ammount       = 1000,
                        Number        = "58000000000000000002",
                    },

                    new DbInvoice
                    {
                        BankId        = sberbank.Id,
                        InvoiceTypeId = individual.Id,
                        Ammount       = 5000,
                        Number        = "58000000000000000003",
                    },
                    new DbInvoice
                    {
                        BankId        = sberbank.Id,
                        InvoiceTypeId = individual.Id,
                        Ammount       = 2000,
                        Number        = "58000000000000000004",
                    },
                    new DbInvoice
                    {
                        BankId        = sberbank.Id,
                        InvoiceTypeId = individual.Id,
                        Ammount       = 2000,
                        Number        = "58000000000000000005",
                    },
                    new DbInvoice
                    {
                        BankId        = sberbank.Id,
                        InvoiceTypeId = individual.Id,
                        Ammount       = 2000,
                        Number        = "58000000000000000006",
                    },
                    new DbInvoice
                    {
                        BankId        = sberbank.Id,
                        InvoiceTypeId = individual.Id,
                        Ammount       = 2000,
                        Number        = "58000000000000000007",
                    },
                    new DbInvoice
                    {
                        BankId        = sberbank.Id,
                        InvoiceTypeId = individual.Id,
                        Ammount       = 2000,
                        Number        = "58000000000000000008",
                    },
                    new DbInvoice
                    {
                        BankId        = sberbank.Id,
                        InvoiceTypeId = individual.Id,
                        Ammount       = 2000,
                        Number        = "58000000000000000009",
                    },
                    new DbInvoice
                    {
                        BankId        = sberbank.Id,
                        InvoiceTypeId = individual.Id,
                        Ammount       = 2000,
                        Number        = "58000000000000000010",
                    },
                    new DbInvoice
                    {
                        BankId        = sberbank.Id,
                        InvoiceTypeId = individual.Id,
                        Ammount       = 2000,
                        Number        = "58000000000000000011",
                    },
                    new DbInvoice
                    {
                        BankId        = sberbank.Id,
                        InvoiceTypeId = individual.Id,
                        Ammount       = 2000,
                        Number        = "58000000000000000012",
                    },
                    new DbInvoice
                    {
                        BankId        = sberbank.Id,
                        InvoiceTypeId = individual.Id,
                        Ammount       = 2000,
                        Number        = "58000000000000000013",
                    },
                    new DbInvoice
                    {
                        BankId        = sberbank.Id,
                        InvoiceTypeId = individual.Id,
                        Ammount       = 2000,
                        Number        = "58000000000000000014",
                    },
                    new DbInvoice
                    {
                        BankId        = sberbank.Id,
                        InvoiceTypeId = individual.Id,
                        Ammount       = 2000,
                        Number        = "58000000000000000015",
                    },

                    new DbInvoice
                    {
                        BankId        = vtbbank.Id,
                        InvoiceTypeId = individual.Id,
                        Ammount       = 100000m,
                        Number        = "68000000000000000001",
                    },
                    new DbInvoice
                    {
                        BankId        = vtbbank.Id,
                        InvoiceTypeId = nonresident.Id,
                        Ammount       = 100000,
                        Number        = "68000000000000000002",
                    },

                    new DbInvoice
                    {
                        BankId        = alfabank.Id,
                        InvoiceTypeId = legal.Id,
                        Ammount       = 100000,
                        Number        = "78000000000000000002",
                    },
                };

                invoices.ForEach(s => context.Invoices.AddOrUpdate(p => p.Number, s));

                context.SaveChanges();
            }
        }