public DB(Account[] Accs,DataGridView DataGrid) { size = 0; _dataGrid = DataGrid; _db = new List<Account>(); foreach (Account a in Accs) { Add(a,size); size++; } _dataGrid.BeginInvoke((MethodInvoker)(() => _dataGrid.Rows.Add(size))); }
public static void Login(int _fromClient, Packet _packet) { string username = _packet.ReadString(); string password = _packet.ReadString(); Database.Account account = Database.ActiveRecord.Load <Database.Account>(("username", username), ("password", password)); }
protected void Page_Load(object sender, EventArgs e) { if (HttpContext.Current.User.Identity.IsAuthenticated) { menuNavigation.Items[0].Text = Resources.Localization.Logout; menuNavigation.Items[0].NavigateUrl = "~/Logout.aspx"; try { string accName = (string)Session["AccountName"]; if (String.IsNullOrEmpty(accName)) { Database.Interface.open(); Database.Account account = new Database.Account(); MembershipUser user = Membership.GetUser(); account.select_all_where_ID((Guid)user.ProviderUserKey); Session["AccountName"] = account.Name; accName = account.Name; } labelProfile.Text = Resources.Localization.Account + ": " + accName; } catch (Exception ex) { Database.Interface.close(); } } else { menuNavigation.Items[0].Text = Resources.Localization.Login; menuNavigation.Items[0].NavigateUrl = "~/Login.aspx"; menuNavigation.Visible = false; return; } // Get page name from relative path string thisPage = Page.AppRelativeVirtualPath; int slashPos = thisPage.LastIndexOf("/"); string pageName = "~" + thisPage.Substring(slashPos, thisPage.Length - slashPos); // Select menu item with matching NavigateUrl property foreach (MenuItem parentMenu in menuNavigation.Items) { if (parentMenu.NavigateUrl.ToUpper() == pageName.ToUpper()) { parentMenu.Selected = true; } } }
protected void ddCourses_OnSelectedIndexChanged(object sender, EventArgs e) { if (ddCourses.SelectedValue == Guid.Empty.ToString()) { textBoxCourseTitleUpd.Text = ""; textBoxCourseDescriptionUpd.Text = ""; textBoxCourseCommentUpd.Text = ""; checkBoxCourseCompleteUpd.Checked = false; lbMembers.Items.Clear(); return; } try { Database.Interface.open(); Database.Course course = new Database.Course(); if (!course.select_all_where_ID(new Guid(ddCourses.SelectedValue))) { Utils.displayStatus(ref labelStatusCreate, Color.Red, "Kurs '" + ddCourses.SelectedItem.Text + "' ikke funnet"); return; } textBoxCourseTitleUpd.Text = course.Title; textBoxCourseDescriptionUpd.Text = course.Description; textBoxCourseCommentUpd.Text = course.Comment; checkBoxCourseCompleteUpd.Checked = course.Completed; Database.Contact contact = new Database.Contact(); Database.Account account = new Database.Account(); string accountName = ""; List <Guid> idList = new List <Guid>(); Database.Contact.select_ID_from_courseID(new Guid(ddCourses.SelectedValue), ref idList); lbMembers.Items.Clear(); foreach (Guid id in idList) { contact.select_all_by_ID(id); account.select_String_where_ID(contact.AccountID, "vchName", ref accountName); lbMembers.Items.Add(new ListItem(contact.Name + " fra " + accountName + " [" + (contact.Status == "Active" ? "Aktiv" : "Inaktiv") + "]")); } } catch (Exception ex) { Utils.displayStatus(ref labelStatusEdit, Color.Red, ex.Message); } finally { Database.Interface.close(); } }
protected void buttonRegister_OnClick(object sender, EventArgs e) { try { if (ddRegister.Items.Count <= 0) { Utils.displayStatus(ref labelStatusRegister, Color.Red, Lang.You_need_min_one_contact_before_register); return; } if (ddRegister.SelectedValue == Guid.Empty.ToString()) { Utils.displayStatus(ref labelStatusRegister, Color.Red, Lang.You_need_to_select_a_contact_before_register); return; } Database.Interface.open(); Database.Account account = new Database.Account(); if (!account.select_all_where_ID(new Guid(hiddenAccountID.Value))) { Utils.reportStatus(ref labelStatusRegister, Color.Red, "Ringtest.buttonRegister_OnClick: account.select_all_where_ID failed"); return; } if (!account.update_Int_by_ID("intLastRegistrationYear", DateTime.Now.Year)) { Utils.reportStatus(ref labelStatusRegister, Color.Red, "Ringtest.buttonRegister_OnClick: account.update_Int_by_ID failed"); return; } if (!account.update_String_by_ID("vchRingtestContact", ddRegister.SelectedItem.Text)) { Utils.reportStatus(ref labelStatusRegister, Color.Red, "Ringtest.buttonRegister_OnClick: account.update_String_by_ID failed"); return; } } catch (Exception ex) { Utils.reportStatus(ref labelStatusRegister, Color.Red, "Ringtest.buttonRegister_OnClick: " + ex.Message); } finally { Database.Interface.close(); } initializePage(); }
protected void buttonAccountRegisterE_OnClick(object sender, EventArgs e) { if (ddUsers.SelectedValue == Guid.Empty.ToString()) { Utils.displayStatus(ref labelStatusEdit, Color.Red, "Du må velge en konto først"); return; } try { Database.Interface.open(); Database.Ringtest ringtest = new Database.Ringtest(); if (ringtest.select_all_where_year(DateTime.Now.Year)) { if (ringtest.Finished) { Utils.displayStatus(ref labelStatusEdit, Color.Red, "Ringtesten for " + DateTime.Now.Year.ToString() + " er avsluttet"); return; } } Database.Account account = new Database.Account(); account.select_all_where_ID(new Guid(ddUsers.SelectedValue)); if (account.update_Int_by_ID("intLastRegistrationYear", DateTime.Now.Year)) { Utils.displayStatus(ref labelStatusEdit, Color.SeaGreen, "Konto '" + account.Name + "' etter-registrert"); tbLastRegistrationE.Text = DateTime.Now.Year.ToString(); } else { Utils.displayStatus(ref labelStatusEdit, Color.Red, "Etter-registrering av konto feilet"); } } catch (Exception ex) { Utils.displayStatus(ref labelStatusEdit, Color.Red, ex.Message); } finally { Database.Interface.close(); } }
protected void ddUsers_OnSelectedIndexChanged(object sender, EventArgs e) { if (ddUsers.SelectedValue == Guid.Empty.ToString()) { clearAllUpdateFields(); return; } try { Database.Interface.open(); Database.Account account = new Database.Account(); account.select_all_where_ID(new Guid(ddUsers.SelectedValue)); tbNameE.Text = account.Name; lblAccountID.Text = account.ID.ToString().ToUpper(); tbContactE.Text = account.Contact; tbAddressE.Text = account.Address; tbPostalE.Text = account.Postal; tbEmailE.Text = account.Email; tbPhoneE.Text = account.Phone; tbMobileE.Text = account.Mobile; tbFaxE.Text = account.Fax; tbWebsiteE.Text = account.Website; cbActiveE.Checked = account.Active; tbCommentE.Text = account.Comment; tbLastRegistrationE.Text = account.LastRegistrationYear.ToString(); tbRingtestCountE.Text = account.RingtestCount.ToString(); Membership.ApplicationName = "/Lorakon"; MembershipUser user = Membership.GetUser(account.ID); tbUserNameE.Text = user.UserName; hiddenName.Value = tbNameE.Text; Membership.ApplicationName = "/LorakonAdmin"; } catch (Exception ex) { Utils.displayStatus(ref labelStatusEdit, Color.Red, ex.Message); } finally { Database.Interface.close(); } }
protected void buttonAccountUnregisterE_OnClick(object sender, EventArgs e) { if (ddUsers.SelectedValue == Guid.Empty.ToString()) { Utils.displayStatus(ref labelStatusEdit, Color.Red, "Du må velge en konto først"); return; } try { Database.Interface.open(); Database.Account account = new Database.Account(); account.select_all_where_ID(new Guid(ddUsers.SelectedValue)); Database.Ringtest ringtest = new Database.Ringtest(); if (ringtest.select_all_where_year(DateTime.Now.Year)) { Database.RingtestReport.delete_where_AccountID_and_Year(account.ID, ringtest.ID); } account.RingtestBoxID = Guid.Empty; account.select_LastYear_from_RingtestReport(); if (!account.update_all_by_ID()) { Utils.displayStatus(ref labelStatusEdit, Color.Red, "buttonAccountUnregisterE_OnClick: Oppdatering av konto feilet"); return; } tbLastRegistrationE.Text = account.LastRegistrationYear.ToString(); Utils.displayStatus(ref labelStatusEdit, Color.SeaGreen, "Konto '" + account.Name + "' avregistrert fra årets ringtest"); } catch (Exception ex) { Utils.displayStatus(ref labelStatusEdit, Color.Red, ex.Message); } finally { Database.Interface.close(); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { try { MembershipUser User = Membership.GetUser(HttpContext.Current.User.Identity.Name); object UserGUID = User.ProviderUserKey; dataSourceActors.SelectParameters.Add("accountID", UserGUID.ToString()); Database.Interface.open(); Database.Account account = new Database.Account(); if (!account.select_all_where_ID((Guid)UserGUID)) { Utils.reportStatus(ref labelStatus, Color.Red, Lang.Account_for_user + " '" + HttpContext.Current.User.Identity.Name + "' " + Lang.not_found); return; } tbUserNameE.Text = HttpContext.Current.User.Identity.Name; tbNameE.Text = account.Name; hiddenName.Value = tbNameE.Text; tbContactE.Text = account.Contact; tbAddressE.Text = account.Address; //tbPostboxE.Text = account.Postbox; tbPostalE.Text = account.Postal; tbEmailE.Text = account.Email; tbPhoneE.Text = account.Phone; tbMobileE.Text = account.Mobile; tbFaxE.Text = account.Fax; tbWebsiteE.Text = account.Website; } catch (Exception ex) { Utils.reportStatus(ref labelStatus, Color.Red, "Account.Page_Load: " + ex.Message); } finally { Database.Interface.close(); } } }
protected void login_OnLoggingIn(object sender, LoginCancelEventArgs e) { Database.Account account = new Database.Account(); try { MembershipUser User = Membership.GetUser(login.UserName); if (User == null) { return; } object UserGUID = User.ProviderUserKey; Database.Interface.open(); if (!account.select_all_where_ID((Guid)UserGUID)) { Utils.reportStatus(ref labelStatus, Color.Red, "Login:login_OnLoggingIn: " + Lang.Account_for_user + " '" + login.UserName + "' " + Lang.not_found); return; } if (!account.Active) { Utils.displayStatus(ref labelStatus, Color.SeaGreen, Lang.Account_for_user + " '" + login.UserName + "' " + Lang.is_not_active); e.Cancel = true; } } catch (Exception ex) { Utils.reportStatus(ref labelStatus, Color.Red, ex.Message); } finally { Database.Interface.close(); } }
public static void Registration(int _fromClient, Packet _packet) { string username = _packet.ReadString(); string password = _packet.ReadString(); string email = _packet.ReadString(); Database.Account account = Database.ActiveRecord.Load <Database.Account>(("username", username)); // Check DB for existing user if (account != null) { // Account Exists / Inform Client Server.Send.RegistrationAccountExists(_fromClient); } else { // Account Created Successfully // Added to Connected Client Server.clients[_fromClient].account = new Database.Account(username, password, email); // Send Client to Character Selection Server.Send.SendToCharacterSelection(_fromClient); } }
private void Scan() { _account = 0; var processes = Process.GetProcessesByName("Wow.exe"); if (processes.Length == 0) { if(Properties.Settings.Default.lang=="Русский") MessageBox.Show(_count < 2 ? "Не обнаружен подходящий вов\nИли программа запущена без админских прав" : "Ты што сука совсем еблан?"); else MessageBox.Show(_count < 2 ? "Cant find any WoW\nOr launched without admin rigts" : "Are you stupid?"); _count++; return; } accountGrid.Refresh(); bool ret = false; _accounts = new Account[processes.Length]; for (int i = 0; i < processes.Length; i++) { //EmptyWorkingSet(processes[i].Handle); Config.Memory = new Memory(processes[i].Id); Config.baseAddressModule = Memory.GetModule(processes[i].Id, "Wow.exe"); if (Config.Memory.ReadInt(Config.baseAddressModule + Offset.GameState)==1) { ret = true; } if (ret) { var pName = Config.Memory.ReadString(Config.baseAddressModule + Offset.PlayerName,30); var pRealm =Config.Memory.ReadString(Config.baseAddressModule + Offset.Realm,30); var pGold = Config.Memory.ReadInt((int)Config.Memory.ReadUInt(ObjectManager.ObjectManager.getPlayerBase() + 0xC) + Offset.Gold) / 10000; var pFaction = ObjectManager.ObjectManager.PlayerFaction; _accounts[i] = new Account(pName.Split('\0')[0], pRealm.Split('\0')[0], pGold, pFaction); _account++; } } if (_account != 0) { _dataBase = new DB(_accounts,accountGrid); _dataBase.FillTable(); } }
protected void buttonAccountE_OnClick(object sender, EventArgs e) { if (String.IsNullOrEmpty(tbNameE.Text) || String.IsNullOrEmpty(tbAddressE.Text) || String.IsNullOrEmpty(tbPostalE.Text) || String.IsNullOrEmpty(tbEmailE.Text)) { Utils.displayStatus(ref labelStatus, Color.Red, Lang.Account_update_failed + ". " + Lang.MissingInformation); return; } if (!Utils.isValidEmail(tbEmailE.Text)) { Utils.displayStatus(ref labelStatus, Color.Red, Lang.Email_invalid_address); return; } try { MembershipUser User = Membership.GetUser(HttpContext.Current.User.Identity.Name); object UserGUID = User.ProviderUserKey; Database.Interface.open(); if (tbNameE.Text.ToLower() != hiddenName.Value.ToLower()) { if (Database.Account.accountNameExists(tbNameE.Text)) { Utils.displayStatus(ref labelStatus, Color.Red, Lang.The_name + " '" + tbNameE.Text + "' " + Lang.already_exists); return; } } Database.Account account = new Database.Account(); if (!account.select_all_where_ID((Guid)UserGUID)) { Utils.reportStatus(ref labelStatus, Color.Red, "Account.buttonAccountE_OnClick: " + Lang.Account + " '" + HttpContext.Current.User.Identity.Name + "' " + Lang.not_found); return; } account.Name = tbNameE.Text; account.Contact = tbContactE.Text; account.Address = tbAddressE.Text; account.Postbox = "Field not active"; account.Postal = tbPostalE.Text; account.Email = tbEmailE.Text; account.Phone = tbPhoneE.Text; account.Mobile = tbMobileE.Text; account.Fax = tbFaxE.Text; account.Website = tbWebsiteE.Text; if (account.update_all_by_ID()) { hiddenName.Value = tbNameE.Text; Utils.displayStatus(ref labelStatus, Color.SeaGreen, Lang.Account_update + " " + Lang.success); } else { Utils.reportStatus(ref labelStatus, Color.Red, "Account.buttonAccountE_OnClick: " + Lang.Account_update + " '" + HttpContext.Current.User.Identity.Name + "' " + Lang.failed); } } catch (Exception ex) { Utils.reportStatus(ref labelStatus, Color.Red, "Account.buttonAccountE_OnClick: " + ex.Message); } finally { Database.Interface.close(); } }
protected void buttonCreateAccount_OnClick(object sender, EventArgs e) { bool accountCreated = false; Database.Account account = null; if (String.IsNullOrEmpty(tbUserName.Text) || String.IsNullOrEmpty(tbPassword.Text) || String.IsNullOrEmpty(tbEmail.Text) || String.IsNullOrEmpty(tbName.Text) || String.IsNullOrEmpty(tbAddress.Text) || String.IsNullOrEmpty(tbPostal.Text)) { Utils.displayStatus(ref labelStatusCreate, Color.Red, "Mangler informasjon"); return; } if (!Utils.isValidEmail(tbEmail.Text)) { Utils.displayStatus(ref labelStatusCreate, Color.Red, "Epost adresse har ugyldig format"); return; } if (tbPassword.Text.Length < Membership.MinRequiredPasswordLength) { Utils.displayStatus(ref labelStatusCreate, Color.Red, "Passordet må ha minst " + Membership.MinRequiredPasswordLength.ToString() + " tegn"); return; } if (tbPassword.Text != tbConfirmPassword.Text) { Utils.displayStatus(ref labelStatusCreate, Color.Red, "Passordene er ikke like"); return; } if (String.IsNullOrEmpty(ConfigurationManager.AppSettings["MailServer"]) || String.IsNullOrEmpty(ConfigurationManager.AppSettings["MailServerPort"])) { Utils.displayStatus(ref labelStatusCreate, Color.Red, "Innstillinger for mailserver mangler"); return; } Database.Configuration configuration = new Database.Configuration(); try { Membership.ApplicationName = "/Lorakon"; Database.Interface.open(); if (!configuration.select_all_where_name("Default")) { Utils.displayStatus(ref labelStatusCreate, Color.Red, "Finner ikke konfigurasjon"); return; } if (Database.Account.accountNameExists(tbName.Text)) { Utils.displayStatus(ref labelStatusCreate, Color.Red, "Navnet " + tbName.Text + " finnes allerede"); Membership.ApplicationName = "/LorakonAdmin"; return; } MembershipCreateStatus status = new MembershipCreateStatus(); MembershipUser user = Membership.CreateUser(tbUserName.Text, tbPassword.Text, tbEmail.Text, "question", "answer", true, out status); if (user == null) { Utils.displayStatus(ref labelStatusCreate, Color.Red, Utils.getErrorMessage(status)); Membership.ApplicationName = "/LorakonAdmin"; return; } account = new Database.Account( Guid.Empty, tbName.Text, tbContact.Text, tbAddress.Text, "Field not active", tbPostal.Text, tbEmail.Text, tbPhone.Text, tbMobile.Text, tbFax.Text, tbWebsite.Text, true, "", 0, 0, ""); accountCreated = account.insert_with_ID((Guid)user.ProviderUserKey); if (!String.IsNullOrEmpty(hiddenPendingUser.Value) && hiddenPendingUser.Value != Guid.Empty.ToString()) { Database.PendingAccount pendingAccount = new Database.PendingAccount(); if (pendingAccount.select_all_where_ID(new Guid(hiddenPendingUser.Value))) { pendingAccount.delete_by_ID(); } } ddUsers.DataBind(); ddAccountsA.DataBind(); } catch (Exception ex) { Membership.DeleteUser(tbUserName.Text); if (accountCreated) { account.delete_by_ID(); } Utils.displayStatus(ref labelStatusCreate, Color.Red, ex.Message); return; } finally { Database.Interface.close(); Membership.ApplicationName = "/LorakonAdmin"; } string userName = tbUserName.Text; string receip = tbEmail.Text; string mailTitle = "Ny LORAKON konto tildelt"; string mailBody = @"Velkommen som bruker av LORAKON nettjenester.<br> Hver bedrift får kun tildelt ett brukernavn og passord. Dersom bedriften har flere ansatte som skal være delaktige i nettverket må brukernavnet og passordet deles mellom disse.<br> Deres bedrift har fått tildelt følgende brukernavn: " + tbUserName.Text + " og passord: " + tbPassword.Text + @".<br> For å logge inn på sidene kan følgende lenke benyttes: <a href='" + ConfigurationManager.AppSettings["LorakonURL"] + "'>" + ConfigurationManager.AppSettings["LorakonURL"] + @"</a><br> NB! Brukernavnet er låst, men brukeren kan selv endre passordet ved behov via siden 'Bedriftens konto'<br><br> Hilsen Statens Strålevern"; clearAllCreateFields(); ddPendingUsers.DataBind(); ddUsers.DataBind(); ddAccountsA.DataBind(); if (ConfigurationManager.AppSettings["UseEmail"] == "yes") { try { MailMessage mail = new MailMessage(); mail.To.Add(receip); mail.From = new MailAddress(configuration.RingtestAdminEmail); mail.IsBodyHtml = true; mail.BodyEncoding = System.Text.Encoding.Default; mail.Subject = mailTitle; mail.Body = mailBody; SmtpClient smtp = new SmtpClient(ConfigurationManager.AppSettings["MailServer"], Convert.ToInt32(ConfigurationManager.AppSettings["MailServerPort"])); smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.Send(mail); Utils.displayStatus(ref labelStatusCreate, Color.SeaGreen, "Bruker " + userName + " ble opprettet, og e-post er sendt til " + receip); } catch (Exception ex) { Utils.displayStatus(ref labelStatusCreate, Color.Red, ex.Message); } } }
protected void buttonSendMessage_OnClick(object sender, EventArgs e) { if (ConfigurationManager.AppSettings["UseEmail"] != "yes") { Utils.displayStatus(ref labelStatusMessage, Color.Red, "Sending av epost er deaktivert"); return; } if (String.IsNullOrEmpty(tbMessage.Text)) { Utils.displayStatus(ref labelStatusMessage, Color.Red, Lang.Missing_fields); return; } try { Database.Interface.open(); Database.Configuration configuration = new Database.Configuration(); if (!configuration.select_all_where_name("Default")) { Utils.displayStatus(ref labelStatusMessage, Color.Red, Lang.Configuration + " " + Lang.not_found); return; } Database.Account account = new Database.Account(); if (!account.select_all_where_ID(new Guid(hiddenAccountID.Value))) { Utils.reportStatus(ref labelStatusMessage, Color.Red, "Ringtest.buttonSendMessage_OnClick: account.select_all_where_ID failed"); return; } if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["MailServer"]) && !String.IsNullOrEmpty(ConfigurationManager.AppSettings["MailServerPort"])) { string mailTitle = "Forespørsel fra LORAKON konto " + account.Name + "(" + account.Email + ")"; string mailBody = tbMessage.Text; MailMessage mail = new MailMessage(); mail.To.Add(configuration.RingtestAdminEmail); mail.From = new MailAddress(configuration.RingtestAdminEmail); mail.BodyEncoding = System.Text.Encoding.Default; mail.IsBodyHtml = true; mail.Subject = mailTitle; mail.Body = mailBody; SmtpClient smtp = new SmtpClient(ConfigurationManager.AppSettings["MailServer"], Convert.ToInt32(ConfigurationManager.AppSettings["MailServerPort"])); smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.Send(mail); Utils.displayStatus(ref labelStatusMessage, Color.SeaGreen, Lang.Message_sent); } else { Utils.displayStatus(ref labelStatusMessage, Color.Red, Lang.Email_no_server); } tbMessage.Text = ""; } catch (Exception ex) { Utils.displayStatus(ref labelStatusMessage, Color.Red, "Ringtest.buttonSendMessage_OnClick: " + ex.Message); } finally { Database.Interface.close(); } }
protected void buttonAccountE_OnClick(object sender, EventArgs e) { if (ddUsers.SelectedValue == Guid.Empty.ToString()) { Utils.displayStatus(ref labelStatusEdit, Color.Red, "Du må velge en konto først"); return; } if (String.IsNullOrEmpty(tbUserNameE.Text) || String.IsNullOrEmpty(tbEmailE.Text) || String.IsNullOrEmpty(tbNameE.Text) || String.IsNullOrEmpty(tbAddressE.Text) || String.IsNullOrEmpty(tbPostalE.Text)) { Utils.displayStatus(ref labelStatusEdit, Color.Red, "Mangler informasjon"); return; } try { Database.Interface.open(); // Sjekk at konto ikke er oppmeldt til ringtest eller kurs hvis active er false if (!cbActiveE.Checked) { Database.Interface.command.Parameters.Clear(); Database.Interface.command.CommandText = @" SELECT COUNT(Contact.ID) FROM Contact, Course, Contact_Course WHERE Course.bitCompleted = 0 AND Contact.AccountID = @accountID AND Contact.ID = Contact_Course.ContactID AND Course.ID = Contact_Course.CourseID"; Database.Interface.command.CommandType = CommandType.Text; Database.Interface.command.Parameters.AddWithValue("@accountID", new Guid(ddUsers.SelectedValue)); int count = (int)Database.Interface.command.ExecuteScalar(); if (count > 0) { Utils.displayStatus(ref labelStatusEdit, Color.Red, "Kan ikke sette konto til deaktivert. Kontoen er oppmeldt til en eller flere kurs"); return; } Database.Interface.command.Parameters.Clear(); Database.Interface.command.CommandText = @" SELECT COUNT(RingtestReport.ID) FROM RingtestReport WHERE RingtestReport.bitApproved = 0 AND RingtestReport.AccountID = @accountID"; Database.Interface.command.CommandType = CommandType.Text; Database.Interface.command.Parameters.AddWithValue("@accountID", new Guid(ddUsers.SelectedValue)); count = (int)Database.Interface.command.ExecuteScalar(); if (count > 0) { Utils.displayStatus(ref labelStatusEdit, Color.Red, "Kan ikke sette konto til deaktivert. Kontoen har en eller flere uferdige ringtest rapporter"); return; } Database.Interface.command.Parameters.Clear(); } if (tbNameE.Text.ToLower() != hiddenName.Value.ToLower()) { if (Database.Account.accountNameExists(tbNameE.Text)) { Utils.displayStatus(ref labelStatusEdit, Color.Red, "Navnet " + tbNameE.Text + " finnes allerede"); return; } } Database.Account account = new Database.Account(); account.select_all_where_ID(new Guid(ddUsers.SelectedValue)); account.Name = tbNameE.Text; account.Contact = tbContactE.Text; account.Address = tbAddressE.Text; account.Postbox = "Field not active"; account.Postal = tbPostalE.Text; account.Email = tbEmailE.Text; account.Phone = tbPhoneE.Text; account.Mobile = tbMobileE.Text; account.Fax = tbFaxE.Text; account.Website = tbWebsiteE.Text; account.Active = cbActiveE.Checked; account.Comment = tbCommentE.Text; //account.LastRegistrationYear = Convert.ToInt32(tbLastRegistrationE.Text); //account.RingtestCount = Convert.ToInt32(tbRingtestCountE.Text); if (account.update_all_by_ID()) { Utils.displayStatus(ref labelStatusEdit, Color.SeaGreen, "Konto '" + account.Name + "' oppdatert"); hiddenName.Value = tbNameE.Text; } else { Utils.displayStatus(ref labelStatusEdit, Color.Red, "Oppdatering av konto feilet"); } } catch (Exception ex) { Utils.displayStatus(ref labelStatusEdit, Color.Red, ex.Message); } finally { Database.Interface.close(); } }
public void Add(Account Acc,int Size) { _db.Add(Acc); }
protected void initializePage() { bool ringtestExists = false; bool hasStarted = false; try { Database.Interface.open(); Database.Configuration configuration = new Database.Configuration(); if (!configuration.select_all_where_name("Default")) { Utils.reportStatus(ref labelStatus, Color.Red, "Ringtest.initializePage: Configuration not found"); return; } Database.Ringtest ringtest = new Database.Ringtest(); if (ringtest.select_all_where_year(DateTime.Now.Year)) { ringtestExists = true; if (DateTime.Now >= ringtest.StartDate) { hasStarted = true; } if (hasStarted && ringtest.Finished) { multiViewRingtest.SetActiveView(viewFinished); return; } } Database.Account account = new Database.Account(); if (!account.select_all_where_ID(new Guid(hiddenAccountID.Value))) { Utils.reportStatus(ref labelStatus, Color.Red, "Ringtest.initializePage: Account not found"); return; } if (account.LastRegistrationYear != DateTime.Now.Year) { if (hasStarted) { // send info to admin multiViewRingtest.SetActiveView(viewSendMessage); labelSendMessage.Text = Lang.RingtestAlreadyStarted; } else { multiViewRingtest.SetActiveView(viewRegister); labelRegister.Text = Lang.RingtestAccountNotRegistered; } return; } if (hasStarted) { hiddenRingtestID.Value = ringtest.ID.ToString(); } else { multiViewRingtest.SetActiveView(viewNoInit); if (ringtestExists) { labelInit.Text = Lang.RingtestNotStarted + " " + ringtest.StartDate.ToShortDateString(); } else { labelInit.Text = Lang.RingtestDateNotDetermined; } return; } if (account.RingtestBoxID == Guid.Empty) { multiViewRingtest.SetActiveView(viewSendMessage); labelSendMessage.Text = Lang.RingtestAccountBoxNotAssigned; return; } hiddenRingtestBoxID.Value = account.RingtestBoxID.ToString(); Database.DeviceCategory category = new Database.DeviceCategory(); if (!category.select_all_where_name("Detektor")) { multiViewRingtest.SetActiveView(viewNoInit); labelInit.Text = Lang.DatabaseError; Utils.reportStatus(ref labelStatus, Color.Red, "Ringtest.initializePage: Category 'Detektor' not found"); return; } List <Database.Identifiers> idList = new List <Database.Identifiers>(); if (!Database.Device.select_identifiers_where_accountID_categoryID_status(account.ID, category.ID, "Ok", ref idList)) { multiViewRingtest.SetActiveView(viewNoInit); labelInit.Text = Lang.RingtestNoDetectors1 + " " + account.Name + Lang.RingtestNoDetectors2 + " " + configuration.RingtestAdminEmail + " " + Lang.RingtestNoDetectors3; return; } ddDetector.Items.Add(new ListItem("---", Guid.Empty.ToString())); foreach (Database.Identifiers ids in idList) { ddDetector.Items.Add(new ListItem(ids.Name, ids.ID.ToString())); } } catch (Exception ex) { Utils.reportStatus(ref labelStatus, Color.Red, "Ringtest.initializePage: " + ex.Message); } finally { Database.Interface.close(); } multiViewRingtest.SetActiveView(viewSelectDetector); }