Ejemplo n.º 1
0
        /// <summary>
        /// Method to Get ChequeDetails Item
        /// </summary>
        /// <param name="argEn">ChequeDetails Entity is an Input.</param>
        /// <returns>Returns a ChequeDetails Item</returns>
        public ChequeDetailsEn GetItem(ChequeDetailsEn argEn)
        {
            ChequeDetailsEn loItem = new ChequeDetailsEn();
            string          sqlCmd = "Select * FROM SAS_ChequeDetails ";

            try
            {
                if (!FormHelp.IsBlank(sqlCmd))
                {
                    using (IDataReader loReader = _DatabaseFactory.ExecuteReader(Helper.GetDataBaseType,
                                                                                 DataBaseConnectionString, sqlCmd).CreateDataReader())
                    {
                        if (loReader != null)
                        {
                            loReader.Read();
                            loItem = LoadObject(loReader);
                        }
                        loReader.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(loItem);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Method to Insert ChequeDetails
/// </summary>
        /// <param name="argEn">ChequeDetails Entity is the Input.</param>
        /// <returns>Returns a Boolean</returns>
        public bool Insert(ChequeDetailsEn argEn)
        {
            bool lbRes = false;

            try
            {
                string sqlCmd = "INSERT INTO SAS_ChequeDetails(ProcessId,ChequeStartNo,ChequeEndNo) VALUES (@ProcessId,@ChequeStartNo,@ChequeEndNo) ";

                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, "@ChequeStartNo", DbType.String, argEn.ChequeStartNo);
                    _DatabaseFactory.AddInParameter(ref cmd, "@ChequeEndNo", DbType.String, argEn.ChequeEndNo);
                    _DbParameterCollection = cmd.Parameters;

                    int liRowAffected = _DatabaseFactory.ExecuteNonQuery(Helper.GetDataBaseType, cmd,
                                                                         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);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Method to Get ChequeDetails
        /// </summary>
        /// <param name="argEn">ChequeDetails Entity is an Input.ProcessID is Input Property.</param>
        /// <returns>Returns List of ChequeDetails</returns>
        public List <ChequeDetailsEn> GetList(ChequeDetailsEn argEn)
        {
            List <ChequeDetailsEn> loEnList = new List <ChequeDetailsEn>();
            string sqlCmd = "select * from SAS_ChequeDetails where processid = '" + argEn.ProcessId + "'";

            try
            {
                if (!FormHelp.IsBlank(sqlCmd))
                {
                    using (IDataReader loReader = _DatabaseFactory.ExecuteReader(Helper.GetDataBaseType,
                                                                                 DataBaseConnectionString, sqlCmd).CreateDataReader())
                    {
                        while (loReader.Read())
                        {
                            ChequeDetailsEn loItem = LoadObject(loReader);
                            loEnList.Add(loItem);
                        }
                        loReader.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(loEnList);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Method to Delete  ChequeDetails
/// </summary>
        /// <param name="argEn">ChequeDetails Entity is an Input.ProceddID is Property.</param>
        /// <returns>Returns a Boolean</returns>
        public bool Delete(ChequeDetailsEn argEn)
        {
            bool   lbRes  = false;
            string sqlCmd = "DELETE FROM SAS_ChequeDetails 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;

                    int liRowAffected = _DatabaseFactory.ExecuteNonQuery(Helper.GetDataBaseType, cmd,
                                                                         DataBaseConnectionString, sqlCmd, _DbParameterCollection);

                    if (liRowAffected > -1)
                    {
                        lbRes = true;
                    }
                    else
                    {
                        throw new Exception("Deletion Failed! No Row has been deleted...");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(lbRes);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Method to Load ChequeDetails Entity
/// </summary>
        /// <param name="argReader">Reader Object is an Input.</param>
        /// <returns>Returns Cheques Entity Object.</returns>
        private ChequeDetailsEn LoadObject(IDataReader argReader)
        {
            ChequeDetailsEn loItem = new ChequeDetailsEn();

            loItem.ProcessId     = GetValue <string>(argReader, "ProcessId");
            loItem.ChequeStartNo = GetValue <string>(argReader, "ChequeStartNo");
            loItem.ChequeEndNo   = GetValue <string>(argReader, "ChequeEndNo");

            return(loItem);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Method to Update ChequeDetails
/// </summary>
        /// <param name="argEn">ChequeDetails Entity is the Input.</param>
        /// <returns>Returns a Boolean</returns>
        public bool Update(ChequeDetailsEn argEn)
        {
            bool   lbRes  = false;
            int    iOut   = 0;
            string sqlCmd = "Select count(*) as cnt From SAS_ChequeDetails WHERE ";

            try
            {
                if (!FormHelp.IsBlank(sqlCmd))
                {
                    using (IDataReader dr = _DatabaseFactory.ExecuteReader(Helper.GetDataBaseType,
                                                                           DataBaseConnectionString, sqlCmd).CreateDataReader())
                    {
                        if (dr.Read())
                        {
                            iOut = clsGeneric.NullToInteger(dr["cnt"]);
                        }
                        if (iOut < 0)
                        {
                            throw new Exception("Update Failed! No Record Exist!");
                        }
                    }
                    if (iOut != 0)
                    {
                        sqlCmd = "UPDATE SAS_ChequeDetails SET ProcessId = @ProcessId, ChequeStartNo = @ChequeStartNo, ChequeEndNo = @ChequeEndNo WHERE ";

                        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, "@ChequeStartNo", DbType.String, argEn.ChequeStartNo);
                            _DatabaseFactory.AddInParameter(ref cmd, "@ChequeEndNo", DbType.String, argEn.ChequeEndNo);
                            _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);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Method to Get ChequeDetails Item
        /// </summary>
        /// <param name="argEn">ChequeDetails Entity is an Input.</param>
        /// <returns>Returns a ChequeDetails Item</returns>

        public ChequeDetailsEn GetItem(ChequeDetailsEn argEn)
        {
            try
            {
                ChequeDetailsDAL loDs = new ChequeDetailsDAL();
                return(loDs.GetItem(argEn));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Method to Get ChequeDetails
 /// </summary>
 /// <param name="argEn">ChequeDetails Entity is an Input.ProcessID is Input Property.</param>
 /// <returns>Returns List of ChequeDetails</returns>
 public List <ChequeDetailsEn> GetList(ChequeDetailsEn argEn)
 {
     try
     {
         ChequeDetailsDAL loDs = new ChequeDetailsDAL();
         return(loDs.GetList(argEn));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Method to Validate ChequeDetails Fields
        /// </summary>
        /// <param name="argEn">ChequeDetails Entity is an Input</param>
        /// <returns>Returns a Boolean</returns>

        public bool IsValid(ChequeDetailsEn argEn)
        {
            try
            {
                if (argEn.ProcessId == null || argEn.ProcessId.ToString().Length <= 0)
                {
                    throw new Exception("ProcessId Is Required!");
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 10
0
        /// <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);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Method to Update ChequeDetails
        /// </summary>
        /// <param name="argEn">ChequeDetails Entity is the Input.</param>
        /// <returns>Returns a Boolean</returns>
        public bool Update(ChequeDetailsEn argEn)
        {
            bool flag;

            using (TransactionScope ts = new TransactionScope())
            {
                try
                {
                    ChequeDetailsDAL loDs = new ChequeDetailsDAL();
                    flag = loDs.Update(argEn);
                    ts.Complete();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return(flag);
        }
Ejemplo n.º 12
0
        /// <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);
        }