public bool MoveLibTransToCashTrans(int libTrnsId, bool?IsMovedToTransaction, int?cashTrnsId) { using (IDbSvc dbSvc = new DbSvc(_configSvc)) { try { dbSvc.OpenConnection(); MySqlCommand command = new MySqlCommand(); command.CommandText = "UPDATE LibraryTransaction SET IsMovedToTransaction=@isMoved, TransactionIdForDue=@trnsIdForDue WHERE LibraryTranId=@libTrnsId"; command.Parameters.Add("@isMoved", MySqlDbType.Bit).Value = IsMovedToTransaction; command.Parameters.Add("@trnsIdForDue", MySqlDbType.Int32).Value = cashTrnsId; command.Parameters.Add("@libTrnsId", MySqlDbType.Int32).Value = libTrnsId; command.Connection = dbSvc.GetConnection() as MySqlConnection; return(command.ExecuteNonQuery() > 0); } catch (Exception exp) { _logger.Log(exp); throw exp; } } }
public StatusDTO <TransactionLogPaymentsDTO> Insert(TransactionLogPaymentsDTO data) { using (IDbSvc dbSvc = new DbSvc(_configSvc)) { try { dbSvc.OpenConnection(); MySqlCommand command = new MySqlCommand(); command.CommandText = "INSERT INTO transactionlogpayments(transactionlogid, paymentdate, " + "currentamount, paymentchequeno, paymentmode, currentadjustingamount) VALUES (@transLogId, @paymentDate, " + "@curramount, @chqNo, @mode, @currentadjusting)"; command.Connection = dbSvc.GetConnection() as MySqlConnection; command.Parameters.Add("@transLogId", MySqlDbType.Int32).Value = data.TransactionLog.TransactionLogId; command.Parameters.Add("@paymentDate", MySqlDbType.DateTime).Value = data.PaymentDate.Value; command.Parameters.Add("@curramount", MySqlDbType.Decimal).Value = data.CurrentAmount.Value; if (string.IsNullOrEmpty(data.PaymentChequeNo)) { command.Parameters.Add("@chqNo", MySqlDbType.VarChar).Value = DBNull.Value; } else { command.Parameters.Add("@chqNo", MySqlDbType.VarChar).Value = data.PaymentChequeNo; } command.Parameters.Add("@mode", MySqlDbType.VarChar).Value = data.PaymentMode; command.Parameters.Add("@currentadjusting", MySqlDbType.Decimal).Value = data.CurrentAdjustingAmount.Value; StatusDTO <TransactionLogPaymentsDTO> status = new StatusDTO <TransactionLogPaymentsDTO>(); if (command.ExecuteNonQuery() > 0) { status.IsSuccess = true; status.IsException = false; return(status); } status.IsSuccess = false; status.IsException = false; status.FailureReason = "Insert failed"; return(status); } catch (Exception exp) { _logger.Log(exp); throw exp; } } }
public override void OnException(ExceptionContext filterContext) { Exception ex = filterContext.Exception; _logger.Log(ex); filterContext.ExceptionHandled = true; var controllerName = (string)filterContext.RouteData.Values["controller"]; var actionName = (string)filterContext.RouteData.Values["action"]; var model = new HandleErrorInfo(filterContext.Exception, controllerName, actionName); filterContext.ExceptionHandled = true; filterContext.Result = new ViewResult() { ViewName = "~/Views/Error/Error.cshtml", ViewData = new ViewDataDictionary <HandleErrorInfo>(model) }; }
static void Main(string[] args) { string diResolverPath = System.Configuration.ConfigurationManager.AppSettings["DIResolverPath"]; StandardKernel kernel = new StandardKernel(); kernel.Load(diResolverPath); try { Console.WriteLine("*** RUNNING TRANSACTION RULES ***"); Console.WriteLine("*** WINDOW WILL BE CLOSED AUTOMATICALLY WHEN COMPLETED ***"); Console.WriteLine("*** PLEASE DON'T CLOSE WINDOW ***"); ITransactionSvc trnsSvc = kernel.Get <ITransactionSvc>(); trnsSvc.AddRegularTransactions(); trnsSvc.CheckDuesAndAddFine(); trnsSvc.CheckLibraryDueAndAddFine(); } catch (Exception exp) { ILogSvc logger = kernel.Get <ILogSvc>(); logger.Log(exp); } }
public StatusDTO <TransactionMasterDTO> Insert(TransactionMasterDTO data) { StatusDTO <TransactionMasterDTO> status = new StatusDTO <TransactionMasterDTO>(); using (IDbSvc dbSvc = new DbSvc(_configSvc)) { try { dbSvc.OpenConnection(); MySqlCommand command = new MySqlCommand(); command.CommandText = "INSERT INTO transactionmaster (TransactionType, TransactionName, IsPenalty, Frequency, DayToRun, YearlyDayToRun, IsdifferentTo, Active)" + " VALUES(@transactionType, @trName, @isPenalty, @frequency, @dayToRun, @yearlyDayToRun, @isdifferentTo, @active)"; command.Connection = dbSvc.GetConnection() as MySqlConnection; command.Parameters.Add("@transactionType", MySqlDbType.String).Value = data.TransactionType; command.Parameters.Add("@trName", MySqlDbType.String).Value = data.TransactionName; command.Parameters.Add("@isPenalty", MySqlDbType.Bit).Value = data.IsPenalty; command.Parameters.Add("@frequency", MySqlDbType.String).Value = data.Frequency; command.Parameters.Add("@dayToRun", MySqlDbType.String).Value = data.DayToRun; command.Parameters.Add("@yearlyDayToRun", MySqlDbType.String).Value = data.YearlyDayToRun; command.Parameters.Add("@isdifferentTo", MySqlDbType.String).Value = data.IsDiffTo; command.Parameters.Add("@active", MySqlDbType.Bit).Value = data.Active; if (command.ExecuteNonQuery() > 0) { status.IsSuccess = true; status.IsException = false; status.ReturnObj = data; } return(status); } catch (Exception exp) { _logger.Log(exp); throw exp; } } }
public void AddRegularTransactions() { FillTransDetails(); DataTable dtReader = _uTransSvc.GetUserTransactions(_runDate); if (dtReader != null) { foreach (DataRow reader in dtReader.Rows) { try { using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required)) { DateTime?lastDayOfRun = null; DateTime?nextDayToRun = null; string isDiffTo = string.Empty; int transMasterId = (int)reader["TranMasterId"]; if (IsTransactionRequired(transMasterId, string.IsNullOrEmpty(reader["NextAutoTransactionOn"].ToString())?null: reader["NextAutoTransactionOn"], string.IsNullOrEmpty(reader["LastAutoTransactionOn"].ToString())?null: reader["LastAutoTransactionOn"], out lastDayOfRun, out nextDayToRun, out isDiffTo)) { DataRow[] rules = GetRuleRow(transMasterId, isDiffTo, reader["StandardId"], reader["SectionId"], reader["UserMasterId"], reader["ClassTypeId"]); if (rules != null) { //Insert records as pending in trans log TransactionLogDTO trnsLogDto = new TransactionLogDTO(); trnsLogDto.Active = true; trnsLogDto.User = new UserMasterDTO(); trnsLogDto.User.UserMasterId = (int)reader["UserMasterId"]; trnsLogDto.TransactionDate = _runDate; if (rules[0]["FirstDueAfterDays"] != null || !string.IsNullOrEmpty(rules[0]["FirstDueAfterDays"].ToString())) { trnsLogDto.TransactionDueDate = _runDate.AddDays((int)rules[0]["FirstDueAfterDays"]); } else { trnsLogDto.TransactionDueDate = null; } trnsLogDto.TransactionPreviousDueDate = null; trnsLogDto.ParentTransactionLogId = null; trnsLogDto.IsCompleted = false; trnsLogDto.CompletedOn = null; trnsLogDto.AmountImposed = CalculateAmount(string.IsNullOrEmpty(reader["GraceAmountOn"].ToString())?null: reader["GraceAmountOn"], string.IsNullOrEmpty(reader["GraceAmount"].ToString())?null: reader["GraceAmount"], double.Parse(rules[0]["ActualAmount"].ToString())); trnsLogDto.AmountGiven = null; trnsLogDto.DueAmount = trnsLogDto.AmountImposed; trnsLogDto.TransferMode = null; trnsLogDto.Location = null; if (string.Equals(reader["RoleId"].ToString(), _commonConfig["STUD_ROLE_ID"])) { trnsLogDto.StandardSectionMap = new StandardSectionMapDTO(); trnsLogDto.StandardSectionMap.StandardSectionId = (int)reader["StandardSectionId"]; } else { trnsLogDto.StandardSectionMap = null; } trnsLogDto.TransactionType = reader["TransactionType"].ToString(); trnsLogDto.HasPenalty = false; trnsLogDto.TransactionRule = new TransactionRuleDTO(); trnsLogDto.TransactionRule.TranRuleId = (int)rules[0]["TranRuleId"]; if (trnsLogDto.TransactionDueDate != null) { trnsLogDto.PenaltyTransactionRule = new TransactionRuleDTO(); trnsLogDto.PenaltyTransactionRule.TranRuleId = trnsLogDto.TransactionRule.TranRuleId; } StatusDTO <TransactionLogDTO> status = _transLog.Insert(trnsLogDto); if (status.IsSuccess) { UserTransactionDTO uTrns = new UserTransactionDTO(); uTrns.LastAutoTransactionOn = lastDayOfRun; uTrns.NextAutoTransactionOn = nextDayToRun; uTrns.UserTransactionId = (int)reader["UserTransactionId"]; StatusDTO uTrnsStatus = _uTransSvc.UpdateTransLastRunNextRun(uTrns); if (uTrnsStatus.IsSuccess) { ts.Complete(); } } } } } } catch (Exception exp) { _logger.Log(exp); } } } //Disposing source data _uTransSvc.Dispose(); if (dtReader != null) { dtReader.Dispose(); dtReader = null; } }
public StatusDTO <UserTransactionDTO> Insert(UserTransactionDTO data) { StatusDTO <UserTransactionDTO> status = new StatusDTO <UserTransactionDTO>(); status.IsSuccess = false; using (IDbSvc dbSvc = new DbSvc(_configSvc)) { try { dbSvc.OpenConnection(); MySqlCommand command = new MySqlCommand(); command.CommandText = "INSERT INTO UserTransaction(UserMasterId, TranMasterId, GraceAmountOn, GraceAmount, Active) VALUES (@userMasterId, @tranMasterId, @graceAmountOn, @graceAmount, 1)"; if (data.User != null && data.User.UserMasterId > 0) { command.Parameters.Add("@userMasterId", MySqlDbType.Int32).Value = data.User.UserMasterId; } else { command.Parameters.Add("@userMasterId", MySqlDbType.Int32).Value = DBNull.Value; } if (data.Transaction != null && data.Transaction.TranMasterId > 0) { command.Parameters.Add("@tranMasterId", MySqlDbType.Int32).Value = data.Transaction.TranMasterId; } else { command.Parameters.Add("@tranMasterId", MySqlDbType.Int32).Value = DBNull.Value; } if (!string.IsNullOrEmpty(data.GraceAmountIn) && !string.Equals(data.GraceAmountIn, "-1")) { command.Parameters.Add("@graceAmountOn", MySqlDbType.String).Value = data.GraceAmountIn; } else { command.Parameters.Add("@graceAmountOn", MySqlDbType.String).Value = DBNull.Value; } if (data.GraceAmount != null) { command.Parameters.Add("@graceAmount", MySqlDbType.String).Value = data.GraceAmount.Value; } else { command.Parameters.Add("@graceAmount", MySqlDbType.String).Value = DBNull.Value; } command.Connection = dbSvc.GetConnection() as MySqlConnection; if (command.ExecuteNonQuery() > 0) { status.IsSuccess = true; } return(status); } catch (Exception exp) { _logger.Log(exp); throw exp; } } }
public StatusDTO <TransactionRuleDTO> Insert(TransactionRuleDTO data) { StatusDTO <TransactionRuleDTO> status = new StatusDTO <TransactionRuleDTO>(); using (IDbSvc dbSvc = new DbSvc(_configSvc)) { try { dbSvc.OpenConnection(); MySqlCommand command = new MySqlCommand(); command.Connection = dbSvc.GetConnection() as MySqlConnection; command.CommandText = "INSERT INTO transactionrule(Active, TranMasterId, UserMasterId, StandardId, SectionId, FirstDueAfterDays, DueDateIncreasesBy, PenaltyCalculatedIn, PenaltyAmount, ActualAmount, ClassTypeId, RuleName, PenaltyTransactionType, PenaltyTranRuleId)" + " VALUES (@active, @tmId,@umId,@stdId,@secId,@frstDueAfter,@dueDTIncreasesBy,@penaltyCalcIn,@penaltyAmt,@actualAmt,@ctId,@ruleName,@penaltyTrType,@penaltyTrRuleId)"; command.Parameters.Add("@active", MySqlDbType.Bit).Value = data.Active; if (data.TranMaster != null && data.TranMaster.TranMasterId > 0) { command.Parameters.Add("@tmId", MySqlDbType.Int32).Value = data.TranMaster.TranMasterId; } else { command.Parameters.Add("@tmId", MySqlDbType.Int32).Value = DBNull.Value; } if (data.UserDTO != null && data.UserDTO.UserMasterId > 0) { command.Parameters.Add("@umId", MySqlDbType.Int32).Value = data.UserDTO.UserMasterId; } else { command.Parameters.Add("@umId", MySqlDbType.Int32).Value = DBNull.Value; } if (data.Standard != null && data.Standard.StandardId > 0) { command.Parameters.Add("@stdId", MySqlDbType.Int32).Value = data.Standard.StandardId; } else { command.Parameters.Add("@stdId", MySqlDbType.Int32).Value = DBNull.Value; } if (data.Section != null && data.Section.SectionId > 0) { command.Parameters.Add("@secId", MySqlDbType.Int32).Value = data.Section.SectionId; } else { command.Parameters.Add("@secId", MySqlDbType.Int32).Value = DBNull.Value; } command.Parameters.Add("@frstDueAfter", MySqlDbType.Int32).Value = data.FirstDueAfterDays; command.Parameters.Add("@dueDTIncreasesBy", MySqlDbType.Int32).Value = data.DueDateIncreasesBy; if (!string.IsNullOrEmpty(data.PenaltyCalculatedIn)) { command.Parameters.Add("@penaltyCalcIn", MySqlDbType.String).Value = data.PenaltyCalculatedIn; } else { command.Parameters.Add("@penaltyCalcIn", MySqlDbType.String).Value = DBNull.Value; } if (data.PenaltyAmount != null) { command.Parameters.Add("@penaltyAmt", MySqlDbType.Double).Value = data.PenaltyAmount.Value; } else { command.Parameters.Add("@penaltyAmt", MySqlDbType.Double).Value = DBNull.Value; } if (data.ActualAmount != null) { command.Parameters.Add("@actualAmt", MySqlDbType.Double).Value = data.ActualAmount.Value; } else { command.Parameters.Add("@actualAmt", MySqlDbType.Double).Value = DBNull.Value; } if (data.ClassType != null && data.ClassType.ClassTypeId > 0) { command.Parameters.Add("@ctId", MySqlDbType.Int32).Value = data.ClassType.ClassTypeId; } else { command.Parameters.Add("@ctId", MySqlDbType.Int32).Value = DBNull.Value; } if (!string.IsNullOrEmpty(data.RuleName)) { command.Parameters.Add("@ruleName", MySqlDbType.String).Value = data.RuleName; } else { command.Parameters.Add("@ruleName", MySqlDbType.String).Value = DBNull.Value; } if (!string.IsNullOrEmpty(data.PenaltyTransactionType)) { command.Parameters.Add("@penaltyTrType", MySqlDbType.String).Value = data.PenaltyTransactionType; } else { command.Parameters.Add("@penaltyTrType", MySqlDbType.String).Value = DBNull.Value; } if (data.PenaltyTransactionRule != null && data.PenaltyTransactionRule.TranRuleId > 0) { command.Parameters.Add("@penaltyTrRuleId", MySqlDbType.Int32).Value = data.PenaltyTransactionRule.TranRuleId; } else { command.Parameters.Add("@penaltyTrRuleId", MySqlDbType.Int32).Value = DBNull.Value; } if (command.ExecuteNonQuery() > 0) { status.IsSuccess = true; status.IsException = false; status.ReturnObj = data; } return(status); } catch (Exception exp) { _logger.Log(exp); throw exp; } } }
public StatusDTO <List <UserMasterDTO> > Select(UserMasterDTO data) { StatusDTO <List <UserMasterDTO> > userList = new StatusDTO <List <UserMasterDTO> >(); string whereClause = null; string selectClause = null; DataSet dsUserLst = null; using (IDbSvc dbSvc = new DbSvc(_configSvc)) { try { dbSvc.OpenConnection(); //openning the connection MySqlCommand command = new MySqlCommand(); // creating my sql command for queries command.Connection = dbSvc.GetConnection() as MySqlConnection; selectClause = "SELECT users.UserMasterId,users.FName,users.MName,users.LName,users.Gender,users.EmailId,users.ResidentialAddress,users.PermanentAddress," + "users.ContactNo,users.AltContactNo,users.BloodGroup,r.RoleDescription" + " FROM usermaster users" + " INNER JOIN roles r ON users.RoleId = r.RoleId AND users.RoleId>1"; whereClause = " WHERE users.Active = 1"; if (data != null) { //Name Search if (!string.IsNullOrEmpty(data.FName)) { data.FName = data.FName + "%"; whereClause = whereClause + " AND users.FName LIKE @FName"; command.Parameters.Add("@FName", MySqlDbType.String).Value = data.FName; } if (!string.IsNullOrEmpty(data.MName)) { data.MName = data.MName + "%"; whereClause = whereClause + " AND users.MName LIKE @MName "; command.Parameters.Add("@MName", MySqlDbType.String).Value = data.MName; } if (!string.IsNullOrEmpty(data.LName)) { data.LName = data.LName + "%"; whereClause = whereClause + " AND users.LName LIKE @LName "; command.Parameters.Add("@LName", MySqlDbType.String).Value = data.LName; } //Gender Search if (!string.IsNullOrEmpty(data.Gender) && !string.Equals(data.Gender, "-1")) { whereClause = whereClause + " AND users.Gender=@Gender "; command.Parameters.Add("@Gender", MySqlDbType.String).Value = data.Gender; } // Role Search if (!string.IsNullOrEmpty(data.Role.RoleDescription)) { whereClause = whereClause + " AND r.RoleDescription=@RoleDescription"; command.Parameters.Add("@RoleDescription", MySqlDbType.String).Value = data.Role.RoleDescription; } //BloodGroup Search if (!string.IsNullOrEmpty(data.BloodGroup)) { whereClause = whereClause + " AND users.BloodGroup=@BloodGroup"; command.Parameters.Add("@BloodGroup", MySqlDbType.String).Value = data.BloodGroup; } } command.CommandText = selectClause + whereClause; MySqlDataAdapter da = new MySqlDataAdapter(command); dsUserLst = new DataSet(); da.Fill(dsUserLst); if (dsUserLst != null && dsUserLst.Tables.Count > 0) { userList.ReturnObj = new List <UserMasterDTO>(); for (int i = 0; i < dsUserLst.Tables[0].Rows.Count; i++) { UserMasterDTO user = new UserMasterDTO(); user.UserMasterId = Convert.ToInt32(dsUserLst.Tables[0].Rows[i]["UserMasterId"]); user.FName = dsUserLst.Tables[0].Rows[i]["FName"].ToString(); user.MName = dsUserLst.Tables[0].Rows[i]["MName"].ToString(); user.LName = dsUserLst.Tables[0].Rows[i]["LName"].ToString(); user.Gender = dsUserLst.Tables[0].Rows[i]["Gender"].ToString(); user.EmailId = dsUserLst.Tables[0].Rows[i]["EmailId"].ToString(); user.ResidentialAddress = dsUserLst.Tables[0].Rows[i]["ResidentialAddress"].ToString(); user.PermanentAddress = dsUserLst.Tables[0].Rows[i]["PermanentAddress"].ToString(); user.ContactNo = dsUserLst.Tables[0].Rows[i]["ContactNo"].ToString(); user.AltContactNo = dsUserLst.Tables[0].Rows[i]["AltContactNo"].ToString(); user.BloodGroup = dsUserLst.Tables[0].Rows[i]["BloodGroup"].ToString(); user.Role = new RoleDTO(); user.Role.RoleDescription = dsUserLst.Tables[0].Rows[i]["RoleDescription"].ToString(); userList.ReturnObj.Add(user); userList.IsSuccess = true; } } } catch (Exception ex) { _logger.Log(ex); userList.IsSuccess = false; userList.IsException = true; userList.ReturnObj = null; userList.ExceptionMessage = ex.Message; userList.StackTrace = ex.StackTrace; } } return(userList); }