Exemplo n.º 1
0
        public List <ProofOfPayment> GetAllProofOfPayment()
        {
            //...Create New Instance of Object...
            List <ProofOfPayment> list = new List <ProofOfPayment>();
            ProofOfPayment        ins;

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection      con    = dbConn.SqlConn();
            SqlCommand         cmdI;

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT pop.*,c.CashType FROM t_ProofOfPayment pop inner join l_CashType c on pop.CashTypeID = c.CashTypeID WHERE pop.Removed = 0", con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins = new ProofOfPayment();
                    ins.ProofOfPaymentID   = Convert.ToInt32(drI["ProofOfPaymentID"]);
                    ins.ActualDate         = Convert.ToDateTime(drI["ActualDate"]);
                    ins.PaymentDescription = Convert.ToString(drI["PaymentDescription"]);
                    ins.CreatedDate        = Convert.ToDateTime(drI["CreatedDate"]);
                    ins.Amount             = Convert.ToInt32(drI["Amount"]);
                    ins.CompanyID          = Convert.ToInt32(drI["CompanyID"]);
                    ins.ModifiedDate       = Convert.ToDateTime(drI["ModifiedDate"]);
                    ins.ModifiedBy         = Convert.ToString(drI["ModifiedBy"]);
                    ins.Removed            = Convert.ToBoolean(drI["Removed"]);
                    ins.InvoiceNumber      = drI["InvoiceNumber"].ToString();
                    ins.CashTypeID         = Convert.ToInt32(drI["CashTypeID"]);
                    ins.cashtype           = drI["CashType"].ToString();
                    list.Add(ins);
                }
            }

            //...Close Connections...
            drI.Close();
            con.Close();


            //...Return...
            return(list);
        }
        public List<ProofOfPayment> GetAllProofOfPayment()
        {
            //...Create New Instance of Object...
            List<ProofOfPayment> list = new List<ProofOfPayment>();
            ProofOfPayment ins;

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            SqlCommand cmdI;

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT pop.*,c.CashType FROM t_ProofOfPayment pop inner join l_CashType c on pop.CashTypeID = c.CashTypeID WHERE pop.Removed = 0", con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins = new ProofOfPayment();
                    ins.ProofOfPaymentID = Convert.ToInt32(drI["ProofOfPaymentID"]);
                    ins.ActualDate = Convert.ToDateTime(drI["ActualDate"]);
                    ins.PaymentDescription = Convert.ToString(drI["PaymentDescription"]);
                    ins.CreatedDate = Convert.ToDateTime(drI["CreatedDate"]);
                    ins.Amount = Convert.ToInt32(drI["Amount"]);
                    ins.CompanyID = Convert.ToInt32(drI["CompanyID"]);
                    ins.ModifiedDate = Convert.ToDateTime(drI["ModifiedDate"]);
                    ins.ModifiedBy = Convert.ToString(drI["ModifiedBy"]);
                    ins.Removed = Convert.ToBoolean(drI["Removed"]);
                    ins.InvoiceNumber = drI["InvoiceNumber"].ToString();
                    ins.CashTypeID = Convert.ToInt32(drI["CashTypeID"]);
                    ins.cashtype = drI["CashType"].ToString();
                    list.Add(ins);
                }
            }

            //...Close Connections...
            drI.Close();
            con.Close();

            //...Return...
            return list;
        }
Exemplo n.º 3
0
        public ProofOfPayment GetProofOfPayment(int ProofOfPaymentID)
        {
            //...Create New Instance of Object...
            ProofOfPayment ins = new ProofOfPayment();

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection      con    = dbConn.SqlConn();
            SqlCommand         cmdI;

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT * FROM t_ProofOfPayment WHERE ProofOfPaymentID =" + ProofOfPaymentID, con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins.ProofOfPaymentID   = Convert.ToInt32(drI["ProofOfPaymentID"]);
                    ins.ActualDate         = Convert.ToDateTime(drI["ActualDate"]);
                    ins.PaymentDescription = Convert.ToString(drI["PaymentDescription"]);
                    ins.CreatedDate        = Convert.ToDateTime(drI["CreatedDate"]);
                    ins.Amount             = Convert.ToInt32(drI["Amount"]);
                    ins.CompanyID          = Convert.ToInt32(drI["CompanyID"]);
                    ins.ModifiedDate       = Convert.ToDateTime(drI["ModifiedDate"]);
                    ins.ModifiedBy         = Convert.ToString(drI["ModifiedBy"]);
                    ins.Removed            = Convert.ToBoolean(drI["Removed"]);
                    ins.InvoiceNumber      = drI["InvoiceNumber"].ToString();
                    ins.CashTypeID         = Convert.ToInt32(drI["CashTypeID"]);
                }
            }

            //...Close Connections...
            drI.Close();
            con.Close();


            //...Return...
            return(ins);
        }
        public ProofOfPayment GetProofOfPayment(int ProofOfPaymentID)
        {
            //...Create New Instance of Object...
            ProofOfPayment ins = new ProofOfPayment();

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            SqlCommand cmdI;

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT * FROM t_ProofOfPayment WHERE ProofOfPaymentID =" + ProofOfPaymentID, con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins.ProofOfPaymentID = Convert.ToInt32(drI["ProofOfPaymentID"]);
                    ins.ActualDate = Convert.ToDateTime(drI["ActualDate"]);
                    ins.PaymentDescription = Convert.ToString(drI["PaymentDescription"]);
                    ins.CreatedDate = Convert.ToDateTime(drI["CreatedDate"]);
                    ins.Amount = Convert.ToInt32(drI["Amount"]);
                    ins.CompanyID = Convert.ToInt32(drI["CompanyID"]);
                    ins.ModifiedDate = Convert.ToDateTime(drI["ModifiedDate"]);
                    ins.ModifiedBy = Convert.ToString(drI["ModifiedBy"]);
                    ins.Removed = Convert.ToBoolean(drI["Removed"]);
                    ins.InvoiceNumber = drI["InvoiceNumber"].ToString();
                    ins.CashTypeID = Convert.ToInt32(drI["CashTypeID"]);
                }
            }

            //...Close Connections...
            drI.Close();
            con.Close();

            //...Return...
            return ins;
        }
        public JsonResult _Insert(ProofOfPayment ins)
        {
            if(ins.InvoiceNumber != null)
            {
                //...Remove Supplier from Invoice Number
                List<string> suppliers = DDRep.GetSupplierNameList();
                SupplierInvoiceSplit split = POPRep.RemoveSupplierFormInvoiceNumber(ins.InvoiceNumber, suppliers);
                ins.InvoiceNumber = split.InvoiceNumber;
                ins.SupplierID = split.SupplierId.ToString();
            }
            else
            {
                ins.InvoiceNumber = SupRep.GetSupplier(Convert.ToInt32(ins.SupplierID)).Suppliers + " Payment";
            }

            //...Insert Object
            ProofOfPayment ins2 = POPRep.Insert(ins);

            //...Repopulate Grid...
            return Json(new GridModel(POPRep.GetAllProofOfPayment()));
        }
Exemplo n.º 6
0
        public ProofOfPayment Update(ProofOfPayment ins)
        {
            //...Get User and Date Data...
            string ModifiedDate = string.Format("{0:yyyy-MM-dd hh:mm:ss}", DateTime.Now);
            string EmployeeId   = Convert.ToString(HttpContext.Current.Session["Username"]);

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection      con    = dbConn.SqlConn();

            con.Open();
            SqlCommand cmdI = con.CreateCommand();

            cmdI.Connection = con;

            //...Update Record...
            cmdI.Parameters.Clear();
            cmdI.CommandText = StoredProcedures.ProofOfPaymentUpdate;
            cmdI.CommandType = System.Data.CommandType.StoredProcedure;
            cmdI.Parameters.AddWithValue("@ProofOfPaymentID", ins.ProofOfPaymentID);
            cmdI.Parameters.AddWithValue("@ActualDate", ins.ActualDate);
            cmdI.Parameters.AddWithValue("@PaymentDescription", ins.PaymentDescription);
            cmdI.Parameters.AddWithValue("@CreatedDate", DateTime.Now);
            cmdI.Parameters.AddWithValue("@Amount", ins.Amount);
            cmdI.Parameters.AddWithValue("@CompanyID", ins.CompanyID);
            cmdI.Parameters.AddWithValue("@ModifiedDate", ModifiedDate);
            cmdI.Parameters.AddWithValue("@ModifiedBy", EmployeeId);
            cmdI.Parameters.AddWithValue("@InvoiceNumber", ins.InvoiceNumber);
            cmdI.Parameters.AddWithValue("@CashTypeID", ins.CashTypeID);
            cmdI.Parameters.AddWithValue("@SupplierId", ins.SupplierID);

            cmdI.ExecuteNonQuery();
            cmdI.Connection.Close();

            return(ins);
        }
        public ProofOfPayment Update(ProofOfPayment ins)
        {
            //...Get User and Date Data...
            string ModifiedDate = string.Format("{0:yyyy-MM-dd hh:mm:ss}", DateTime.Now);
             string EmployeeId = Convert.ToString(HttpContext.Current.Session["Username"]);

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            con.Open();
            SqlCommand cmdI = con.CreateCommand();
            cmdI.Connection = con;

            //...Update Record...
            cmdI.Parameters.Clear();
            cmdI.CommandText = StoredProcedures.ProofOfPaymentUpdate;
            cmdI.CommandType = System.Data.CommandType.StoredProcedure;
            cmdI.Parameters.AddWithValue("@ProofOfPaymentID", ins.ProofOfPaymentID);
            cmdI.Parameters.AddWithValue("@ActualDate", ins.ActualDate);
            cmdI.Parameters.AddWithValue("@PaymentDescription", ins.PaymentDescription);
            cmdI.Parameters.AddWithValue("@CreatedDate", DateTime.Now);
            cmdI.Parameters.AddWithValue("@Amount", ins.Amount);
            cmdI.Parameters.AddWithValue("@CompanyID", ins.CompanyID);
            cmdI.Parameters.AddWithValue("@ModifiedDate",ModifiedDate);
            cmdI.Parameters.AddWithValue("@ModifiedBy",EmployeeId);
            cmdI.Parameters.AddWithValue("@InvoiceNumber", ins.InvoiceNumber);
            cmdI.Parameters.AddWithValue("@CashTypeID", ins.CashTypeID);
            cmdI.Parameters.AddWithValue("@SupplierId", ins.SupplierID);

            cmdI.ExecuteNonQuery();
            cmdI.Connection.Close();

            return ins;
        }
        public ProofOfPayment Insert(ProofOfPayment ins)
        {
            //...Get User and Date Data...
            string ModifiedDate = string.Format("{0:yyyy-MM-dd hh:mm:ss}", DateTime.Now);
             string EmployeeId = Convert.ToString(HttpContext.Current.Session["Username"]);
            string strTrx = "ProofOfPaymentIns_" + EmployeeId;

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            con.Open();

            //...Command Interface...
            SqlCommand cmdI = con.CreateCommand();
            SqlTransaction trx;
            trx = con.BeginTransaction(strTrx);
            cmdI.Connection = con;
            cmdI.Transaction = trx;

            try
            {
                //...Insert Record...
                cmdI.CommandText = StoredProcedures.ProofOfPaymentInsert;
                cmdI.CommandType = System.Data.CommandType.StoredProcedure;
                //cmdI.Parameters.AddWithValue("@ProofOfPaymentID", ins.ProofOfPaymentID);
                cmdI.Parameters.AddWithValue("@ActualDate", ins.ActualDate);
                cmdI.Parameters.AddWithValue("@PaymentDescription", ins.PaymentDescription);
                cmdI.Parameters.AddWithValue("@CreatedDate", DateTime.Now);
                cmdI.Parameters.AddWithValue("@Amount", ins.Amount);
                cmdI.Parameters.AddWithValue("@CompanyID", ins.CompanyID);
                cmdI.Parameters.AddWithValue("@ModifiedDate",ModifiedDate);
                cmdI.Parameters.AddWithValue("@ModifiedBy",EmployeeId);
                cmdI.Parameters.AddWithValue("@Removed", ins.Removed);
                cmdI.Parameters.AddWithValue("@InvoiceNumber", ins.InvoiceNumber);
                cmdI.Parameters.AddWithValue("@CashTypeID", ins.CashTypeID);
                cmdI.Parameters.AddWithValue("@SupplierId", ins.SupplierID);

                //...Return new ID
                ins.ProofOfPaymentID = (int)cmdI.ExecuteScalar();

                trx.Commit();
                cmdI.Connection.Close();
            }
            catch (SqlException ex)
            {
                if (trx != null) trx.Rollback();
            }
            finally
            {
                //Check for close and respond accordingly
                if (con.State != ConnectionState.Closed)
                {
                    con.Close();
                }
                //Clean up
                con.Dispose();
                cmdI.Dispose();
                trx.Dispose();
            }
            return ins;
        }
Exemplo n.º 9
0
        public ProofOfPayment Insert(ProofOfPayment ins)
        {
            //...Get User and Date Data...
            string ModifiedDate = string.Format("{0:yyyy-MM-dd hh:mm:ss}", DateTime.Now);
            string EmployeeId   = Convert.ToString(HttpContext.Current.Session["Username"]);
            string strTrx       = "ProofOfPaymentIns_" + EmployeeId;

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection      con    = dbConn.SqlConn();

            con.Open();

            //...Command Interface...
            SqlCommand     cmdI = con.CreateCommand();
            SqlTransaction trx;

            trx              = con.BeginTransaction(strTrx);
            cmdI.Connection  = con;
            cmdI.Transaction = trx;

            try
            {
                //...Insert Record...
                cmdI.CommandText = StoredProcedures.ProofOfPaymentInsert;
                cmdI.CommandType = System.Data.CommandType.StoredProcedure;
                //cmdI.Parameters.AddWithValue("@ProofOfPaymentID", ins.ProofOfPaymentID);
                cmdI.Parameters.AddWithValue("@ActualDate", ins.ActualDate);
                cmdI.Parameters.AddWithValue("@PaymentDescription", ins.PaymentDescription);
                cmdI.Parameters.AddWithValue("@CreatedDate", DateTime.Now);
                cmdI.Parameters.AddWithValue("@Amount", ins.Amount);
                cmdI.Parameters.AddWithValue("@CompanyID", ins.CompanyID);
                cmdI.Parameters.AddWithValue("@ModifiedDate", ModifiedDate);
                cmdI.Parameters.AddWithValue("@ModifiedBy", EmployeeId);
                cmdI.Parameters.AddWithValue("@Removed", ins.Removed);
                cmdI.Parameters.AddWithValue("@InvoiceNumber", ins.InvoiceNumber);
                cmdI.Parameters.AddWithValue("@CashTypeID", ins.CashTypeID);
                cmdI.Parameters.AddWithValue("@SupplierId", ins.SupplierID);

                //...Return new ID
                ins.ProofOfPaymentID = (int)cmdI.ExecuteScalar();

                trx.Commit();
                cmdI.Connection.Close();
            }
            catch (SqlException ex)
            {
                if (trx != null)
                {
                    trx.Rollback();
                }
            }
            finally
            {
                //Check for close and respond accordingly
                if (con.State != ConnectionState.Closed)
                {
                    con.Close();
                }
                //Clean up
                con.Dispose();
                cmdI.Dispose();
                trx.Dispose();
            }
            return(ins);
        }