public AddMessageViewModel(INavigation navigation) { System.Diagnostics.Debug.WriteLine("=================================="); System.Diagnostics.Debug.Flush(); DateTime date = DateTime.Now; var test = date.ToString("yyyy-MM-dd H:mm:ss.fffffffzzz"); System.Diagnostics.Debug.WriteLine("AddMessageViewModel() constructor -1- start - timestamp: " + test); System.Diagnostics.Debug.Flush(); _navigation = navigation; _message = new MessageInfo(); GetDBConnection dbConnection = new GetDBConnection(); if (dbConnection == null || dbConnection.Connection == null) { string errMsg = dbConnection.ConnException.Message; App.DatabaseError("AddMessageViewModel() constructor", errMsg); return; } else { string textPointer = "pointer is null"; if (dbConnection.Connection != null) { if (dbConnection.Connection.Handle == null) { textPointer = "handle is null"; } else { textPointer = dbConnection.Connection.Handle.ptr.ToString(); } } System.Diagnostics.Debug.WriteLine("AddMessageViewModel() constructor -2- sqlite connection: " + textPointer); } _repository = new Repository(dbConnection.Connection); ContactList = _repository.GetAllContactsData(); IList <int> foreignKeys = _repository.GetAllContactKeys(); _messageValidator = new MessageValidator(foreignKeys); AddMessageCommand = new Command(async() => await AddMessage()); test = date.ToString("yyyy-MM-dd H:mm:ss.fffffffzzz"); System.Diagnostics.Debug.WriteLine("AddMessageViewModel() constructor -3- end - timestamp: " + test); System.Diagnostics.Debug.WriteLine("=================================="); System.Diagnostics.Debug.Flush(); }
public DetailsContactViewModel(INavigation navigation, int selectedContactID) { System.Diagnostics.Debug.WriteLine("=================================="); System.Diagnostics.Debug.Flush(); DateTime date = DateTime.Now; var test = date.ToString("yyyy-MM-dd H:mm:ss.fffffffzzz"); System.Diagnostics.Debug.WriteLine("DetailsContactViewModel() constructor -1- start - timestamp: " + test); System.Diagnostics.Debug.Flush(); _navigation = navigation; _contactValidator = new ContactValidator(); _contact = new ContactInfo(); _contact.Id = selectedContactID; GetDBConnection dbConnection = new GetDBConnection(); if (dbConnection == null || dbConnection.Connection == null) { string errMsg = dbConnection.ConnException.Message; App.DatabaseError("DetailsContactViewModel() constructor", errMsg); return; } else { string textPointer = "pointer is null"; if (dbConnection.Connection != null) { if (dbConnection.Connection.Handle == null) { textPointer = "handle is null"; } else { textPointer = dbConnection.Connection.Handle.ptr.ToString(); } } System.Diagnostics.Debug.WriteLine("DetailsContactViewModel() constructor -2- sqlite connection: " + textPointer); } _repository = new Repository(dbConnection.Connection); UpdateContactCommand = new Command(async() => await UpdateContact()); DeleteContactCommand = new Command(async() => await DeleteContact()); FetchContactDetails(); test = date.ToString("yyyy-MM-dd H:mm:ss.fffffffzzz"); System.Diagnostics.Debug.WriteLine("DetailsContactViewModel() constructor -3- end - timestamp: " + test); System.Diagnostics.Debug.WriteLine("=================================="); System.Diagnostics.Debug.Flush(); }
//Search Method public void Search_Data() { GetDBConnection.Open(); using (var cmd = new SqlCommand()) { dt.Clear(); cmd.CommandText = "Select * from Member where Member_name ='" + search_text + "'"; SqlDataAdapter sda = new SqlDataAdapter(cmd); cmd.CommandType = CommandType.Text; cmd.Connection = GetDBConnection; sda.Fill(dt); GetDBConnection.Close(); } }
//Delete Method public void Delete_Data() { GetDBConnection.Open(); using (var cmd = new SqlCommand()) { dt.Clear(); cmd.CommandText = "Delete from Member where Member_id = @id"; SqlDataAdapter sda = new SqlDataAdapter(cmd); cmd.CommandType = CommandType.Text; //PARAMETERS @name cmd.Parameters.Add("@id", SqlDbType.Int).Value = id; cmd.Connection = GetDBConnection; sda.Fill(dt); GetDBConnection.Close(); } }
public void show_name() { GetDBConnection.Open(); using (var cmd = new SqlCommand()) { datafill.Clear(); SqlDataReader rd; cmd.CommandText = "Select * from member"; cmd.CommandType = CommandType.Text; cmd.Connection = GetDBConnection; rd = cmd.ExecuteReader(); while (rd.Read()) { datafill.Add(rd[1].ToString()); } GetDBConnection.Close(); } }
//Insert method public void insert() { GetDBConnection.Open(); using (var cmd = new SqlCommand()) { cmd.CommandText = "insert into Trainer (Trainer_name,Trainer_gender,Trainer_dob,Trainer_mobile,Trainer_Email,Trainer_address) values(@name,@gender,@dob,@mobile,@email,@address)"; cmd.CommandType = CommandType.Text; cmd.Connection = GetDBConnection; //PARAMETERS @name,@cnic,@gender,@dob,@mobile,@email,@joindate,@gymtime,@address,@membershiptype cmd.Parameters.Add("@name", SqlDbType.NVarChar).Value = name; cmd.Parameters.Add("@gender", SqlDbType.NVarChar).Value = gender; cmd.Parameters.Add("@dob", SqlDbType.NVarChar).Value = dob; cmd.Parameters.Add("@mobile", SqlDbType.NVarChar).Value = mobile; cmd.Parameters.Add("@email", SqlDbType.NVarChar).Value = email; cmd.Parameters.Add("@address", SqlDbType.NVarChar).Value = address; cmd.ExecuteNonQuery(); GetDBConnection.Close(); } }
public void insert() { GetDBConnection.Open(); using (var cmd = new SqlCommand()) { cmd.CommandText = "insert into Payment (Payment_Customer_name,Payment_amount,Payment_description,Payment_date,Package_name,Package_type) values(@name,@amount,@desc,@paid_date,@pkg_name,@pkg_type)"; cmd.CommandType = CommandType.Text; cmd.Connection = GetDBConnection; //PARAMETERS @name,@cnic,@gender,@dob,@mobile,@email,@joindate,@gymtime,@address,@membershiptype cmd.Parameters.Add("@name", SqlDbType.NVarChar).Value = name; cmd.Parameters.Add("@amount", SqlDbType.NVarChar).Value = amount; cmd.Parameters.Add("@desc", SqlDbType.NVarChar).Value = desc; cmd.Parameters.Add("@paid_date", SqlDbType.NVarChar).Value = paid_date; cmd.Parameters.Add("@pkg_name", SqlDbType.NVarChar).Value = pkg_name; cmd.Parameters.Add("@pkg_type", SqlDbType.NVarChar).Value = pkg_type; cmd.ExecuteNonQuery(); GetDBConnection.Close(); } }
//Update Method public void Update_Data() { GetDBConnection.Open(); using (var cmd = new SqlCommand()) { dt.Clear(); cmd.CommandText = "Update Member SET Member_mobile=@mobile, Member_Email=@email, Gym_time=@gymtime, Member_address=@address, Membership_type=@membershiptype where Member_id = @id"; SqlDataAdapter sda = new SqlDataAdapter(cmd); cmd.CommandType = CommandType.Text; //PARAMETERS cmd.Parameters.Add("@id", SqlDbType.Int).Value = id; cmd.Parameters.Add("@mobile", SqlDbType.NVarChar).Value = mobile; cmd.Parameters.Add("@email", SqlDbType.NVarChar).Value = email; cmd.Parameters.Add("@gymtime", SqlDbType.NVarChar).Value = gymtime; cmd.Parameters.Add("@address", SqlDbType.NVarChar).Value = address; cmd.Parameters.Add("@membershiptype", SqlDbType.NVarChar).Value = membershiptype; cmd.Connection = GetDBConnection; sda.Fill(dt); GetDBConnection.Close(); } }