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


C# DBManager.Connection方法代码示例

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


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

示例1: GetLastMemoNumber

        private int GetLastMemoNumber()
        {
            DBManager manager = new DBManager();
            SqlConnection connection = manager.Connection();
            string selectQ = "select MAX(Memo_No) from Deliveri_Memo_Counter";
            SqlCommand command = new SqlCommand(selectQ, connection);

            connection.Open();
            SqlDataReader reader = command.ExecuteReader();
            while (reader.Read())
            {
                if (reader[0].ToString().Equals(""))
                {
                    memoNumver = 1;
                }
                else
                {
                    memoNumver = Convert.ToInt16(reader[0]);
                }

            }

            connection.Close();
            connection.Open();
           



            return memoNumver;
        }
开发者ID:salamcseiu21,项目名称:Library-Management-With-CSharp-Desktop-,代码行数:30,代码来源:ShowOrderUI.cs

示例2: GetAllOrders

        public void GetAllOrders()
        {
            try
            {

                DBManager manager = new DBManager();
                SqlConnection connection = manager.Connection();

                string selectQuery = "SELECT * From Orders";
                SqlCommand cmd = new SqlCommand(selectQuery, connection);
                
                SqlDataAdapter adapter = new SqlDataAdapter();
                adapter.SelectCommand = cmd;
                dataTable = new DataTable();
                adapter.Fill(dataTable);
                BindingSource binding = new BindingSource();
                binding.DataSource = dataTable;
                dataGridView1.DataSource = dataTable;
                adapter.Update(dataTable);
            }
            catch (SqlException exception)
            {
                MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
开发者ID:salamcseiu21,项目名称:Library-Management-With-CSharp-Desktop-,代码行数:25,代码来源:QuantitySelect.cs

示例3: TestBook

        public void TestBook()
        {
            try
            {
                DBManager manager1 = new DBManager();
                SqlConnection connection = manager1.Connection();
                string seletQuery = "select * from ALl_Table_Name";
                SqlCommand selectCmd = new SqlCommand(seletQuery, connection);
                connection.Open();

                SqlDataReader reader = selectCmd.ExecuteReader();
                while (reader.Read())
                {
                    string name = reader[1].ToString();

                    comboBox2.Items.Add(name);
                    //textBox3.Text = name;
                }


                //return null;
            }
            catch (Exception obj)
            {

                throw new Exception("Error", obj);
            }
        }
开发者ID:salamcseiu21,项目名称:Library-Management-With-CSharp-Desktop-,代码行数:28,代码来源:TestUI.cs

示例4: dataGridView1_CellContentClick

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex >= 0)
                {
                    DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex];
                    string serialNo = row.Cells["S.No"].Value.ToString();
                    DBManager manager=new DBManager();
                    SqlConnection connection = manager.Connection();
                    string query = "delete from Books Where [S.No]='" + serialNo + "'";
                    SqlCommand delCommand=new SqlCommand(query,connection);
                    connection.Open();

                    System.Windows.Forms.DialogResult result =
                        MessageBox.Show("Do you wnat to delete the selected book?", "Message", MessageBoxButtons.YesNo,
                            MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        delCommand.ExecuteNonQuery();
                        MessageBox.Show("deleted", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        TestBook(); 
                    }


 
                }
            }
            catch (Exception exception)
            {

                MessageBox.Show(exception.StackTrace);
            }
        }
开发者ID:salamcseiu21,项目名称:Library-Management-With-CSharp-Desktop-,代码行数:34,代码来源:UpdateUI.cs

示例5: SaveTempOrer

       public void SaveTempOrer(TempOrder aOrder)
       {
           try
           {
               DBManager maneageManager = new DBManager();
               SqlConnection connection1 = maneageManager.Connection();
               string query = "Insert into Temp_Order_Hold values(@serial,@customerName,@mobile,@bookName,@writerName,@edition,@type,@print,@quantity,@unitPrice,@total,@advance,@due,@supplydate,@memoNumber)";
               SqlCommand command = new SqlCommand(query, connection1);
               command.Parameters.Clear();
               command.Parameters.AddWithValue("@serial", aOrder.SerialNo);
               command.Parameters.AddWithValue("@customerName", aOrder.CustomerName);
               command.Parameters.AddWithValue("@mobile", aOrder.MobileNo);
               command.Parameters.AddWithValue("@bookName", aOrder.BookName);
               command.Parameters.AddWithValue("@writerName", aOrder.WriterName);
               command.Parameters.AddWithValue("@edition", aOrder.Edition);
               command.Parameters.AddWithValue("@type", aOrder.Type);
               command.Parameters.AddWithValue("@print", aOrder.Print);
               command.Parameters.AddWithValue("@quantity", aOrder.Quantity);
               command.Parameters.AddWithValue("@unitPrice", aOrder.Unitprice);
               command.Parameters.AddWithValue("@total", aOrder.Total);
               command.Parameters.AddWithValue("@advance", aOrder.Advance);
               command.Parameters.AddWithValue("@due", aOrder.Due);
               command.Parameters.AddWithValue("@supplydate", aOrder.SupplyDate);
               command.Parameters.AddWithValue("@memoNumber", aOrder.MemoNumber);
               connection1.Open();
               command.ExecuteNonQuery();
               MessageBox.Show("Saved", "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Information);

           }
           catch (Exception exception)
           {

               MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
           }
       }
开发者ID:salamcseiu21,项目名称:Library-Management-With-CSharp-Desktop-,代码行数:35,代码来源:TempOrderGateway.cs

示例6: GetAllOrders1

        public void GetAllOrders1()
        {
            try
            {
                DBManager manager = new DBManager();
                SqlConnection connection = manager.Connection();

                string selectQuery = "SELECT Quantity From Orders";
                SqlCommand cmd = new SqlCommand(selectQuery, connection);
                connection.Open()
                    ;
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    string q = reader[0].ToString();
                     if (q.Equals(""))
                    {
                        qunatityOfRemaingBook = 0;
                    }
                    else
                    {
                        qunatityOfRemaingBook = Convert.ToInt16(q);
                    }
                }
                connection.Close();
            }
            catch (SqlException exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
开发者ID:salamcseiu21,项目名称:Library-Management-With-CSharp-Desktop-,代码行数:31,代码来源:ShowOrderUI.cs

示例7: showTotalButton_Click

        private void showTotalButton_Click(object sender, EventArgs e)
        {
            DBManager manager = new DBManager();
            SqlConnection connection = manager.Connection();
            string selectQuery =
                "select SUM(From_Book), sum(From_Photocopy),sum(From_Others),sum(Total_Income) from Income";
            connection.Open();
            SqlCommand cmd = new SqlCommand(selectQuery, connection);
            SqlDataReader reader = cmd.ExecuteReader();
            List<double> sellBooks = new List<double>();
            while (reader.Read())
            {
                try
                {

                    double fbook = Convert.ToInt16(reader[0]);
                    double fphotocopy = Convert.ToDouble(reader[1]);
                    double fothers = Convert.ToDouble(reader[2]);
                    double total = Convert.ToDouble(reader[3]);


                    bookTextBox.Text = fbook.ToString();
                    photocopyTextBox.Text = fphotocopy.ToString();
                    othersTextBox.Text = fothers.ToString();
                    sumofAllTextBox.Text = total.ToString();
                }
                catch (Exception)
                {

                    MessageBox.Show("NO data found", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

            }
        }
开发者ID:salamcseiu21,项目名称:Library-Management-With-CSharp-Desktop-,代码行数:34,代码来源:IncomeRecord.cs

示例8: LoadAllBook

       public void LoadAllBook()    
        {
            try
            {
                DBManager manager = new DBManager();
                SqlConnection connection = manager.Connection();

                string selectQuery = "SELECT * From Books";
                SqlCommand cmd = new SqlCommand(selectQuery, connection);
                //connection.Open();
                SqlDataAdapter adapter = new SqlDataAdapter();
                adapter.SelectCommand = cmd;
                dataTable = new DataTable();
                adapter.Fill(dataTable);
                BindingSource binding = new BindingSource();
                binding.DataSource = dataTable;
                dataGridView1.DataSource = dataTable;
                adapter.Update(dataTable);


            }
            catch ( SqlException exception)
            {

                MessageBox.Show(exception.Message);
            }
        }
开发者ID:salamcseiu21,项目名称:Library-Management-With-CSharp-Desktop-,代码行数:27,代码来源:OrderUI.cs

示例9: GetAllBook

        public void GetAllBook()
        {
            
            try
            {
                DBManager manager = new DBManager();
                SqlConnection connection = manager.Connection();
                string query = "select * from Books";
                SqlCommand command = new SqlCommand(query, connection);
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    string name = reader[1].ToString();
                    //comboBox1.Items.Add(name);

                }
            }
            catch (Exception exception)
            {

                MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
           
            
        }
开发者ID:salamcseiu21,项目名称:Library-Management-With-CSharp-Desktop-,代码行数:26,代码来源:TestUI.cs

示例10: SaveBook

       public string SaveBook(Book aBook)
       {

           double totalPrice=Convert.ToDouble(aBook.Quantity)*Convert.ToDouble(aBook.UnitPrice);
           DBManager manager = new DBManager();
           SqlConnection connection = manager.Connection();
            string InsertQuerty = "Insert into Books values(@name,@writer,@edition,@type,@print,@quantity,@unitprice,@totalprice,@pdate)";
          // string InsertQuerty = string.Format("Insert into Books values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')",aBook.BookName,aBook.AuthorName,aBook.Edition,aBook.TypeOfBook,aBook.BookPrint,aBook.Quantity,aBook.UnitPrice,totalPrice,aBook.PurchasesDate);
          // string insertQuery = "INSERT INTO Books values('"+aBook.BookName+"','"+aBook.AuthorName+"','"+aBook.Edition+"','"+aBook.TypeOfBook+"','"+aBook.BookPrint+"','"+aBook.Quantity+"','"+aBook.UnitPrice+"','"+totalPrice+"','"+aBook.PurchasesDate+"')";
           SqlCommand cmd = new SqlCommand(InsertQuerty, connection);
           connection.Open();
           cmd.Parameters.Clear();
           cmd.Parameters.AddWithValue("@name", aBook.BookName);
           cmd.Parameters.AddWithValue("@writer", aBook.AuthorName);
           cmd.Parameters.AddWithValue("@edition", aBook.Edition);
           cmd.Parameters.AddWithValue("@type", aBook.TypeOfBook);
           cmd.Parameters.AddWithValue("@print", aBook.BookPrint);
           cmd.Parameters.AddWithValue("@quantity", aBook.Quantity);
           cmd.Parameters.AddWithValue("@unitprice", aBook.UnitPrice);
           cmd.Parameters.AddWithValue("@totalprice", totalPrice);
           cmd.Parameters.AddWithValue("@pdate", aBook.PurchasesDate);
           int i = cmd.ExecuteNonQuery();
           return i + "  Book Saved";
           // connection.Close();
       }
开发者ID:salamcseiu21,项目名称:Library-Management-With-CSharp-Desktop-,代码行数:25,代码来源:BookGateway.cs

示例11: LastAddedInvestlNo

        public int LastAddedInvestlNo()
        {
           
            OrderGateway gateway=new OrderGateway();
            
            DBManager manager = new DBManager();
            SqlConnection connection = manager.Connection();
           

            string selectQuery = "SELECT Order_No From Orders";
            SqlCommand cmd = new SqlCommand(selectQuery, connection);
            connection.Open();  
            SqlDataReader reader = cmd.ExecuteReader();
            List<int> totalId = new List<int>();

            while (reader.Read())
            {
                int aId = Convert.ToInt16(reader[0]);

               
                totalId.Add(aId);
            }
            if (totalId.Count<=0)
            {
                return 0;
            }
            else
            {
                int x = totalId.Max();

                return x;  
            }
           

        }
开发者ID:salamcseiu21,项目名称:Library-Management-With-CSharp-Desktop-,代码行数:35,代码来源:OrderUI.cs

示例12: SaveSelfOrder

        public void SaveSelfOrder(SelfOrder selfOrder)
        {

            
        

            if (HasThisBookalradyinList(selfOrder.BName,selfOrder.BWriter,selfOrder.BEdition) == false)
            {
                DBManager manager = new DBManager();
                SqlConnection connection = manager.Connection();
                connection.Close();
                string selectQuery = "Insert into Self_Order values('" + selfOrder.BName + "','" +
                                     selfOrder.BWriter + "','" + selfOrder.BEdition + "','" + selfOrder.Quantity +
                                     "','" + DateTime.Now.ToShortDateString() + "')";

                SqlCommand cmd = new SqlCommand(selectQuery, connection);
                connection.Open();
                int i = cmd.ExecuteNonQuery();
                MessageBox.Show("Saved", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);


                
            }

            else
            {
                MessageBox.Show("This book already include.","Message",MessageBoxButtons.OK,MessageBoxIcon.Warning);
            }

        }
开发者ID:salamcseiu21,项目名称:Library-Management-With-CSharp-Desktop-,代码行数:30,代码来源:SelfOrderGateway.cs

示例13: LastAddedInvestlNo

         public int  LastAddedInvestlNo()
        {
            int a = lastAdded;
            InvestmentGateway inGateway = new InvestmentGateway();
            Invest invest = new Invest();
            
            DBManager manager = new DBManager();
            SqlConnection connection = manager.Connection();
           
            string selectQuery = "SELECT Id From InvestmentCost";
            SqlCommand cmd = new SqlCommand(selectQuery, connection);
            connection.Open();
            SqlDataReader reader = cmd.ExecuteReader();
            List<int> totalId = new List<int>();

            while (reader.Read())
            {
                int  aId = Convert.ToInt16(reader[0]);

                
                totalId.Add(aId);
            }
             if (totalId.Count.Equals(0))
             {
                 return 0;
             }
             else
             {
                 int x = totalId.Max();
                 return x;
             }

           
        }
开发者ID:salamcseiu21,项目名称:Library-Management-With-CSharp-Desktop-,代码行数:34,代码来源:InvestmentUI.cs

示例14: TestBook

        public void TestBook()
        {
            try
            {
                DBManager manager1 = new DBManager();
                SqlConnection connection = manager1.Connection();
                string seletQuery = "select * from Books Order by Name";
                SqlCommand selectCmd = new SqlCommand(seletQuery, connection);
                connection.Open();

                SqlDataAdapter myAdapter = new SqlDataAdapter();
                myAdapter.SelectCommand = selectCmd;

                dt = new DataTable();
                myAdapter.Fill(dt);
                BindingSource bSource = new BindingSource();
                bSource.DataSource = dt;
                dataGridView1.DataSource = dt;
                myAdapter.Update(dt);



                //return null;
            }
            catch (Exception obj)
            {

                throw new Exception("Error", obj);
            }
        }
开发者ID:salamcseiu21,项目名称:Library-Management-With-CSharp-Desktop-,代码行数:30,代码来源:UpdateUI.cs

示例15: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                DBManager manager = new DBManager();
                SqlConnection connection = manager.Connection();
                string selectQuery = "select * from Income";
                SqlCommand cmd = new SqlCommand(selectQuery, connection);
                connection.Open();
                SqlDataAdapter myAdapter = new SqlDataAdapter();
                myAdapter.SelectCommand = cmd;

                dataTable = new DataTable();
                myAdapter.Fill(dataTable);
                BindingSource bSource = new BindingSource();
                bSource.DataSource = dataTable;
                dataGridView1.DataSource = bSource;
                myAdapter.Update(dataTable);
            }
            catch (SqlException ex)
            {

                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
开发者ID:salamcseiu21,项目名称:Library-Management-With-CSharp-Desktop-,代码行数:25,代码来源:IncomeRecord.cs


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