客运综合管理系统项目—线路管理(站点新增修改)
2015-06-04 20:15
645 查看
3.线路管理
【1】站点新增修改
3【1】(图1)
数据库
1、表与关系
3【1】(图2)
表1.站点表(dbo.StationList)
表2.站点邻居表(StationNeighbourList)
(1)新增站点
按启动按钮可以新增一个站点名称,这个名称不能和dgv中的相同,如果相同则有提示
3【1】(图3)
第一步:数据库的存储过程
第二步:逻辑层(BLL)代码
第三步:界面层(UIL)代码
新增相邻站点,在dgv中选择新增,在选中否那打上勾,同一行里面距离,各种票价都要填上,然后再按保存按钮
3【1】(图4)
第一步:数据库的存储过程
第二步:逻辑层(BLL)代码
第三步:界面层(UIL)代码
(2)修改站点
图3【1】(图5)红框内容是修改数据前要绑定的数据
3【1】(图5)
第一步:数据库的存储过程(绑定站点和下一站点的信息)
第二步:逻辑层(BLL)代码(绑定站点和下一站点的信息)
第三步:界面层(UIL)代码(绑定站点和下一站点的信息)
A.修改界面的跳转
3【1】(图6)
B.修改相邻站点信息
仅供学习,禁止用于商业用途
【1】站点新增修改
3【1】(图1)
数据库
1、表与关系
3【1】(图2)
表1.站点表(dbo.StationList)
列名 | 数据类型 | 主键/外键 | 说明 |
StationID | int | 主键 | 站点ID |
StationNumber | char (100) | 站点编号 | |
StationName | char (100) | 站点名称 | |
StopNo | bit | 停用否 |
列名 | 数据类型 | 主键/外键 | 说明 |
StationNeighbourID | int | 主键 | 站点邻居ID |
StationID | int | 外键 | 站点表.站点ID |
NeighbourListStationID | int | 外键 | 站点表.邻居站点ID |
Distance | decimal (18) | 距离 | |
LinePriceID | int | 外键 | 线路票价表.线路票价ID |
WholeTicketPrice | decimal (18, 1) | 全票价 | |
HalfTicketPrice | decimal (18, 1) | 半票价 | |
DiscountPrice | decimal (18, 1) | 打折价 | |
ChildrenPrice | decimal (18, 1) | 儿童价 | |
AddSeatPrice | decimal (18, 1) | 加位价 | |
StudentPrice | decimal (18, 1) | 学生价 |
按启动按钮可以新增一个站点名称,这个名称不能和dgv中的相同,如果相同则有提示
3【1】(图3)
第一步:数据库的存储过程
IF @TYPE='frmLineManage_Station_Insert_InsertStation'--新增站点 BEGIN BEGIN TRAN INSERT INTO StationList(StationName,StopNo) VALUES (@StationName,@StopNo) SELECT @@IDENTITY COMMIT TRAN END
第二步:逻辑层(BLL)代码
[OperationContract] public int frmLineManage_Station_Insert_InsertStation(string strStationName, Boolean boolStopNo)//新增线路 { SqlParameter[] mySqlParameter = { new SqlParameter("@type", SqlDbType.Char), new SqlParameter("@StationName", SqlDbType.Char), new SqlParameter("@StopNo", SqlDbType.Bit)}; mySqlParameter[0].Value = "frmLineManage_Station_Insert_InsertStation"; mySqlParameter[1].Value = strStationName; mySqlParameter[2].Value = boolStopNo; return myDALMethod.UpdateData("LineManage_frmLineManage_Station", mySqlParameter); }
第三步:界面层(UIL)代码
private void btnQiYongWangDian_Click(object sender, EventArgs e)//新增一个站点 { string StationName = "";//初始声明一个字符串等于空 for (int i = 0; i < dgvXiangLinWangDian.Rows.Count; i++)//循环dgv,比较是否已经存在文本框中的站点 { StationName = dgvXiangLinWangDian.Rows[i].Cells["StationName"].Value.ToString().Trim(); if (txtWangDianMingCheng.Text.ToString().Trim() == StationName) {//如果不存在就执行 MessageBox.Show("已存在该站点!"); txtWangDianMingCheng.Text = ""; return;//返回值 } } if (txtWangDianMingCheng.Text.ToString().Trim() == "") {//如果文本的值为空 MessageBox.Show("请填上站点!"); return; } if (MessageBox.Show("确定生成" + txtWangDianMingCheng.Text.ToString().Trim() + "?", "系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK)//提示框 { string strStationName = txtWangDianMingCheng.Text.ToString().Trim();//新增的数据 Boolean boolStopNo = false; int i = myfrmLineManage_StationClient.frmLineManage_Station_Insert_InsertStation(strStationName, boolStopNo); if (i > 0) { MessageBox.Show("启用成功!"); txtWangDianMingCheng.Text = "";//文本框的值为空 frmLineManage_Station_Insert_Load(null,null);//刷新 } else { MessageBox.Show("启用失败!"); txtWangDianMingCheng.Text = ""; } } }
新增相邻站点,在dgv中选择新增,在选中否那打上勾,同一行里面距离,各种票价都要填上,然后再按保存按钮
3【1】(图4)
第一步:数据库的存储过程
@StopNo BIT=0, @StationID INT=0, @StationName CHAR(100)='', @NeighbourListStationID INT=0, @Distance DECIMAL(18, 0)=0, @LinePriceID INT=0, @WholeTicketPrice DECIMAL(18, 1)=0, @HalfTicketPrice DECIMAL(18, 1)=0, @DiscountPrice DECIMAL(18, 1)=0, @ChildrenPrice DECIMAL(18, 1)=0, @AddSeatPrice DECIMAL(18, 1)=0, @StudentPrice DECIMAL(18, 1)=0, @StationNeighbourID INT=0 AS IF @TYPE='frmLineManage_Station_Insert_InsertStationNeighbour'--新增邻居站点 BEGIN BEGIN TRAN INSERT INTO StationNeighbourList(StationID, NeighbourListStationID, Distance, LinePriceID, WholeTicketPrice, HalfTicketPrice, DiscountPrice, ChildrenPrice, AddSeatPrice, StudentPrice) VALUES (@StationID, @NeighbourListStationID, @Distance, @LinePriceID, @WholeTicketPrice, @HalfTicketPrice, @DiscountPrice, @ChildrenPrice, @AddSeatPrice, @StudentPrice) SELECT @@IDENTITY COMMIT T
第二步:逻辑层(BLL)代码
[OperationContract] public DataSet frmLineManage_Station_Insert_InsertStationNeighbour(int intStationID, int intNeighbourListStationID, Decimal strDistance, int LinePriceID, decimal decWholeTicketPrice,decimal decHalfTicketPrice,decimal decDiscountPrice, decimal decChildrenPrice,decimal decAddSeatPrice,decimal decStudentPrice)// 新增邻居站点 { SqlParameter[] mySqlParameter = { new SqlParameter("@type", SqlDbType.Char), new SqlParameter("@StationID", SqlDbType.Int), new SqlParameter("@NeighbourListStationID", SqlDbType.Int), new SqlParameter("@Distance", SqlDbType.Decimal), new SqlParameter("@LinePriceID", SqlDbType.Int), new SqlParameter("@WholeTicketPrice", SqlDbType.Decimal), new SqlParameter("@HalfTicketPrice", SqlDbType.Decimal), new SqlParameter("@DiscountPrice", SqlDbType.Decimal), new SqlParameter("@ChildrenPrice", SqlDbType.Decimal), new SqlParameter("@AddSeatPrice", SqlDbType.Decimal), new SqlParameter("@StudentPrice", SqlDbType.Decimal)}; mySqlParameter[0].Value = "frmLineManage_Station_Insert_InsertStationNeighbour"; mySqlParameter[1].Value = intStationID; mySqlParameter[2].Value = intNeighbourListStationID; mySqlParameter[3].Value = strDistance; mySqlParameter[4].Value = LinePriceID; mySqlParameter[5].Value = decWholeTicketPrice; mySqlParameter[6].Value = decHalfTicketPrice; mySqlParameter[7].Value = decDiscountPrice; mySqlParameter[8].Value = decChildrenPrice; mySqlParameter[9].Value = decAddSeatPrice; mySqlParameter[10].Value = decStudentPrice; DataTable myDataTable = myDALMethod.QueryDataTable("LineManage_frmLineManage_Station", mySqlParameter); DataSet myDataSet = new DataSet(); myDataSet.Tables.Add(myDataTable); return myDataSet; }
第三步:界面层(UIL)代码
private void btnBaoCun_Insert_Click(object sender, EventArgs e)//保存按钮 { if (txtWangDianMingCheng.Text.ToString().Trim() != "") { dgvXiangLinWangDian.EndEdit();//dgv结束编辑操作 foreach (DataGridViewRow dr in dgvXiangLinWangDian.Rows) { if (Convert.ToBoolean(dr.Cells["选中否"].FormattedValue)) { if (dr.Cells["距离"].Value == null)//当文本框的值为空时 { MessageBox.Show("请输入距离!"); return;//结束方法,返回值 } if (dr.Cells["全票价"].Value == null) { MessageBox.Show("请输入全票价!"); return;//结束方法,返回值 } if (dr.Cells["半票价"].Value == null) { MessageBox.Show("请输入半票价!"); return;//结束方法,返回值 } if (dr.Cells["打折价"].Value == null) { MessageBox.Show("请输入打折价!"); return;//结束方法,返回值 } if (dr.Cells["儿童价"].Value == null) { MessageBox.Show("请输入儿童价!"); return;//结束方法,返回值 } if (dr.Cells["加位价"].Value == null) { MessageBox.Show("请输入加位价!"); return;//结束方法,返回值 } if (dr.Cells["学生价"].Value == null) { MessageBox.Show("请输入学生价!"); return;//结束方法,返回值 } } } string StationName = txtWangDianMingCheng.Text.ToString().Trim(); DataTable dtStationName = myfrmLineManage_StationClient.frmLineManage_Station_Insert_SelectStationOne(StationName).Tables[0]; if (dtStationName.Rows.Count > 0) { if (MessageBox.Show("确定生成?", "系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK) { DataTable resule2 = new DataTable();//声明一个DataTable foreach (DataGridViewRow dr1 in dgvXiangLinWangDian.Rows)//循环一个DataGridViewRow,DataGridViewRow的数据为图中dgv的所有行 { if (Convert.ToBoolean(dr1.Cells["选中否"].FormattedValue))//当dgv中(选中否)打上了勾 { int intStationID = (int)dtStationName.Rows[0]["StationID"];//获取值进行新增 int intNeighbourListStationID = Convert.ToInt32(dr1.Cells["StationID"].Value); int LinePriceID = (int)dtStationName.Rows[0]["StationID"]; ; decimal strDistance = Convert.ToDecimal(dr1.Cells["距离"].Value.ToString().Trim()); decimal decWholeTicketPrice = Convert.ToDecimal(dr1.Cells["全票价"].Value.ToString().Trim()); decimal decHalfTicketPrice = Convert.ToDecimal(dr1.Cells["半票价"].Value.ToString().Trim()); decimal decDiscountPrice = Convert.ToDecimal(dr1.Cells["打折价"].Value.ToString().Trim()); decimal decChildrenPrice = Convert.ToDecimal(dr1.Cells["儿童价"].Value.ToString().Trim()); decimal decAddSeatPrice = Convert.ToDecimal(dr1.Cells["加位价"].Value.ToString().Trim()); decimal decStudentPrice = Convert.ToDecimal(dr1.Cells["学生价"].Value.ToString().Trim()); resule2 = myfrmLineManage_StationClient.frmLineManage_Station_Insert_InsertStationNeighbour(intStationID, intNeighbourListStationID, strDistance, LinePriceID, decWholeTicketPrice, decHalfTicketPrice, decDiscountPrice, decChildrenPrice, decAddSeatPrice, decStudentPrice).Tables[0]; } } if (resule2.Rows.Count > 0)//当新增的数据大于0时 { MessageBox.Show("保存成功!"); } else { MessageBox.Show("保存失败!"); } } } else { } } else { MessageBox.Show("请填上站点!"); } }
(2)修改站点
图3【1】(图5)红框内容是修改数据前要绑定的数据
3【1】(图5)
第一步:数据库的存储过程(绑定站点和下一站点的信息)
IF @TYPE='frmLineManage_Station_Update_SelectStationClear'--SG显示站点明细(修改站点绑定数据) BEGIN SELECT StationNeighbourList.StationNeighbourID, StationNeighbourList.StationID, StationNeighbourList.NeighbourListStationID, StationList.StationName, StationList_1.StationName AS NeighbourListStationID, StationNeighbourList.Distance, StationNeighbourList.WholeTicketPrice, StationNeighbourList.HalfTicketPrice, StationNeighbourList.DiscountPrice, StationNeighbourList.ChildrenPrice, StationNeighbourList.AddSeatPrice, StationNeighbourList.StudentPrice FROM StationNeighbourList INNER JOIN StationList ON StationNeighbourList.StationID = StationList.StationID INNER JOIN StationList AS StationList_1 ON StationNeighbourList.NeighbourListStationID = StationList_1.StationID WHERE StationList.StopNo=0 AND StationList.StationID=@StationID --停用否=否and 获取员工站点ID END
第二步:逻辑层(BLL)代码(绑定站点和下一站点的信息)
[OperationContract] public DataSet frmLineManage_Station_Update_SelectStationClear(int intStationID)//(修改站点绑定数据) { SqlParameter[] mySqlParameter = { new SqlParameter("@type", SqlDbType.Char), new SqlParameter("@StationID", SqlDbType.Int),}; mySqlParameter[0].Value = "frmLineManage_Station_Update_SelectStationClear"; mySqlParameter[1].Value = intStationID; DataTable myDataTable = myDALMethod.QueryDataTable("LineManage_frmLineManage_Station", mySqlParameter); DataSet myDataSet = new DataSet(); myDataSet.Tables.Add(myDataTable); return myDataSet; }
第三步:界面层(UIL)代码(绑定站点和下一站点的信息)
A.修改界面的跳转
3【1】(图6)
private void toolStripButton2_Click(object sender, EventArgs e)//跳转到修改站点信息的界面 { if (PublicStaticObject.intStationClearID>0)//当选择的行数大于0 { DataGridViewRow dr = this.dgvWangDianXinXi.CurrentRow;//获取当前行对象 frmLineManage_Station_Update myfrmLineManage_Station_Update = new frmLineManage_Station_Update(dr);//界面跳转,传递参数 myfrmLineManage_Station_Update.ShowDialog(); } else { MessageBox.Show("请选择站点!"); }
B.修改相邻站点信息
DataGridViewRowmyDR;//声明一个DataGridViewRow publicfrmLineManage_Station_Update(DataGridViewRowDR)//声明第二个DataGridViewRow { InitializeComponent(); myDR = DR;//第一个DataGridViewRow的值等于第二个DataGridViewRow } BLL客运综合管理系统.LineManage.frmLineManage_Station.frmLineManage_StationClientmyfrmLineManage_StationClient = new BLL客运综合管理系统.LineManage.frmLineManage_Station.frmLineManage_StationClient(); public int intStationOneID = 0;//公共的整形 private voidfrmLineManage_Station_Update_Load(objectsender, EventArgs e)//load事件,包括绑定修改的绑定站点和下一站点的信息 { intStationOneID = Convert.ToInt32(myDR.Cells["StationID"].Value.ToString().Trim()); stringStation = myDR.Cells["StationName"].Value.ToString().Trim(); txtWangDianMingCheng.Text =Station; DataTabledt = myfrmLineManage_StationClient.frmLineManage_Station_Update_SelectStation(PublicStaticObject.intStationClearID).Tables[0]; DataTabledt1 =myfrmLineManage_StationClient.frmLineManage_Station_Update_SelectStationClear(PublicStaticObject.intStationClearID).Tables[0]; DataTabledt2 = new DataTable();//声明一个DataTable,名称为dt2 DataColumndc = new DataColumn();//声明一个数据集的列,名称为dc dc = dt2.Columns.Add("选中否", Type.GetType("System.Boolean"));//dc的一列,列名为选中否,列的数据类型为布尔型 dc = dt2.Columns.Add("StationID", Type.GetType("System.Int32"));//dc的一列,列名为StationID,列的数据类型为整形 dc = dt2.Columns.Add("StationName", Type.GetType("System.String"));//dc的一列,列名为StationName,列的数据类型为字符串 dc = dt2.Columns.Add("距离", Type.GetType("System.String"));//dc的一列,列名为距离,列的数据类型为字符串...... dc = dt2.Columns.Add("全票价", Type.GetType("System.String"));//...... dc = dt2.Columns.Add("半票价", Type.GetType("System.String")); dc = dt2.Columns.Add("打折价", Type.GetType("System.String")); dc = dt2.Columns.Add("儿童价", Type.GetType("System.String")); dc = dt2.Columns.Add("加位价", Type.GetType("System.String")); dc = dt2.Columns.Add("学生价", Type.GetType("System.String")); for(int i = 0; i < dt.Rows.Count; i++) { DataRownewRow = dt2.NewRow();//声明一个数据集的行,名称为newRow newRow["StationID"]= dt.Rows[i]["StationID"].ToString().Trim(); newRow["StationName"]= dt.Rows[i]["StationName"].ToString().Trim(); for(int j = 0; j < dt1.Rows.Count; j++)//循环dt1 { if(dt.Rows[i]["StationID"].ToString().Trim()== dt1.Rows[j]["NeighbourListStationID"].ToString().Trim())//如果网点表的网点ID与网店邻居表的相邻网店ID相等时: { newRow["选中否"]= true;//当前行列名(选中否)等于TRUE newRow["距离"]= dt1.Rows[j]["Distance"].ToString().Trim();//当前行列名(距离)的值等于dt1中“WholeTicketPrice”的一行数据... newRow["全票价"]= dt1.Rows[j]["WholeTicketPrice"].ToString().Trim();//同上.... newRow["半票价"]= dt1.Rows[j]["HalfTicketPrice"].ToString().Trim(); newRow["打折价"]= dt1.Rows[j]["DiscountPrice"].ToString().Trim(); newRow["儿童价"]= dt1.Rows[j]["ChildrenPrice"].ToString().Trim(); newRow["加位价"]= dt1.Rows[j]["AddSeatPrice"].ToString().Trim(); newRow["学生价"]= dt1.Rows[j]["StudentPrice"].ToString().Trim(); } } dt2.Rows.Add(newRow);// } this.dgvXiangLinWangDian.AllowUserToAddRows= false;//设置dgv不能添加行 this.dgvXiangLinWangDian.AllowUserToResizeRows= false;//设置dgv不能调整整行的大小 this.dgvXiangLinWangDian.DataSource= dt2;//绑定数据给dgv }
仅供学习,禁止用于商业用途
相关文章推荐
- HDU 4584 Building bridges
- Centos6.5 源码搭建nginx1.4.7
- MySQL查询时强制区分大小写的方法
- php面向对象(OOP)—__toString()和__clone()
- P122.41
- JAVA RMI 原理与实现
- 一句话
- FileInputStream(字节流)与fileReader(字符流) 的区别
- [FZYZOJ 1859] 建桥
- Azure SQL 数据库:新服务级别问答
- Azure SQL 数据库:新服务级别问答
- Azure SQL 数据库:新服务级别问答
- 环境变量中path和classpath的作用
- Azure SQL 数据库:新服务级别问答
- 虚拟互换(virtual swap)
- Android之Intent传递数据
- 概率论与数理统计ppt链接
- Remove Linked List Elements
- 前缀、中缀、后缀表达式
- hdu5194DZY Loves Balls 期望