Beispiel #1
0
        public bool InsertStatus(DemoModel Status)
        {
            DataAccessLayer dal = new DataAccessLayer();
            bool Success = true;
            try
            {
                /* Testing Insert */
                Dictionary<string, string> dict = new Dictionary<string,string>();
                dict.Add("StatusName", Status.StatusName);
                // no need to add statusID, as that column is an identity column
                dal.insert(dict, "TransactionStatus");

                /* Testing Select */
                DataTable dt = new DataTable();
                dt = dal.select("StatusName = 'a'", "TransactionStatus");
                foreach (DataRow row in dt.Rows) // Loop over the rows.
                {
                    foreach (var col in row.ItemArray)
                    {
                        Debug.Write(col);
                    }
                    Debug.Write('\n');
                }

                /* Testing Update */
                Dictionary<string, string> d = new Dictionary<string, string>();
                d.Add("StatusName", "'asma_rox'");
                dal.update("TransactionStatus", "StatusName = 'asma_sux'", d);
                /* Manually go into SQL Server to see if the row is correctly updated */

                /* Testing Delete */
                dal.delete("StatusName = 'johnny'", "TransactionStatus");
                /* now the db should not contain an entry with StatusName = 'johnny' */

            }
            catch (Exception)
            {
                Success = false;
            }
            return Success;
        }
Beispiel #2
0
        public static bool updateUserProfile_Email(int ProfileID, string Email)
        {
            bool success = false;

            try
            {
                Dictionary<string, string> Profile = new Dictionary<string,string>();
                Profile.Add("Email", String.Format("'{0}'", Email));

                DataAccessLayer DAL = new DataAccessLayer();
                DAL.update("UserProfile", String.Format("ProfileID = '{0}'", ProfileID), Profile);

            }
            catch (Exception ex)
            {
                Console.Write("ERROR: An error occured in updating user profile with ethe given email --- " + ex.Message);
            }

            return success;
        }