protected void btnEnter_Click(object sender, EventArgs e)
        {
            //local variables for new user

            string studentName = ddlStudentName.SelectedValue;

            //DBConnect object
            DBConnect dbobj = new DBConnect();
            //good code
            //Database Updates
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandType = CommandType.StoredProcedure;
            sqlCommand.CommandText = "AddNewStudent";
               // sqlCommand.Parameters.AddWithValue("@StudentID", studentID);
            sqlCommand.Parameters.AddWithValue("@Name", studentName);
               // sqlCommand.Parameters.AddWithValue("@FieldOfStudy", fieldOfStudy);

            dbobj.DoUpdateUsingCmdObj(sqlCommand);

            //bad code
            //SqlCommand objCommand = new SqlCommand();
            //objCommand.CommandType = CommandType.StoredProcedure;
            //objCommand.CommandText = "GetRentalCarAgencies";
            //objCommand.Parameters.AddWithValue("@city", city);
            //objCommand.Parameters.AddWithValue("@state", state);
            //DBConnect objDB = new DBConnect();
            //return objDB.GetDataSetUsingCmdObj(objCommand);
        }
Пример #2
0
        public void AddCustomer(Customer customer)
        {
            DBConnect objdb = new DBConnect();

            string insertCustSQL = "INSERT INTO CUSTOMER (FirstName, LastName, Address, City, State, Zipcode)"
            + "VALUES ('" + customer.FirstName + "','" + customer.LastName + "','" + customer.Address + "','" + customer.City + "','" + customer.State + "','" + customer.Zipcode + "')'";

            objdb.DoUpdate(insertCustSQL);
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DBConnect objDB = new DBConnect();
            String strSQL = "SELECT * FROM Students_Table";
            DataSet myDataSet = objDB.GetDataSet(strSQL);

            gvStudents.DataSource = myDataSet;
            gvStudents.DataBind();
        }
        public void AddTPCustomerToDB(string email)
        {
            DBConnect objDB = new DBConnect();
            SqlCommand objCommand = new SqlCommand();
            objCommand.CommandType = CommandType.StoredProcedure;
            objCommand.CommandText = "AddTPCustomer";
            objCommand.Parameters.AddWithValue("@email",  );

            int result = objDB.DoUpdateUsingCmdObj(objCommand);
        }
Пример #5
0
        public void loadCourses()
        {
            DBConnect objDB = new DBConnect();
            SqlCommand objCommand = new SqlCommand();

            objCommand.CommandType = CommandType.StoredProcedure;
            objCommand.CommandText = "ShowAllCourses";
            DataSet myDS = objDB.GetDataSetUsingCmdObj(objCommand);
            gvCourses.DataSource = myDS;
            gvCourses.DataBind();
        }
Пример #6
0
 public void AddCreditCardAccount(string name, float cardNumber, int expMonth, int expYear, int CSV)
 {
     DBConnect objdb = new DBConnect();
     SqlCommand sqlCommand = new SqlCommand();
     sqlCommand.CommandType = CommandType.StoredProcedure;
     sqlCommand.CommandText = "AddNewCreditCard";
     //Values to go into Account Table
     sqlCommand.Parameters.AddWithValue("@Name", name);
     sqlCommand.Parameters.AddWithValue("@CardNumber", cardNumber);
     sqlCommand.Parameters.AddWithValue("@ExpMonth", expMonth);
     sqlCommand.Parameters.AddWithValue("@ExpYear", expYear);
     sqlCommand.Parameters.AddWithValue("@CSV", CSV);
     objdb.DoUpdateUsingCmdObj(sqlCommand);
 }
Пример #7
0
        public void addTransactionLog(string name, float cardNumber, int expMonth, int expYear, int CSV, decimal balance, decimal transactionAmt )
        {
            // stored procedure "AddTransactionLog"
            DBConnect objdb = new DBConnect();
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandType = CommandType.StoredProcedure;
            sqlCommand.CommandText = "AddTransactionLog";
            sqlCommand.Parameters.AddWithValue("@Name", name);
            sqlCommand.Parameters.AddWithValue("@CardNumber", cardNumber);
            sqlCommand.Parameters.AddWithValue("@ExpMonth", expMonth);
            sqlCommand.Parameters.AddWithValue("@ExpYear", expYear);
            sqlCommand.Parameters.AddWithValue("@CSV", CSV);
            sqlCommand.Parameters.AddWithValue("@Balance", balance);
            sqlCommand.Parameters.AddWithValue("@TransactionAmount", transactionAmt);

            objdb.DoUpdateUsingCmdObj(sqlCommand);
        }
        public void registerStudentForClass(string StudentID, string CRN)
        {
            DBConnect objDB = new DBConnect();
            string strSQL = "INSERT INTO [CourseRegistration] (StudentID, CRN) VALUES('" + StudentID + "','" + CRN + "')";
            int updatedRows = objDB.DoUpdate(strSQL);

            strSQL = "DECLARE @DecrementValue int SET @DecrementValue = 1 UPDATE Course SET NumberOfSeatsAvailable = NumberOfSeatsAvailable - @DecrementValue WHERE CRN='" + CRN + "'";
            updatedRows = objDB.DoUpdate(strSQL);

            strSQL = "SELECT CreditHours FROM Course WHERE CRN='" + CRN + "'";
            DataSet myDS = objDB.GetDataSet(strSQL);
            DataRow currRow = objDB.GetRow(myDS, 0);
            float courseCredit = float.Parse(currRow["CreditHours"].ToString());
            float coursePrice = courseCredit * 10000;

            strSQL = "DECLARE @CoursePrice float SET @CoursePrice = " + coursePrice + " UPDATE Students SET TutionOwed = TutionOwed + @CoursePrice WHERE StudentID=" + StudentID;
            updatedRows = objDB.DoUpdate(strSQL);
        }
Пример #9
0
        public decimal getAccountBalance(string name, float cardNumber)
        {
            DBConnect objdb = new DBConnect();
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandType = CommandType.StoredProcedure;
            sqlCommand.CommandText = "GetAccountBalance";
            sqlCommand.Parameters.AddWithValue("@Name", name);
            sqlCommand.Parameters.AddWithValue("@CardNumber", cardNumber);

            SqlParameter returnParameter = new SqlParameter("@Balance", DbType.Decimal);
            returnParameter.Direction = ParameterDirection.ReturnValue;
            sqlCommand.Parameters.Add(returnParameter);

            // Execute stored procedure using DBConnect object and the SQLCommand object
            objdb.GetDataSetUsingCmdObj(sqlCommand);

            decimal balance;
            balance = decimal.Parse(sqlCommand.Parameters["@Balance"].Value.ToString());
            return balance;
        }
Пример #10
0
 public void updateName(string name, int AccountID)
 {
     DBConnect objdb = new DBConnect();
     SqlCommand sqlCommand = new SqlCommand();
     sqlCommand.CommandType = CommandType.StoredProcedure;
     sqlCommand.CommandText = "UpdateAccountName";
     sqlCommand.Parameters.AddWithValue("@Name", name);
     sqlCommand.Parameters.AddWithValue("@AccountID", AccountID);
     objdb.DoUpdateUsingCmdObj(sqlCommand);
 }
Пример #11
0
 public void UpdateExpYear(int expYear, int AccountID)
 {
     DBConnect objdb = new DBConnect();
     SqlCommand sqlCommand = new SqlCommand();
     sqlCommand.CommandType = CommandType.StoredProcedure;
     sqlCommand.CommandText = "UpdateExpYear";
     sqlCommand.Parameters.AddWithValue("@ExpYear", expYear);
     sqlCommand.Parameters.AddWithValue("@AccountID", AccountID);
     objdb.DoUpdateUsingCmdObj(sqlCommand);
 }
Пример #12
0
        public int Transaction(string name, float cardNumber,int expMonth, int expYear, int CSV, double transactionAmt)
        {
            int returnval;
            //get Account Balance
            decimal balance = getAccountBalance(name, cardNumber);
            decimal transaction = decimal.Parse(transactionAmt.ToString());

            //if balance is greater than transaction amount, do the transaction
            if (balance > transaction)
            {
                //Update Account balance using stored procedure
                DBConnect objdb = new DBConnect();
                SqlCommand sqlCommand = new SqlCommand();
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = "UpdateAccountBalance";
                sqlCommand.Parameters.AddWithValue("@CardNumber", cardNumber);
                sqlCommand.Parameters.AddWithValue("@TransactionAmount", transactionAmt);
                objdb.DoUpdateUsingCmdObj(sqlCommand);  //execute update

                //create a log of the transaction
                addTransactionLog(name, cardNumber, expMonth, expYear, CSV, balance, transaction);
                returnval = 0;
            }

            else
            {
                returnval = 1;
            }

            return returnval;
        }
Пример #13
0
        public int getCreditCardCount()
        {
            DBConnect objdb = new DBConnect();
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandType = CommandType.StoredProcedure;
            sqlCommand.CommandText = "GetCreditCardCount";

            //stores the value in the variable @theCount
            SqlParameter returnParameter = new SqlParameter("@theCount", DbType.Int32);
            returnParameter.Direction = ParameterDirection.ReturnValue;
            sqlCommand.Parameters.Add(returnParameter);

            // Execute stored procedure using DBConnect object and the SQLCommand object
            objdb.GetDataSetUsingCmdObj(sqlCommand);

            int count;
            count = int.Parse(sqlCommand.Parameters["@theCount"].Value.ToString());
            return count;
        }
Пример #14
0
 public DataSet getAllTransactions()
 {
     //Update Account balance using stored procedure
     DBConnect objdb = new DBConnect();
     SqlCommand sqlCommand = new SqlCommand();
     sqlCommand.CommandType = CommandType.StoredProcedure;
     sqlCommand.CommandText = "GetAllTransactions";
     DataSet dataset = objdb.GetDataSetUsingCmdObj(sqlCommand);
     return dataset;
 }
Пример #15
0
        protected void gvCourses_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int rowIndex = e.RowIndex;
            int selectedCRN = int.Parse(gvCourses.Rows[rowIndex].Cells[1].Text);
            DBConnect objDB = new DBConnect();
            SqlCommand objCommand = new SqlCommand();
            objCommand.CommandType = CommandType.StoredProcedure;
            objCommand.CommandText = "DeleteCourse";
            objCommand.Parameters.AddWithValue("@CRN", selectedCRN);
            objDB.GetDataSetUsingCmdObj(objCommand);
            objDB.DoUpdateUsingCmdObj(objCommand);

            loadCourses();
        }
Пример #16
0
 public DataSet GetAccounts()
 {
     DBConnect objdb = new DBConnect();
     SqlCommand sqlCommand = new SqlCommand();
     sqlCommand.CommandType = CommandType.StoredProcedure;
     sqlCommand.CommandText = "GetAllAccounts";
     DataSet dataset = objdb.GetDataSetUsingCmdObj(sqlCommand);
     return dataset;
 }
Пример #17
0
 public object GetDataSetUsingCmdObj(DBConnect dbobj)
 {
     throw new NotImplementedException();
 }
Пример #18
0
 public void updateCardNumber(float cardNumber, int AccountID)
 {
     DBConnect objdb = new DBConnect();
     SqlCommand sqlCommand = new SqlCommand();
     sqlCommand.CommandType = CommandType.StoredProcedure;
     sqlCommand.CommandText = "UpdateCardNumber";
     sqlCommand.Parameters.AddWithValue("@CardNumber", cardNumber);
     sqlCommand.Parameters.AddWithValue("@AccountID", AccountID);
     objdb.DoUpdateUsingCmdObj(sqlCommand);
 }