当前位置: 首页>>代码示例>>C#>>正文


C# DBHelper.dbUpdate方法代码示例

本文整理汇总了C#中DBHelper.dbUpdate方法的典型用法代码示例。如果您正苦于以下问题:C# DBHelper.dbUpdate方法的具体用法?C# DBHelper.dbUpdate怎么用?C# DBHelper.dbUpdate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBHelper的用法示例。


在下文中一共展示了DBHelper.dbUpdate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: button2_Click_1

        private void button2_Click_1(object sender, EventArgs e)
        {
            DBHelper db = new DBHelper();
            String Query = "Update patron SET Last_Name = '" + this.editlnamebox.Text + "',First_Name = '" + this.editfnamebox.Text + "',Email = '" + this.editemailbox.Text + "',Address = '" + this.editaddressbox.Text + "',City = '" + editcitybox.Text + "',State = '" + this.editstatebox.Text + "',Telephone = '" + this.editphonebox.Text + "' WHERE patron_ID = '" + editpatronbox.Text + "';";
            db.dbUpdate(Query);
            this.editlnamebox.Text = String.Empty;
            this.editfnamebox.Text = String.Empty;
            this.editemailbox.Text = String.Empty;
            this.editphonebox.Text = String.Empty;
            this.editaddressbox.Text = String.Empty;
            this.editcitybox.Text = String.Empty;
            this.editstatebox.Text = String.Empty;
            this.editpatronbox.Text = String.Empty;

            MessageBox.Show("Update for patron " + editpatronbox.Text + " updated.");
        }
开发者ID:rjosefsberg,项目名称:Library-Project,代码行数:16,代码来源:LibraryGUI.cs

示例2: button2_Click

 private void button2_Click(object sender, EventArgs e)
 {
     String sISBN = removebookbox.Text;
     if (sISBN.Length != 13)
     {
         MessageBox.Show("Incorrect Length for ISBN");
     }
     else
     {
         String dbString = "Delete from books where ISBN = " + sISBN + ";";
         DBHelper db = new DBHelper();
         db.dbUpdate(dbString);
         MessageBox.Show("Book removed from database.");
         removebookbox.Text = String.Empty;
     }
 }
开发者ID:rjosefsberg,项目名称:Library-Project,代码行数:16,代码来源:LibraryGUI.cs

示例3: SaveandExit_Click

        private void SaveandExit_Click(object sender, EventArgs e)
        {
            String ISBN = addbookisbnbox.Text;
            String title = addbooktitlebox.Text;
            String authorLast = addbookauthorlast.Text;
            String authorFirst = addbookauthorfirst.Text;
            String pubDate = pubdatebox.Text;
            String shelfID = addbookshelfidbox.Text;

            if (ISBN.Length != 13)
            {
                MessageBox.Show("Incorrect length for ISBN (13)");
            }
            else
            {
                DBHelper db = new DBHelper();
                String dbString = "INSERT INTO Books(ISBN,Title,Author_Lastname,Author_Firstname,Publication_Date,Shelf_ID,Checked_Out,Out_Date, Due_Date) "+
                  "VALUES (" + ISBN + ",'" + title + "','" + authorLast + "','" + authorFirst + "','" + pubDate + "','" + shelfID + "', 'N',null,null);";

                db.dbUpdate(dbString);
                MessageBox.Show("Book " + title + " added successfully");
                this.Close();
            }
        }
开发者ID:rjosefsberg,项目名称:Library-Project,代码行数:24,代码来源:addbookpop.cs

示例4: button5_Click

 private void button5_Click(object sender, EventArgs e)
 {
     String sISBN = checkinbox.Text;
     if (sISBN.Length != 13)
     {
         MessageBox.Show("Incorrect length for ISBN (13)");
     }
     else
     {
         String dbString = "Update books SET Checked_Out = 'N', Out_Date = null, Due_Date = null, By_patron = null WHERE ISBN = " + sISBN + ";";
         DBHelper db = new DBHelper();
         db.dbUpdate(dbString);
         MessageBox.Show("Check in successful.");
         checkinbox.Text = String.Empty;
     }
 }
开发者ID:rjosefsberg,项目名称:Library-Project,代码行数:16,代码来源:LibraryGUI.cs

示例5: removepatronbutton_Click

        private void removepatronbutton_Click(object sender, EventArgs e)
        {
            DBHelper db = new DBHelper();
            String sPatron_ID = RemovePatronBox.Text;
            if (sPatron_ID.Length != 5)
            {
                MessageBox.Show("Incorrect Length for Patron ID");
            }

            else
            {
                String dbString = "UPDATE patron SET Inactive = TRUE where Patron_ID = " + sPatron_ID + ";";
                db.dbUpdate(dbString);
                MessageBox.Show("Patron "+sPatron_ID+" set to Inactive");
            }
        }
开发者ID:rjosefsberg,项目名称:Library-Project,代码行数:16,代码来源:LibraryGUI.cs

示例6: patronadd_Click

        private void patronadd_Click(object sender, EventArgs e)
        {
            DBHelper db = new DBHelper();
            MySqlDataReader myReader = null;
            MySqlConnection myConnection = new MySqlConnection("Server = localhost; Database=libdb;Uid = root;password=root");
            MySqlCommand myCommand = new MySqlCommand("select count(Patron_ID) from patron", myConnection);
            String idCount = null;
            myConnection.Open();
            myReader = myCommand.ExecuteReader();
            while (myReader.Read())
            {
                idCount = myReader[0].ToString();
            }

            int intCount = int.Parse(idCount);
            intCount++;

            String newID = null;
            if (idCount.Length == 4)
                newID = "1" + intCount;
            else if (idCount.Length == 3)
                newID = "10" + intCount;
            else if (idCount.Length == 2)
                newID = "100" + intCount;
            else
                newID = "1000" + intCount;

            String addPatron = "INSERT INTO patron (Patron_ID, Last_Name, First_Name, Email, Telephone, Address, City, State, Inactive) values ('" + newID + "','" + this.lastnamebox.Text + "','" + this.firstnamebox.Text + "','" + this.emailbox.Text + "','" + this.phonebox.Text + "','" + addressbox.Text + "','" + this.citybox.Text + "','" + this.statebox.Text + "', FALSE);";

            db.dbUpdate(addPatron);
            MessageBox.Show("Entry created. New Patron ID:" + newID);
            this.lastnamebox.Text = String.Empty;
            this.firstnamebox.Text = String.Empty;
            this.emailbox.Text = String.Empty;
            this.phonebox.Text = String.Empty;
            this.addressbox.Text = String.Empty;
            this.citybox.Text = String.Empty;
            this.statebox.Text = String.Empty;
            myConnection.Close();
        }
开发者ID:rjosefsberg,项目名称:Library-Project,代码行数:40,代码来源:LibraryGUI.cs

示例7: checkoutbutton_Click

        private void checkoutbutton_Click(object sender, EventArgs e)
        {
            String sISBN = checkoutboxbook.Text;
            String sPatron = checkoutboxpatron.Text;
            if (sISBN.Length != 13)
            {
                MessageBox.Show("Incorrect length for ISBN (13)");
            }
            else if (sPatron.Length != 5)
            {
                MessageBox.Show("Incorrect length for Patron ID (5)");
            }

            else
            {
                DateTime dtToday = DateTime.Today;
                String sOut = dtToday.ToString("yyyy-MM-dd");
                DateTime dtDue = dtToday.AddDays(14.00);
                String sDue = dtDue.ToString("yyyy-MM-dd");

                String dbString = "UPDATE books SET Checked_Out= 'Y',Out_Date= '" + sOut + "', Due_Date= '" + sDue + "', By_patron= " + sPatron + " WHERE ISBN= " + sISBN + ";";

                DBHelper db = new DBHelper();
                MessageBox.Show("Check out successfull.");
                db.dbUpdate(dbString);
                checkoutboxpatron.Text = String.Empty;
                checkoutboxbook.Text = String.Empty;
            }
        }
开发者ID:rjosefsberg,项目名称:Library-Project,代码行数:29,代码来源:LibraryGUI.cs


注:本文中的DBHelper.dbUpdate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。