コード例 #1
0
        public List <CoinMovement> GetAllCoinMovement()
        {
            //...Create New Instance of Object...
            List <CoinMovement> list = new List <CoinMovement>();
            CoinMovement        ins;

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

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT cm.*, ct.CoinMovementType, m.MoneyUnit FROM t_CoinMovement cm inner join l_CoinMovementType ct on cm.MovementTypeId = ct.CoinMovementTypeId inner join l_MoneyUnit m on cm.MoneyUnitID = m.MoneyUnitID where cm.Removed=0", con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins = new CoinMovement();
                    ins.CoinMovementID = Convert.ToInt32(drI["CoinMovementID"]);
                    ins.ActualDate     = Convert.ToDateTime(drI["ActualDate"]);
                    ins.ModifiedDate   = Convert.ToDateTime(drI["ModifiedDate"]);
                    ins.Amount         = Convert.ToDecimal(drI["Amount"]);
                    ins.MovementTypeID = Convert.ToInt32(drI["MovementTypeID"]);
                    ins.MoneyUnitID    = Convert.ToInt32(drI["MoneyUnitID"]);
                    ins.UserID         = Convert.ToString(drI["UserID"]);
                    ins.moneyunit      = drI["MoneyUnit"].ToString();
                    ins.movementtype   = drI["CoinMovementType"].ToString();
                    list.Add(ins);
                }
            }

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


            //...Return...
            return(list);
        }
コード例 #2
0
        public List<CoinMovement> GetAllCoinMovement()
        {
            //...Create New Instance of Object...
            List<CoinMovement> list = new List<CoinMovement>();
            CoinMovement ins;

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

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT cm.*, ct.CoinMovementType, m.MoneyUnit FROM t_CoinMovement cm inner join l_CoinMovementType ct on cm.MovementTypeId = ct.CoinMovementTypeId inner join l_MoneyUnit m on cm.MoneyUnitID = m.MoneyUnitID where cm.Removed=0", con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins = new CoinMovement();
                    ins.CoinMovementID = Convert.ToInt32(drI["CoinMovementID"]);
                    ins.ActualDate = Convert.ToDateTime(drI["ActualDate"]);
                    ins.ModifiedDate = Convert.ToDateTime(drI["ModifiedDate"]);
                    ins.Amount = Convert.ToDecimal(drI["Amount"]);
                    ins.MovementTypeID = Convert.ToInt32(drI["MovementTypeID"]);
                    ins.MoneyUnitID = Convert.ToInt32(drI["MoneyUnitID"]);
                    ins.UserID = Convert.ToString(drI["UserID"]);
                    ins.moneyunit = drI["MoneyUnit"].ToString();
                    ins.movementtype = drI["CoinMovementType"].ToString();
                    list.Add(ins);
                }
            }

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

            //...Return...
            return list;
        }
コード例 #3
0
        public List <CoinMovement> GetCoinMovementsPerMovementType(int MovementTypeID)
        {
            //...Create New Instance of Object...
            List <CoinMovement> list = new List <CoinMovement>();
            CoinMovement        ins;

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

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

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins = new CoinMovement();
                    ins.CoinMovementID = Convert.ToInt32(drI["CoinMovementID"]);
                    ins.ActualDate     = Convert.ToDateTime(drI["ActualDate"]);
                    ins.ModifiedDate   = Convert.ToDateTime(drI["ModifiedDate"]);
                    ins.Amount         = Convert.ToDecimal(drI["Amount"]);
                    ins.MovementTypeID = Convert.ToInt32(drI["MovementTypeID"]);
                    ins.MoneyUnitID    = Convert.ToInt32(drI["MoneyUnitID"]);
                    ins.UserID         = Convert.ToString(drI["UserID"]);
                    ins.UserTypeID     = Convert.ToInt32(drI["UserTypeID"]);
                    list.Add(ins);
                }
            }

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


            //...Return...
            return(list);
        }
コード例 #4
0
        public CoinMovement GetCoinMovement(int CoinMovementID)
        {
            //...Create New Instance of Object...
            CoinMovement ins = new CoinMovement();

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

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

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins.CoinMovementID = Convert.ToInt32(drI["CoinMovementID"]);
                    ins.ActualDate = Convert.ToDateTime(drI["ActualDate"]);
                    ins.ModifiedDate = Convert.ToDateTime(drI["ModifiedDate"]);
                    ins.Amount = Convert.ToDecimal(drI["Amount"]);
                    ins.MovementTypeID = Convert.ToInt32(drI["MovementTypeID"]);
                    ins.MoneyUnitID = Convert.ToInt32(drI["MoneyUnitID"]);
                    ins.UserID = Convert.ToString(drI["UserID"]);
                    ins.UserTypeID = Convert.ToInt32(drI["UserTypeID"]);
                }
            }

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

            //...Return...
            return ins;
        }
コード例 #5
0
        public CoinMovement Update(CoinMovement 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.CoinMovementUpdate;
            cmdI.CommandType = System.Data.CommandType.StoredProcedure;
            cmdI.Parameters.AddWithValue("@CoinMovementID", ins.CoinMovementID);
            cmdI.Parameters.AddWithValue("@ActualDate", ins.ActualDate);
            cmdI.Parameters.AddWithValue("@ModifiedDate", ModifiedDate);
            cmdI.Parameters.AddWithValue("@CreatedDate", DateTime.Now);
            cmdI.Parameters.AddWithValue("@Amount", ins.Amount);
            cmdI.Parameters.AddWithValue("@MovementTypeID", ins.MovementTypeID);
            cmdI.Parameters.AddWithValue("@MoneyUnitID", ins.MoneyUnitID);
            cmdI.Parameters.AddWithValue("@UserID", EmployeeId);
            cmdI.Parameters.AddWithValue("@CompanyID", 0);
            cmdI.Parameters.AddWithValue("@ModifiedBy", EmployeeId);


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

            return(ins);
        }
コード例 #6
0
        public CoinMovement Update(CoinMovement 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.CoinMovementUpdate;
            cmdI.CommandType = System.Data.CommandType.StoredProcedure;
            cmdI.Parameters.AddWithValue("@CoinMovementID", ins.CoinMovementID);
            cmdI.Parameters.AddWithValue("@ActualDate", ins.ActualDate);
            cmdI.Parameters.AddWithValue("@ModifiedDate", ModifiedDate);
            cmdI.Parameters.AddWithValue("@CreatedDate", DateTime.Now);
            cmdI.Parameters.AddWithValue("@Amount", ins.Amount);
            cmdI.Parameters.AddWithValue("@MovementTypeID", ins.MovementTypeID);
            cmdI.Parameters.AddWithValue("@MoneyUnitID", ins.MoneyUnitID);
            cmdI.Parameters.AddWithValue("@UserID", EmployeeId);
            cmdI.Parameters.AddWithValue("@CompanyID", 0);
            cmdI.Parameters.AddWithValue("@ModifiedBy", EmployeeId);

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

            return ins;
        }
コード例 #7
0
        public CoinMovement Insert(CoinMovement 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 = "CoinMovementIns_" + 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.CoinMovementInsert;
                cmdI.CommandType = System.Data.CommandType.StoredProcedure;
                //cmdI.Parameters.AddWithValue("@InstantMoneyID", ins.InstantMoneyID);
                cmdI.Parameters.AddWithValue("@ActualDate", ins.ActualDate);
                cmdI.Parameters.AddWithValue("@ModifiedDate",ModifiedDate);
                cmdI.Parameters.AddWithValue("@CreatedDate", DateTime.Now);
                cmdI.Parameters.AddWithValue("@Amount", ins.Amount);
                cmdI.Parameters.AddWithValue("@MovementTypeID", ins.MovementTypeID);
                cmdI.Parameters.AddWithValue("@MoneyUnitID", ins.MoneyUnitID);
                cmdI.Parameters.AddWithValue("@UserID", EmployeeId);
                cmdI.Parameters.AddWithValue("@CompanyID", 0);
                cmdI.Parameters.AddWithValue("@ModifiedBy", EmployeeId);
                cmdI.Parameters.AddWithValue("@Removed", 0);

                //...Return new ID
                ins.CoinMovementID = (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;
        }
コード例 #8
0
        public JsonResult _UpdateCoinMovement(CoinMovement ins)
        {
            CoinMovement ins2 = CoinRep.Update(ins);

            //...Repopulate Grid...
            return Json(new GridModel(CoinRep.GetAllCoinMovement()));
        }
コード例 #9
0
        public CoinMovement Insert(CoinMovement 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       = "CoinMovementIns_" + 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.CoinMovementInsert;
                cmdI.CommandType = System.Data.CommandType.StoredProcedure;
                //cmdI.Parameters.AddWithValue("@InstantMoneyID", ins.InstantMoneyID);
                cmdI.Parameters.AddWithValue("@ActualDate", ins.ActualDate);
                cmdI.Parameters.AddWithValue("@ModifiedDate", ModifiedDate);
                cmdI.Parameters.AddWithValue("@CreatedDate", DateTime.Now);
                cmdI.Parameters.AddWithValue("@Amount", ins.Amount);
                cmdI.Parameters.AddWithValue("@MovementTypeID", ins.MovementTypeID);
                cmdI.Parameters.AddWithValue("@MoneyUnitID", ins.MoneyUnitID);
                cmdI.Parameters.AddWithValue("@UserID", EmployeeId);
                cmdI.Parameters.AddWithValue("@CompanyID", 0);
                cmdI.Parameters.AddWithValue("@ModifiedBy", EmployeeId);
                cmdI.Parameters.AddWithValue("@Removed", 0);


                //...Return new ID
                ins.CoinMovementID = (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);
        }