public static void Main() { var author = new Author(); var firstReader = new Reader(author); var secondReader = new Reader(author); var thirdReader = new Reader(author); author.Add(firstReader); author.Add(secondReader); author.Add(thirdReader); author.SetState("C# via CLR 4th edition"); author.Notify(); }
protected void Bt_register_Click(object sender, EventArgs e) { if (Page.IsValid) { Hashtable ht = new Hashtable(); ht.Add("authorID", SQLString.GetQuotedString(txtID.Text)); ht.Add("authorPwd", SQLString.GetQuotedString(txtPwd.Text)); ht.Add("authorName", SQLString.GetQuotedString(txtName.Text)); ht.Add("authorSex", SQLString.GetQuotedString(rblSex.SelectedValue)); ht.Add("authorBirth", SQLString.GetQuotedString(txtBirth.Text)); ht.Add("authorRegion", SQLString.GetQuotedString(txtRegion.Text)); ht.Add("authorPost", SQLString.GetQuotedString(TxtPostcode.Text)); ht.Add("authorMail", SQLString.GetQuotedString(txtMail.Text)); ht.Add("authorDegree", SQLString.GetQuotedString(dddlDegree.SelectedValue)); ht.Add("authorMajor", SQLString.GetQuotedString(txtMajor.Text)); ht.Add("authorTitle", SQLString.GetQuotedString(txtTitle.Text)); ht.Add("authorJob", SQLString.GetQuotedString(txtJob.Text)); ht.Add("authorCompany", SQLString.GetQuotedString(txtCompany.Text)); ht.Add("authorPhone", SQLString.GetQuotedString(txtPhone.Text)); ht.Add("authorAddress", SQLString.GetQuotedString(txtAddress.Text)); ht.Add("authorInfo", SQLString.GetQuotedString(txtInfo.Text)); Author author = new Author(); if (author.Add(ht)) { Response.Write("<script>alert('注册成功!');window.location='login.aspx';</script>"); } else { Response.Write("<Script Language=JavaScript>alert(\"注册失败!\")</Script>"); } } }
public Bookform() { InitializeComponent(); MySqlConnection Con = new MySqlConnection(library); MySqlCommand SelectCommand = new MySqlCommand("SELECT * FROM books", Con); idthing.Visible = false; try { Con.Open(); using (MySqlDataReader myReader = SelectCommand.ExecuteReader()) { while (myReader.Read()) { Author.Add(myReader.GetString("author")); codiwign.Add(myReader.GetString("isbn")); fasi.Add(myReader.GetString("price")); satauri.Add(myReader.GetString("title")); id.Add(myReader.GetString("id")); comboBox1.Items.Add(myReader.GetString("title")); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void Post([FromBody] Author author) { try { IAdd authorDetail = new Author(); authorDetail.Add(author); } catch (Exception ex) { _logger.LogError(string.Format("AuthorController => POST Error Occured at: {0}{1}Error Details: {2}", DateTime.Now, Environment.NewLine, ex.InnerException.Message)); } }
private void Submit_btn_Click(object sender, EventArgs e) { Author a = new Author(); a.Name = Name_TB.Text; a.Address = Address_TB.Text; a.Birthdate = dateTimePicker1.Value.Date; if (a.Name == "") { MessageBox.Show("Name Cannot be empty!"); } else { a.Add(); this.Close(); } }
async Task ExecuteLoadAuthorsCommand() { IsBusy = true; try { Author.Clear(); var _authors = await AuthorDataStore.GetItemsAsync(true); foreach (var _author in _authors) { Author.Add(_author); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
private void Add_Click_Func(bool is_edit) { name = (tb_name.Text.Trim()).Replace('\'', ' '); country = (tb_country.Text.Trim()).Replace('\'', ' '); year = dtp_author.Value.Year.ToString(); biography = tb_biography.Text.Replace('\'', ' '); pic_new_source_path = picture_event.Pic_source_file; lbl_message.Text = ""; if (tb_name.Text.Trim() == "Name" || tb_name.Text.Trim() == "") { lbl_message.Text = "* Please enter name."; lbl_message.ForeColor = Color.Red; tb_name.Focus(); return; } if (tb_country.Text.Trim() == "Country" || tb_country.Text.Trim() == "") { lbl_message.Text = "* Please country name."; lbl_message.ForeColor = Color.Red; tb_country.Focus(); return; } if (dtp_author.Text.Trim() == "Year" || dtp_author.Text.Trim() == "") { lbl_message.Text = "* Please enter birth year."; lbl_message.ForeColor = Color.Red; dtp_author.Focus(); return; } if (tb_biography.Text.Trim() == "Biography..." || tb_biography.Text.Trim() == "") { lbl_message.Text = "* Please enter biography."; lbl_message.ForeColor = Color.Red; tb_biography.Focus(); return; } if (rdo_male.Checked) { gender = "Male"; } else if (rdo_female.Checked) { gender = "Female"; } else { lbl_message.Text = "* Please select gender"; lbl_message.ForeColor = Color.Red; return; } if (is_edit == false) { /* IMPORTANT */ if (picture_event.Pic_source_file != null && picture_event.Pic_source_file != pic_default_file) { picture_event.Copy_The_Picture(name); pic_new_source_path = picture_event.Pic_source_file; } else { pic_new_source_path = pic_default_file; } Author author = new Author(0, 0, name, country, gender, year, biography, pic_new_source_path); author.Add(); Clear(); } else { if (change_image) { /* IMPORTANT */ if (author_to_edit.Author_cover_path_file != pic_default_file) { Picture_Events.Delete_The_Picture(author_to_edit.Author_cover_path_file); } picture_event.Copy_The_Picture(name); pic_new_source_path = picture_event.Pic_source_file; change_image = false; } lbl_message.Text = "*Author changed successfully"; lbl_message.ForeColor = Color.LightGreen; author_to_edit.Author_name = name; author_to_edit.Author_country = country; author_to_edit.Author_gender = gender; author_to_edit.Author_birthday = year; author_to_edit.Author_biography = biography; author_to_edit.Author_cover_path_file = pic_new_source_path; author_to_edit.Edit(); main_page.Pnl_author_list.VerticalScroll.Value = 0; main_page.Author_search_list.Delete_All_List(); main_page.Main_author_list.Hide_All_Author_Objects(); main_page.Main_author_list.Draw_All_Authors(); main_page.Author_searched_already = false; main_page.Main_book_list.Delete_All_List(); Book.Show_All_Books(main_page); } }
protected void EBtnSubmit_Click(object sender, EventArgs e) { if (!this.Page.IsValid) { return; } AuthorInfo ainfo = new AuthorInfo(); ainfo.Id = (this.ViewState["AuthorId"] == null) ? 0 : DataConverter.CLng(this.ViewState["AuthorId"].ToString()); if (!string.IsNullOrEmpty(this.TxtUserName.Text)) { ainfo.UserId = Author.GetUserId(this.TxtUserName.Text); } ainfo.Type = this.RadlAuthorType.SelectedValue; ainfo.Name = this.TxtName.Text; ainfo.Passed = Convert.ToBoolean(this.ChkPass.Checked); ainfo.OnTop = Convert.ToBoolean(this.ChkOnTop.Checked); ainfo.Elite = Convert.ToBoolean(this.ChkElite.Checked); ainfo.Hits = 0; ainfo.LastUseTime = DateTime.Now; ainfo.Photo = this.ExtenFileUpload.FilePath; ainfo.Intro = this.TxtIntro.Text; ainfo.Address = this.TxtAddress.Text; ainfo.Tel = this.TxtTel.Text; ainfo.Fax = this.TxtFax.Text; ainfo.Mail = this.TxtMail.Text; ainfo.Email = this.TxtEmail.Text; ainfo.ZipCode = DataConverter.CLng(this.TxtZipCode.Text); ainfo.HomePage = this.TxtHomePage.Text; ainfo.Imeeting = this.TxtIm.Text; ainfo.Sex = DataConverter.CLng(this.RadlSex.Text); ainfo.BirthDay = DataConverter.CDate(this.TxtBirthDay.Text); ainfo.Company = this.TxtCompany.Text; ainfo.Department = this.TxtDepartment.Text; bool flag = false; string str = this.ViewState["action"].ToString(); if (str != null) { if (!(str == "add")) { if (str == "modify") { flag = Author.Update(ainfo); goto Label_0236; } } else { flag = Author.Add(ainfo); goto Label_0236; } } flag = Author.Add(ainfo); Label_0236: if (flag) { if (this.ViewState["action"].ToString() == "add") { base.Response.Write("<script type='text/javascript'>parent.frames[\"left\"].location.reload();</script>"); AdminPage.WriteSuccessMsg("添加作者成功!", "AuthorManage.aspx"); return; } base.Response.Write("<script type='text/javascript'>parent.frames[\"left\"].location.reload();</script>"); AdminPage.WriteSuccessMsg("修改作者成功!", "AuthorManage.aspx"); } else { AdminPage.WriteErrMsg("操作失败!", "AuthorManage.aspx"); } }
public RedirectToRouteResult Store(Author authorObj) { Author.Add(TempData["author"] as Author); return(RedirectToAction("Index", "Authors")); }
/// <summary> /// loads the information of a book from an online source /// </summary> public Book AutoLoadDNB(string isbn) { Book book = new Book(); book.BookIsbn = isbn; if (IsbnValidated(isbn)) { htmlData = Regex.Replace(htmlData, @"\t|\n|\r", ""); htmlData = Regex.Replace(htmlData, "<a href=.*?>", ""); var genreName = GetGenreNeu().Replace("[", "(").Replace("]", ")"); if (!genreName.Equals("")) { GenreHelper helper = new GenreHelper(); Genre genre = new Genre(); if (helper.FindIdByName(genreName) < 0) { genre.GenreName = genreName; genre.Add(); } genre = new Genre(helper.FindIdByName(genreName)); book.BookGenre = genre; } var titel = GetTitelNeu().Replace("[", "(").Replace("]", ")"); if (!titel.Equals("")) { book.BookTitle = titel; } var authors = GetAutorNeu(); foreach (string s in authors) { Author author = new Author(); AuthorHelper helper = new AuthorHelper(); if (helper.FindIdByName(s) < 0) { author.AuthorName = s; author.Add(); } author = new Author(helper.FindIdByName(s)); book.BookAuthors.Add(author); } var ausgabe = GetAusgabeNeu().Replace("[", "(").Replace("]", ")"); if (!ausgabe.Equals("")) { book.BookEdition = ausgabe; } var publisherName = GetVerlagNeu().Replace("[", "(").Replace("]", ")"); if (!publisherName.Equals("")) { PublisherHelper helper = new PublisherHelper(); Publisher publisher = new Publisher(); if (helper.FindIdByName(publisherName) < 0) { publisher.PublisherName = publisherName; publisher.Add(); } publisher = new Publisher(helper.FindIdByName(publisherName)); book.BookPublisher = publisher; } var jahr = GetDatumNeu(); if (!jahr.Equals("")) { try { DateTime date = new DateTime(int.Parse(jahr), 1, 1); book.BookDatePublication = date; } catch { book.BookDatePublication = DateTime.UtcNow; } } var preis = GetPreisNeu().Replace('.', ','); if (!preis.Equals("")) { book.BookPrice = decimal.Parse(preis); } var languageName = GetSpracheNeu().Replace("[", "(").Replace("]", ")"); if (!languageName.Equals("")) { LanguageHelper helper = new LanguageHelper(); Language language = new Language(); if (helper.FindIdByName(languageName) < 0) { language.LanguageName = languageName; language.Add(); } language = new Language(helper.FindIdByName(languageName)); book.BookLanguage = language; } var image = GetPictureNeu(isbn); if (image != null) { book.BookImage = image; } return(book); //MetroMessageBox.Show(this, "Das Buch \"" + tb_Titel.Text + "\" wurde erfolgreich geladen!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { return(book); //AutoLoadBuecherNachISBN(); } }
public Book(string title, Author author) { this.Title = title; this.TheAuthor = author; TheAuthor.Add(this); }
public int Add(Author author) { Author.Add(author); return(SaveChanges()); }