Ejemplo n.º 1
0
    protected void grdBank_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == Globals.GridCommandEvents.ADDNEW)
        {
            if (Page.IsValid)
            {
                GridViewRow row = (GridViewRow)(((Button)e.CommandSource).NamingContainer);

                BankDTO bankDetails = new BankDTO();
                bankDetails.Bank_Name = ((TextBox)row.FindControl("txtNewBankName")).Text;
                bankDetails.Bank_AccountNo = ((TextBox)row.FindControl("txtNewBankAccountNo")).Text;
                bankDetails.Bank_LastUpdatedDate = DateTime.Now;
                bankDetails.Bank_CreatedBy = GetCurrentUserId();
                
                ESalesUnityContainer.Container.Resolve<IMasterService>().SaveAndUpdateBankDetails(bankDetails);
                ucMessageBoxForGrid.ShowMessage("Bank details saved successfully");
            }
        }
    }
Ejemplo n.º 2
0
 /// <summary>
 /// Get bank details by bank id
 /// </summary>
 /// <param name="bankId">bank id to retreive bank details</param>
 /// <returns>returns BankDTO object</returns>
 BankDTO IMasterService.GetBanksDetailsById(int bankId)
 {
     BankDTO bankDTO = new BankDTO();
     AutoMapper.Mapper.Map(base.BankRepository.GetSingle(f => f.Bank_Id == bankId), bankDTO);
     return bankDTO;
 }
Ejemplo n.º 3
0
    protected void grdBank_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        if (Page.IsValid)
        {
            BankDTO bankDetails = new BankDTO();
            bankDetails = ESalesUnityContainer.Container.Resolve<IMasterService>()
                .GetBanksDetailsById(Convert.ToInt32(grdBank.DataKeys[e.RowIndex].Value));

            bankDetails.Bank_Name = ((TextBox)grdBank.Rows[e.RowIndex].FindControl("txtBankName")).Text;
            bankDetails.Bank_AccountNo = ((TextBox)grdBank.Rows[e.RowIndex].FindControl("txtBankAccountNo")).Text;
            bankDetails.Bank_LastUpdatedDate = DateTime.Now;
            bankDetails.Bank_CreatedBy = GetCurrentUserId();           

            //To update business type
            ESalesUnityContainer.Container.Resolve<IMasterService>().SaveAndUpdateBankDetails(bankDetails);
            ucMessageBoxForGrid.ShowMessage("Bank details updated successfully");
        }  
    }
Ejemplo n.º 4
0
        void IMasterService.SaveAndUpdateBankDetails(BankDTO bankDetails)
        {
            bank bankEntity = new bank();
            using (TransactionScope transactionScope = new TransactionScope())
            {
                AutoMapper.Mapper.Map(bankDetails, bankEntity);

                if (bankDetails.Bank_Id == 0)
                {
                    base.BankRepository.Save(bankEntity);
                }
                else
                {
                    base.BankRepository.Update(bankEntity);
                }
                transactionScope.Complete();
            }
        }