private static void a_ButtonLoginEven(int iLogin, string strMachine, string strUserWindow, string strIpAddress, string strUsername, string password, string strBatch, string strRole, string strToken, ref bool loginOk) { if (iLogin == 1) { //Kiểm tra Token bool has = Global.DbBpo.tbl_TokenLogins.Any(w => w.UserName == strUsername && w.IDProject == Global.StrIdProject); if (has) { var token = (from w in Global.DbBpo.tbl_TokenLogins where w.UserName == strUsername && w.IDProject == Global.StrIdProject select w.Token).FirstOrDefault(); if (token == "") { Global.DbBpo.updateToken(strUsername, Global.StrIdProject, strToken); Global.DbBpo.InsertLoginTime_new(strUsername, DateTime.Now, strUserWindow, strMachine, strIpAddress, strToken, Global.StrIdProject); loginOk = true; } else { if (MessageBox.Show(@"This user has logged in on another machine. Would you like to continue signing in?", @"Notification", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { Global.DbBpo.updateToken(strUsername, Global.StrIdProject, strToken); Global.DbBpo.InsertLoginTime_new(strUsername, DateTime.Now, strUserWindow, strMachine, strIpAddress, strToken, Global.StrIdProject); loginOk = true; } else { loginOk = false; } } } else { var token = new tbl_TokenLogin(); token.UserName = strUsername; token.IDProject = Global.StrIdProject; token.Token = ""; token.DateLogin = DateTime.Now; Global.DbBpo.tbl_TokenLogins.InsertOnSubmit(token); Global.DbBpo.SubmitChanges(); loginOk = true; Global.DbBpo.updateToken(strUsername, Global.StrIdProject, strToken); Global.DbBpo.InsertLoginTime_new(strUsername, DateTime.Now, strUserWindow, strMachine, strIpAddress, strToken, Global.StrIdProject); } } }
partial void Deletetbl_TokenLogin(tbl_TokenLogin instance);
partial void Updatetbl_TokenLogin(tbl_TokenLogin instance);
partial void Inserttbl_TokenLogin(tbl_TokenLogin instance);