예제 #1
0
 public int InsertAuthor(DTO_Author author)
 {
     if (author.Author_name.Contains("'"))
     {
         author.Author_name = checkString(author.Author_name);
     }
     return(authorDAO.Insert(author));
 }
예제 #2
0
 public int UpdateAuthor(DTO_Author author)
 {
     try
     {
         if (author.Author_name.Contains("'"))
         {
             author.Author_name = checkString(author.Author_name);
         }
         return(authorDAO.Update(author));
     }
     catch (Exception)
     {
         return(-1);
     }
 }
예제 #3
0
 private void btnSeach_Click(object sender, EventArgs e)
 {
     if (txtAuthorID.Text != "")
     {
         DTO_Author dto_author = new DTO_Author();
         String     id         = txtAuthorID.Text;
         dto_author = bus_author.SearchAuthor("author_id", txtAuthorID.Text);
         if (dto_author != null)
         {
             txtAuthorName.Text = dto_author.Author_name;
         }
         else
         {
             MessageBox.Show("Không tìm thấy!");
             txtAuthorID.Text = "";
         }
     }
     else
     {
         MessageBox.Show("Hãy nhập mã sách cần tìm!");
     }
 }
예제 #4
0
        private DTO_Project ReadCofFile(string fullPath)
        {
            try
            {
                DTO_Project result = new DTO_Project();

                XDocument data = FileBusiness.XmlHandler.readFromFile(fullPath, BusinessLogic.Config.XML_KEY_COF_HEAD);

                // OVERVIEW INFO =============================================
                var overview = data.Root.Element(XName.Get(BusinessLogic.Config.XML_KEY_COF_HEAD));
                result.ProjectName = overview.Element(XName.Get(BusinessLogic.Config.XML_KEY_COF_ATTRIBUTE_PROJECT_NAME)).Value;
                result.Desc        = overview.Value;

                // GROUP INFO ================================================
                var group = data.Root.Element(XName.Get(BusinessLogic.Config.XML_KEY_COF_GROUP));
                result.GroupName = group.Attribute(XName.Get(BusinessLogic.Config.XML_KEY_COF_GROUP_ATTRIBUTE_NAME)).Value;
                foreach (var author in group.Elements(XName.Get(BusinessLogic.Config.XML_KEY_COF_AUTHOR)))
                {
                    DTO_Author dtoAuthor = new DTO_Author();
                    dtoAuthor.Name           = author.Attribute(XName.Get(BusinessLogic.Config.XML_KEY_COF_AUTHOR_ATTRIBUTE_NAME)).Value;
                    dtoAuthor.AdditionalInfo = author.Value;
                    result.Authors.Add(dtoAuthor);
                }

                // NOTES =====================================================
                var notes = data.Root.Element(XName.Get(BusinessLogic.Config.XML_KEY_COF_NOTES));
                foreach (var noteDetail in notes.Elements(XName.Get(BusinessLogic.Config.XML_KEY_COF_NOTE_DETAIL)))
                {
                    result.Notes.Add(noteDetail.Value);
                }

                return(result);
            }
            catch (Exception)
            {
                return(null);
            }
        }
예제 #5
0
        private void btnAddAuthor_Click(object sender, EventArgs e)
        {
            if (checkNull())
            {
                DTO_Author b = new DTO_Author();
                b.Author_id   = int.Parse(txtAuthorID.Text);
                b.Author_name = txtAuthorName.Text;

                if (bus_author.InsertAuthor(b) == 1)
                {
                    MessageBox.Show("Thành công");
                    frmAuthor_Load(sender, e);
                }
                else
                {
                    MessageBox.Show("Không thành công");
                }
            }
            else
            {
                MessageBox.Show("Hãy nhập đủ thông tin");
            }
        }
예제 #6
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     if (checkNull())
     {
         DTO_Author b = new DTO_Author();
         b.Author_id   = int.Parse(id);
         b.Author_name = txtAuthorName.Text;
         if (bus_author.UpdateAuthor(b) == 1)
         {
             MessageBox.Show("Thành công");
             frmAuthor_Load(sender, e);
             txtAuthorID.Text   = "";
             txtAuthorName.Text = "";
         }
         else
         {
             MessageBox.Show("Không thành công");
         }
     }
     else
     {
         MessageBox.Show("Hãy điển đủ thông tin!");
     }
 }
예제 #7
0
        public int Update(DTO_Author author)
        {
            string sql = "UPDATE Author SET author_name = '" + author.Author_name + "' WHERE author_id = '" + author.Author_id + "';";

            return(this.ExecuteNonQuery(sql));
        }
예제 #8
0
        public int Insert(DTO_Author author)
        {
            string sql = "INSERT INTO Author(author_id, author_name) VALUES('" + author.Author_id + "','" + author.Author_name + "');";

            return(this.ExecuteNonQuery(sql));
        }