Esempio n. 1
0
        public List<RegisterClient> GetListRegisterClient(int ClientId)
        {
            List<RegisterClient> list = new List<RegisterClient>();
            RegisterClient ins;

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

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT * FROM RegisterClient WHERE ClientId = " + ClientId + " ORDER BY RegisterClientId DESC", con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins = new RegisterClient();
                    ins.RegisterClientID = Convert.ToInt32(drI["RegisterClientId"]);
                    ins.ClientId = Convert.ToInt32(drI["ClientId"]);
                    ins.ClientNo = drI["TeamIdA"].ToString();
                    ins.Email = drI["TeamIdB"].ToString();
                    ins.Passwords = drI["StartTime"].ToString();
                    ins.Approved = Convert.ToBoolean(drI["Approved"]);
                    list.Add(ins);
                }
            }
            drI.Close();
            con.Close();

            return list;
        }
Esempio n. 2
0
        public RegisterClient UpdateRegisterClient(RegisterClient ins)
        {
            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            con.Open();
            SqlCommand cmdI = con.CreateCommand();
            cmdI.Connection = con;

            //...Update Picture...

            //...Update Record...
            cmdI.Parameters.Clear();
            cmdI.CommandText = "f_Admin_Update_RegisterClient";
            cmdI.CommandType = System.Data.CommandType.StoredProcedure;
            cmdI.Parameters.AddWithValue("@RegisterClientID", ins.RegisterClientID);
            cmdI.Parameters.AddWithValue("@ClientId", ins.ClientId);
            cmdI.Parameters.AddWithValue("@ClientNo", ins.ClientNo);
            cmdI.Parameters.AddWithValue("@Email", ins.Email);
            cmdI.Parameters.AddWithValue("@Passwords", ins.Passwords);
            cmdI.Parameters.AddWithValue("@Approved", ins.Approved);
            cmdI.ExecuteNonQuery();
            cmdI.Connection.Close();

            return ins;
        }
Esempio n. 3
0
        public RegisterClient InsertRegisterClient(RegisterClient ins)
        {
            //...Get User and Date Data...
            string strTrx = "Insert_RegisterClient";

            //...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 Picture...

                //...Insert Record...
                cmdI.Parameters.Clear();
                cmdI.CommandText = "f_Admin_Insert_RegisterClient";
                //cmdI.Connection.Open();
                cmdI.CommandType = System.Data.CommandType.StoredProcedure;
                cmdI.Parameters.AddWithValue("@ClientId", ins.ClientId);
                cmdI.Parameters.AddWithValue("@ClientNo", ins.ClientNo);
                cmdI.Parameters.AddWithValue("@Email", ins.Email);
                cmdI.Parameters.AddWithValue("@Passwords", ins.Passwords);
                cmdI.Parameters.AddWithValue("@Approved", ins.Approved);

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

                //...Commit Transaction...
                trx.Commit();
                cmdI.Connection.Close();
            }
            catch (SqlException ex)
            {
                if (trx != null) trx.Rollback();
                //...Save Error to Log...
                Functions func = new Functions();
                func.LogError(ex.ToString());
            }
            finally
            {
                //...Check for close and respond accordingly..
                if (con.State != ConnectionState.Closed)
                {
                    con.Close();
                }

                //...Clean up...
                con.Dispose();
                cmdI.Dispose();
                trx.Dispose();
            }

            return ins;
        }