private void CreateNewUserIfNotExist() { if (!dc.tblUsers.Any(z => z.USER_MACADRESS == mac)) { var user = new tblUser { USER_NAME = Utilities.GetUsername(), USER_MACADRESS = mac, USER_ADMIN = false, }; dc.tblUsers.InsertOnSubmit(user); dc.SubmitChanges(); } }
public Admin() { var versionstring = "100"; version = double.Parse(versionstring); dc = new AlsiTMDataContext(); mac = Utilities.GetMacAddress().First(); CreateNewUserIfNotExist(); UserID = dc.tblUsers.Where(z => z.USER_MACADRESS == mac).Select(z => z.ID).First(); UserList = dc.tblUsers.ToList(); var user = dc.tblUsers.Where(z => z.USER_MACADRESS == mac).First(); if (GetNewVersionNumber(user) > version) { var u = new UpdateForm("https://www.dropbox.com/s/rcnhl5eab7f2ywp/WebNotify.zip"); u.ShowDialog(); } var log = new tblLog { LOG_TS = DateTime.UtcNow.AddHours(2), LOG_USER_ID = user.ID, LOG_VERSION = version.ToString(), }; dc.tblLogs.InsertOnSubmit(log); dc.SubmitChanges(); }
private void userListView_DoubleClick(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; if (userListView.SelectedItems.Count == 0) { return; } var user = (tblUser)userListView.SelectedItems[0].Tag; var dc = new AlsiTMDataContext(); var dbu = dc.tblUsers.Where(z => z.USER_MACADRESS == user.USER_MACADRESS).First(); dbu.USER_ADMIN = !dbu.USER_ADMIN; dc.SubmitChanges(); PopulateListView(); Cursor = Cursors.Default; }
private void OKButton_Click(object sender, EventArgs e) { User.USER_NAME = usernameInputTextbox.Text; dc.SubmitChanges(); Close(); }