C#圖書管理系統(tǒng) 附源碼下載
用來(lái)練手還是不錯(cuò)的,分享大家看一下,還是一些新穎點(diǎn)的 !哈哈
就是自定義DataGridView,方便每個(gè)功能部分調(diào)用!簡(jiǎn)單!再次重申?。。『竺嬖创a會(huì)送上!
首先看一下登錄,上圖吧!
只有超級(jí)管理員跟管理員
接下來(lái)看一下主界面
更改DataGridView數(shù)據(jù)列
datagridView自定義類
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Reflection;
using System.Drawing;
namespace Common
{
public class Com
{
public void thread() {
}
/// <summary>
/// DataGridView的樣式
/// </summary>
/// <param name="GridView"></param>
public void ExitGridView(DataGridView GridView)
{
GridView.AllowDrop = false;
GridView.AllowUserToAddRows = false;
GridView.AllowUserToDeleteRows = false;
GridView.AllowUserToOrderColumns = false;
GridView.AllowUserToResizeColumns = false;
}
/// <summary>
/// 生成一列有功能的按鈕
/// </summary>
/// <param name="name"></param>
/// <param name="GridView"></param>
public void AddColumn(string name, DataGridView GridView)
{
//添加修改按鈕
DataGridViewButtonColumn c = new DataGridViewButtonColumn();
//設(shè)置列標(biāo)題單元格的名稱
c.Text = name;
//單元格的背景色
c.DefaultCellStyle.BackColor = Color.LightGray;
//單元格選定時(shí)的背景色
c.DefaultCellStyle.SelectionBackColor = Color.DarkGray;
//單元格的默認(rèn)文本
c.UseColumnTextForButtonValue = true;
//單元格寬
c.Width = 60;
//添加新的一列對(duì)象
//選中時(shí)背景色為灰色
c.DefaultCellStyle.SelectionBackColor = Color.LightGray;
c.DefaultCellStyle.SelectionForeColor = Color.Black;
c.FillWeight = 50;
GridView.Columns.Add(c);
}
/// <summary>
/// 自動(dòng)生成columns 沒(méi)有修改和刪除
/// </summary>
/// <param name="HeaderText"></param>
/// <param name="DataPropertyNames"></param>
/// <param name="GrdiView"></param>
public void AutoColumn(string HeaderText, string DataPropertyNames, DataGridView GrdiView)
{
//去掉自動(dòng)生成的列
GrdiView.AutoGenerateColumns = false;
GrdiView.RowHeadersDefaultCellStyle.SelectionBackColor = Color.DarkGray;
//生成行標(biāo)題標(biāo)號(hào)的方法
GrdiView.DataSource = System.Drawing.Imaging.ImageCodecInfo.GetImageDecoders();
// 禁止用戶改變DataGridView1的所有列的列寬
GrdiView.AllowUserToResizeColumns = false;
//禁止用戶改變DataGridView1の所有行的行高
GrdiView.AllowUserToResizeRows = false;
//選擇整行
GrdiView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
GrdiView.AllowDrop = false;
//不可以添加行
GrdiView.AllowUserToAddRows = false;
//不可以刪除行
GrdiView.AllowUserToDeleteRows = false;
//不可以手動(dòng)對(duì)列重新定位
GrdiView.AllowUserToOrderColumns = false;
//不可以調(diào)整列的大小
GrdiView.AllowUserToResizeColumns = false;
//不可以調(diào)整行的大小
GrdiView.AllowUserToResizeRows = false;
//行標(biāo)題行的寬度
GrdiView.RowHeadersWidth = 32;
//不能多選
GrdiView.MultiSelect = false;
//獲取標(biāo)題樣式
GrdiView.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
string[] arrayHeaderText = HeaderText.Split(',');
string[] arrayDataPropertyNames = DataPropertyNames.Split(',');
for (int i = 0; i < arrayHeaderText.Length; i++)
{
DataGridViewTextBoxColumn d = new DataGridViewTextBoxColumn();
//綁定數(shù)據(jù)庫(kù)列名稱
d.DataPropertyName = arrayDataPropertyNames[i];
//設(shè)置列標(biāo)題的名稱
d.HeaderText = arrayHeaderText[i];
//單元格選定時(shí)的背景色
d.DefaultCellStyle.SelectionBackColor = Color.Gainsboro;
d.DefaultCellStyle.SelectionForeColor = Color.Black;
//單元格的內(nèi)容居中
d.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
GrdiView.Columns.Add(d);
}
GrdiView.DataSource = null;
}
/// <summary>
/// 找到剛剛添加成功的數(shù)據(jù)行s
/// </summary>
/// <param name="A"></param>
/// <param name="GridView"></param>
public void AutoFindRow(string A, DataGridView GridView)
{
//獲取DataGridView中的總行數(shù)
int rows = GridView.RowCount;
//找到剛剛添加成功的數(shù)據(jù)行
for (int i = 0; i < rows; i++)
{
string a = GridView.Rows[i].Cells[0].Value.ToString();
if (a == A)
{
//選中整行
GridView.Rows[i].Selected = true;
//垂直滾動(dòng)條,滾動(dòng)到當(dāng)前行索引位置
GridView.FirstDisplayedScrollingRowIndex = i;
}
else
{
//清楚整行選中
GridView.Rows[i].Selected = false;
}
}
}
/// <summary>
/// 找到剛剛添加成功的數(shù)據(jù)行
/// </summary>
/// <param name="A"></param>
/// <param name="GridView"></param>
public void AutoFindRow(int A, DataGridView GridView)
{
//獲取DataGridView中的總行數(shù)
int rows = GridView.RowCount;
//找到剛剛添加成功的數(shù)據(jù)行
for (int i = 0; i < rows; i++)
{
int a = (int)GridView.Rows[i].Cells[0].Value;
if (a == A)
{
//選中整行
GridView.Rows[i].Selected = true;
//垂直滾動(dòng)條,滾動(dòng)到當(dāng)前行索引位置
GridView.FirstDisplayedScrollingRowIndex = i;
}
else
{
//清楚整行選中
GridView.Rows[i].Selected = false;
}
}
}
}
}
挺簡(jiǎn)單的 一下是圖書管理加載的數(shù)據(jù)方法
private void BookInfoManager_UI_Load(object sender, EventArgs e)
{
#region DataGridView1綁定
//需要添加列的列標(biāo)題字符串
string arraysHeaderText = @"圖書編號(hào),圖書名稱,登記時(shí)間,圖書類型,作者,拼音碼,翻譯,語(yǔ)言,頁(yè)數(shù),價(jià)格,印刷版面,存放位置,ISBS碼,版本,描述";
//需要綁定數(shù)據(jù)庫(kù)列名稱的字符串
string arraysName = @"BookId,BookName,TimeIn,BookTypeName,Author,PinYinCode,Translator,Language,BookNumber,Price,Layout,Address,ISBS,Versions,BookRemark";
//自動(dòng)生成columns
autocoumns.AutoColumn(arraysHeaderText, arraysName, dataGridView1);
dataGridView1.DataSource = bookInfo_bll.selectBookInfo1().Tables[0];
autocoumns.AddColumn("修改", dataGridView1);
autocoumns.AddColumn("刪除", dataGridView1);
//DataGridView1數(shù)據(jù)集綁定
this.dataGridView1.DataSource = bookInfo_bll.selectBookInfo1().Tables[0];
//窗體加載時(shí)默認(rèn)隱藏的列
this.dataGridView1.Columns[14].Visible = false;
this.dataGridView1.Columns[13].Visible = false;
this.dataGridView1.Columns[12].Visible = false;
this.dataGridView1.Columns[11].Visible = false;
this.dataGridView1.Columns[10].Visible = false;
#endregion
#region 下拉框綁定
DataGridViewColumnCollection columns = dataGridView1.Columns;
for (int i = 0; i < columns.Count - 2; i++)
{
comboBox1.Items.Add(columns[i].HeaderText);
}
comboBox1.Items.Insert(0, "全部");
comboBox1.SelectedIndex = 0;
#endregion
#region 樹狀圖的綁定
TreeViewBand();
#endregion
#region DgvHostory綁定
string Header1 = @"圖書編號(hào),圖書名稱,讀者編號(hào),讀者名稱,借出時(shí)間,書應(yīng)歸還時(shí)間,實(shí)際歸還時(shí)間,應(yīng)付罰金,續(xù)借次數(shù),借還描述";
string PropertyNames1 = @"BookId,BookName,ReaderId,ReaderName,BorrowTime,ReturnTime,FactReturnTime,Fine,RenewCount,BorrowRemark";
//自動(dòng)生成columns
autocoumns.AutoColumn(Header1, PropertyNames1, dgvHostory);
#endregion
}
源碼下載:Csharplibrary(jb51.net).rar
關(guān)于管理系統(tǒng)的更多內(nèi)容請(qǐng)點(diǎn)擊《管理系統(tǒng)專題》進(jìn)行學(xué)習(xí)
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持我們。
欄 目:C#教程
下一篇:C#設(shè)置自定義文件圖標(biāo)實(shí)現(xiàn)雙擊啟動(dòng)(修改注冊(cè)表)
本文標(biāo)題:C#圖書管理系統(tǒng) 附源碼下載
本文地址:http://www.jygsgssxh.com/a1/C_jiaocheng/6272.html
您可能感興趣的文章
- 01-10C#實(shí)現(xiàn)附件上傳和下載功能
- 01-10C#有效防止同一賬號(hào)多次登錄(附三種方法)
- 01-10C#實(shí)現(xiàn)DataTable映射成Model的方法(附源碼)
- 01-10C#編程實(shí)現(xiàn)發(fā)送郵件的方法(可添加附件)
- 01-10C#實(shí)現(xiàn)的自定義郵件發(fā)送類完整實(shí)例(支持多人多附件)
- 01-10基于C#生成條形碼操作知識(shí)匯總附源碼下載
- 01-10使用C#編寫簡(jiǎn)單的圖形化的可發(fā)送附件的郵件客戶端程序
- 01-10使用C#發(fā)送帶附件的電子郵件的方法的代碼示例分析
- 01-10C# WinForm 判斷程序是否已經(jīng)在運(yùn)行,且只允許運(yùn)行一個(gè)實(shí)例,附
- 01-10Winform學(xué)生信息管理系統(tǒng)登陸窗體設(shè)計(jì)(1)


閱讀排行
- 1C語(yǔ)言 while語(yǔ)句的用法詳解
- 2java 實(shí)現(xiàn)簡(jiǎn)單圣誕樹的示例代碼(圣誕
- 3利用C語(yǔ)言實(shí)現(xiàn)“百馬百擔(dān)”問(wèn)題方法
- 4C語(yǔ)言中計(jì)算正弦的相關(guān)函數(shù)總結(jié)
- 5c語(yǔ)言計(jì)算三角形面積代碼
- 6什么是 WSH(腳本宿主)的詳細(xì)解釋
- 7C++ 中隨機(jī)函數(shù)random函數(shù)的使用方法
- 8正則表達(dá)式匹配各種特殊字符
- 9C語(yǔ)言十進(jìn)制轉(zhuǎn)二進(jìn)制代碼實(shí)例
- 10C語(yǔ)言查找數(shù)組里數(shù)字重復(fù)次數(shù)的方法
本欄相關(guān)
- 01-10C#通過(guò)反射獲取當(dāng)前工程中所有窗體并
- 01-10關(guān)于ASP網(wǎng)頁(yè)無(wú)法打開的解決方案
- 01-10WinForm限制窗體不能移到屏幕外的方法
- 01-10WinForm繪制圓角的方法
- 01-10C#實(shí)現(xiàn)txt定位指定行完整實(shí)例
- 01-10WinForm實(shí)現(xiàn)仿視頻播放器左下角滾動(dòng)新
- 01-10C#停止線程的方法
- 01-10C#實(shí)現(xiàn)清空回收站的方法
- 01-10C#通過(guò)重寫Panel改變邊框顏色與寬度的
- 01-10C#實(shí)現(xiàn)讀取注冊(cè)表監(jiān)控當(dāng)前操作系統(tǒng)已
隨機(jī)閱讀
- 08-05dedecms(織夢(mèng))副欄目數(shù)量限制代碼修改
- 04-02jquery與jsp,用jquery
- 01-11Mac OSX 打開原生自帶讀寫NTFS功能(圖文
- 01-11ajax實(shí)現(xiàn)頁(yè)面的局部加載
- 08-05DEDE織夢(mèng)data目錄下的sessions文件夾有什
- 01-10C#中split用法實(shí)例總結(jié)
- 01-10delphi制作wav文件的方法
- 08-05織夢(mèng)dedecms什么時(shí)候用欄目交叉功能?
- 01-10SublimeText編譯C開發(fā)環(huán)境設(shè)置
- 01-10使用C語(yǔ)言求解撲克牌的順子及n個(gè)骰子


