/// <summary> /// Method to Delete Cheques /// </summary> /// <param name="argEn">Cheques Entity is the Input.ProcessID is the Input Property.</param> /// <returns>Returns Boolean.</returns> public bool Delete(ChequeEn argEn) { bool lbRes = false; string sqlCmd = "DELETE FROM SAS_Cheque WHERE ProcessID = @ProcessID"; try { if (!FormHelp.IsBlank(sqlCmd)) { DbCommand cmdSel = _DatabaseFactory.GetDbCommand(Helper.GetDataBaseType, sqlCmd, DataBaseConnectionString); _DatabaseFactory.AddInParameter(ref cmdSel, "@ProcessID", DbType.String, argEn.ProcessID); _DbParameterCollection = cmdSel.Parameters; int liRowAffected = _DatabaseFactory.ExecuteNonQuery(Helper.GetDataBaseType, cmdSel, DataBaseConnectionString, sqlCmd, _DbParameterCollection); if (liRowAffected > -1) { lbRes = true; } else { throw new Exception("Insertion Failed! No Row has been updated..."); } } } catch (Exception ex) { throw ex; } return(lbRes); }
/// <summary> /// Method to Get Cheque Item /// </summary> /// <param name="argEn">Cheques Entity is an Input.ProcessID is Input Property.</param> /// <returns>Returns a Cheque Item</returns> public ChequeEn GetItem(ChequeEn argEn) { ChequeEn loItem = new ChequeEn(); string sqlCmd = "Select * FROM SAS_Cheque WHERE ProcessID = @ProcessID"; try { if (!FormHelp.IsBlank(sqlCmd)) { DbCommand cmd = _DatabaseFactory.GetDbCommand(Helper.GetDataBaseType, sqlCmd, DataBaseConnectionString); _DatabaseFactory.AddInParameter(ref cmd, "@ProcessID", DbType.String, argEn.ProcessID); _DbParameterCollection = cmd.Parameters; using (IDataReader loReader = _DatabaseFactory.GetIDataReader(Helper.GetDataBaseType, cmd, DataBaseConnectionString, sqlCmd, _DbParameterCollection).CreateDataReader()) { if (loReader != null) { loReader.Read(); loItem = LoadObject(loReader); } loReader.Close(); } } } catch (Exception ex) { throw ex; } return(loItem); }
/// <summary> /// Method to Get Cheque Item /// </summary> /// <param name="argEn">Cheques Entity is an Input.ProcessID is Input Property.</param> /// <returns>Returns a Cheque Item</returns> public ChequeEn GetItem(ChequeEn argEn) { try { ChequeDAL loDs = new ChequeDAL(); return(loDs.GetItem(argEn)); } catch (Exception ex) { throw ex; } }
/// <summary> /// Method to Get refund Cheques /// </summary> /// <param name="argEn">Cheques Entity is an Input.ProcessID is Input Property.</param> /// <returns>Returns List of Cheques</returns> public List <ChequeEn> GetRefundList(ChequeEn argEn) { try { ChequeDAL loDs = new ChequeDAL(); return(loDs.GetRefundList(argEn)); } catch (Exception ex) { throw ex; } }
/// <summary> /// Method to Validate Cheque Fields /// </summary> /// <param name="argEn">Cheques Entity is an Input</param> /// <returns>Returns a Boolean</returns> public bool IsValid(ChequeEn argEn) { try { if (argEn.ProcessID == null || argEn.ProcessID.ToString().Length <= 0) { throw new Exception("ProcessID Is Required!"); } return(true); } catch (Exception ex) { throw ex; } }
/// <summary> /// Method to Delete Cheques Batch /// </summary> /// <param name="argEn">Cheques Entity is the Input.ProcessID is the Input Property.</param> /// <returns>Returns a Boolean</returns> public bool BatchDelete(ChequeEn argEn) { bool lbRes = false; List <ChequeDetailsEn> loChDetails = new List <ChequeDetailsEn>(); string sqlCmd = "Select * from SAS_Cheque WHERE ProcessID = @ProcessID"; try { if (!FormHelp.IsBlank(sqlCmd)) { DbCommand cmdSel = _DatabaseFactory.GetDbCommand(Helper.GetDataBaseType, sqlCmd, DataBaseConnectionString); _DatabaseFactory.AddInParameter(ref cmdSel, "@ProcessID", DbType.String, argEn.ProcessID); _DbParameterCollection = cmdSel.Parameters; if (!FormHelp.IsBlank(sqlCmd)) { ChequeDetailsDAL loObjChequeDAL = new ChequeDetailsDAL(); ChequeDetailsEn loItem = null; using (IDataReader loReader = _DatabaseFactory.GetIDataReader(Helper.GetDataBaseType, cmdSel, DataBaseConnectionString, sqlCmd, _DbParameterCollection).CreateDataReader()) { loItem = new ChequeDetailsEn(); loItem.ProcessId = GetValue <string>(loReader, "ProcessID"); loChDetails.Add(loItem); loItem = null; loReader.Close(); } int i = 0; //deleting each item in batch for (i = 0; i < loChDetails.Count; i++) { loObjChequeDAL.Delete(loChDetails[i]); } } } } catch (Exception ex) { throw ex; } Delete(argEn); return(lbRes); }
/// <summary> /// Method to Load Cheques Entity /// </summary> /// <param name="argReader">Reader Object is an Input.</param> /// <returns>Returns Cheques Entity Object.</returns> private ChequeEn LoadObject(IDataReader argReader) { ChequeEn loItem = new ChequeEn(); loItem.ProcessID = GetValue <string>(argReader, "ProcessID"); loItem.PaymentNo = GetValue <string>(argReader, "PaymentNo"); loItem.PaymentType = GetValue <string>(argReader, "PaymentType"); loItem.Description = GetValue <string>(argReader, "Description"); loItem.ChequeDate = GetValue <DateTime>(argReader, "ChequeDate"); loItem.TransactionDate = GetValue <DateTime>(argReader, "TransactionDate"); loItem.PrintStatus = GetValue <string>(argReader, "PrintStatus"); loItem.UpdatedBy = GetValue <string>(argReader, "UpdatedBy"); loItem.UpdatedTime = GetValue <DateTime>(argReader, "UpdatedTime"); loItem.BankCode = GetValue <string>(argReader, "BankCode"); loItem.TransactionCode = GetValue <string>(argReader, "TransCode"); loItem.BatchCode = GetValue <string>(argReader, "BatchCode"); loItem.TranssactionID = GetValue <int>(argReader, "TransID"); return(loItem); }
/// <summary> /// Method to Insert Cheques /// </summary> /// <param name="argEn">Cheques Entity is the Input.</param> /// <returns>Returns a Boolean</returns> public string Insert(ChequeEn argEn) { String flag; using (TransactionScope ts = new TransactionScope()) { try { ChequeDAL loDs = new ChequeDAL(); flag = loDs.Insert(argEn); ts.Complete(); } catch (Exception ex) { throw ex; } } return(flag); }
/// <summary> /// Method to Delete Cheques /// </summary> /// <param name="argEn">Cheques Entity is the Input.ProcessID is the Input Property.</param> /// <returns>Returns Boolean.</returns> public bool Delete(ChequeEn argEn) { bool flag; using (TransactionScope ts = new TransactionScope()) { try { ChequeDAL loDs = new ChequeDAL(); flag = loDs.Delete(argEn); ts.Complete(); } catch (Exception ex) { throw ex; } } return(flag); }
/// <summary> /// Method to Update Cheques /// </summary> /// <param name="argEn">Cheques Entity is the Input.</param> /// <returns>Returns Boolean.</returns> public bool Update(ChequeEn argEn) { bool lbRes = false; try { string sqlCmd = "UPDATE SAS_Cheque SET ProcessID = @ProcessID, PaymentNo = @PaymentNo, PaymentType = @PaymentType, Description = @Description, ChequeDate = @ChequeDate, TransactionDate = @TransactionDate, PrintStatus = @PrintStatus, UpdatedBy = @UpdatedBy, UpdatedTime = @UpdatedTime WHERE ProcessID = @ProcessID"; if (!FormHelp.IsBlank(sqlCmd)) { DbCommand cmd = _DatabaseFactory.GetDbCommand(Helper.GetDataBaseType, sqlCmd, DataBaseConnectionString); _DatabaseFactory.AddInParameter(ref cmd, "@ProcessID", DbType.String, argEn.ProcessID); _DatabaseFactory.AddInParameter(ref cmd, "@PaymentNo", DbType.String, argEn.PaymentNo); _DatabaseFactory.AddInParameter(ref cmd, "@PaymentType", DbType.String, argEn.PaymentType); _DatabaseFactory.AddInParameter(ref cmd, "@Description", DbType.String, argEn.Description); _DatabaseFactory.AddInParameter(ref cmd, "@ChequeDate", DbType.DateTime, argEn.ChequeDate); _DatabaseFactory.AddInParameter(ref cmd, "@TransactionDate", DbType.DateTime, argEn.TransactionDate); _DatabaseFactory.AddInParameter(ref cmd, "@PrintStatus", DbType.String, argEn.PrintStatus); _DatabaseFactory.AddInParameter(ref cmd, "@UpdatedBy", DbType.String, argEn.UpdatedBy); _DatabaseFactory.AddInParameter(ref cmd, "@UpdatedTime", DbType.DateTime, argEn.UpdatedTime); _DbParameterCollection = cmd.Parameters; int liRowAffected = _DatabaseFactory.ExecuteNonQuery(Helper.GetDataBaseType, cmd, DataBaseConnectionString, sqlCmd, _DbParameterCollection); if (liRowAffected > -1) { lbRes = true; } else { throw new Exception("Update Failed! No Row has been updated..."); } } } catch (Exception ex) { throw ex; } return(lbRes); }
/// <summary> /// Method to Get refund Cheques /// </summary> /// <param name="argEn">Cheques Entity is an Input.ProcessID is Input Property.</param> /// <returns>Returns List of Cheques</returns> public List <ChequeEn> GetRefundList(ChequeEn argEn) { List <ChequeEn> loEnList = new List <ChequeEn>(); argEn.ProcessID = argEn.ProcessID.Replace("*", "%"); string sqlCmd = "SELECT SAS_Cheque.*, SAS_Accounts.TransCode, SAS_Cheque.PaymentNo, SAS_Accounts.BankCode,SAS_Accounts.transid,SAS_Accounts.BatchCode FROM SAS_Cheque INNER JOIN SAS_Accounts ON SAS_Cheque.PaymentNo = SAS_Accounts.BatchCode where SAS_Cheque.PaymentType = '" + argEn.PaymentType + "' and SAS_Cheque.PrintStatus = '" + argEn.PrintStatus + "'"; if (argEn.ProcessID.Length != 0) { sqlCmd = sqlCmd + " AND ProcessID LIKE '" + argEn.ProcessID + "'"; } try { if (!FormHelp.IsBlank(sqlCmd)) { using (IDataReader loReader = _DatabaseFactory.ExecuteReader(Helper.GetDataBaseType, DataBaseConnectionString, sqlCmd).CreateDataReader()) { while (loReader.Read()) { ChequeDetailsDAL dscheDetials = new ChequeDetailsDAL(); ChequeDetailsEn locheDetials = new ChequeDetailsEn(); ChequeEn loItem = LoadObject(loReader); locheDetials.ProcessId = loItem.ProcessID; loItem.ChequeDetailslist = dscheDetials.GetList(locheDetials); loEnList.Add(loItem); } loReader.Close(); } } } catch (Exception ex) { throw ex; } return(loEnList); }
/// <summary> /// Method to Insert Cheques /// </summary> /// <param name="argEn">Cheques Entity is the Input.</param> /// <returns>Returns a Boolean</returns> public string Insert(ChequeEn argEn) { bool lbRes = false; int iOut = 0; string batchcode = ""; string sqlCmd = "Select count(*) as cnt From SAS_Cheque WHERE PaymentNo = @PaymentNo and printstatus = 'Ready'"; try { if (!FormHelp.IsBlank(sqlCmd)) { DbCommand cmdsel = _DatabaseFactory.GetDbCommand(Helper.GetDataBaseType, sqlCmd, DataBaseConnectionString); _DatabaseFactory.AddInParameter(ref cmdsel, "@PaymentNo", DbType.String, argEn.PaymentNo); _DbParameterCollection = cmdsel.Parameters; using (IDataReader dr = _DatabaseFactory.GetIDataReader(Helper.GetDataBaseType, cmdsel, DataBaseConnectionString, sqlCmd, _DbParameterCollection).CreateDataReader()) { if (dr.Read()) { iOut = clsGeneric.NullToInteger(dr["cnt"]); } if (iOut > 0) { throw new Exception("Record Already Exist"); } } if (iOut == 0) { if (argEn.ProcessID == "") { argEn.ProcessID = GetAutoNumber("TCQ"); } if (argEn.PrintStatus == "Posted") { argEn.ProcessID = GetAutoNumber("CQ"); } batchcode = argEn.ProcessID; string sqlCmd1 = "INSERT INTO SAS_Cheque(ProcessID,PaymentNo,PaymentType,Description,ChequeDate,TransactionDate,PrintStatus,UpdatedBy,UpdatedTime) VALUES (@ProcessID,@PaymentNo,@PaymentType,@Description,@ChequeDate,@TransactionDate,@PrintStatus,@UpdatedBy,@UpdatedTime)"; if (!FormHelp.IsBlank(sqlCmd1)) { DbCommand cmd = _DatabaseFactory.GetDbCommand(Helper.GetDataBaseType, sqlCmd, DataBaseConnectionString); _DatabaseFactory.AddInParameter(ref cmd, "@ProcessID", DbType.String, argEn.ProcessID); _DatabaseFactory.AddInParameter(ref cmd, "@PaymentNo", DbType.String, argEn.PaymentNo); _DatabaseFactory.AddInParameter(ref cmd, "@PaymentType", DbType.String, argEn.PaymentType); _DatabaseFactory.AddInParameter(ref cmd, "@Description", DbType.String, argEn.Description); _DatabaseFactory.AddInParameter(ref cmd, "@ChequeDate", DbType.DateTime, argEn.ChequeDate); _DatabaseFactory.AddInParameter(ref cmd, "@TransactionDate", DbType.DateTime, argEn.TransactionDate); _DatabaseFactory.AddInParameter(ref cmd, "@PrintStatus", DbType.String, argEn.PrintStatus); _DatabaseFactory.AddInParameter(ref cmd, "@UpdatedBy", DbType.String, argEn.UpdatedBy); _DatabaseFactory.AddInParameter(ref cmd, "@UpdatedTime", DbType.DateTime, argEn.UpdatedTime); _DbParameterCollection = cmd.Parameters; int liRowAffected = _DatabaseFactory.ExecuteNonQuery(Helper.GetDataBaseType, cmd, DataBaseConnectionString, sqlCmd, _DbParameterCollection); if (liRowAffected > -1) { lbRes = true; } else { throw new Exception("Update Failed! No Row has been updated..."); } //Inserting AccountDetails Table if (argEn.ChequeDetailslist != null) { if (argEn.ChequeDetailslist.Count != 0) { ChequeDetailsDAL loDS = new ChequeDetailsDAL(); for (int i = 0; i < argEn.ChequeDetailslist.Count; i++) { argEn.ChequeDetailslist[i].ProcessId = batchcode; loDS.Insert(argEn.ChequeDetailslist[i]); } } } if (argEn.PaymentType == "Payment") { //updating allocations UpdatePayments(argEn.AcccountChques); } if (argEn.PaymentType == "Refund") { // updating Refunds UpdatePayments(argEn.AcccountChques); } if (argEn.PaymentType == "Sponsor Payments") { // updating Sponsor Payments UpdatePayments(argEn.AcccountChques); } } } } } catch (Exception ex) { throw ex; } return(batchcode); }