管理示例代码
来源:互联网 发布:新田县广电网络 编辑:程序博客网 时间:2024/05/12 07:50
采用三层代码自动生成,参数形式:
static int i = 1;//页数
static int index;//编码号
static string CNo;//编号
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Button2.Visible = false;
InDate.Text = System.DateTime.Now.ToString("G");
GridViewBind();
CF.BLL.Goods bll = new CF.BLL.Goods();
DropDownList1.DataSource = bll.GetAllList().Tables[0].DefaultView;
DropDownList1.DataBind();
CF.BLL.Admin bll2 = new CF.BLL.Admin();
DropDownList2.DataSource = bll2.GetAllList().Tables[0].DefaultView;
DropDownList2.DataBind();
}
}
/// <summary>
/// 读取数据到GridView1
/// </summary>
private void GridViewBind()
{
CF.BLL.InWarehouse bll = new CF.BLL.InWarehouse();
DataSet ds = bll.GetAllList();
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
}
/// <summary>
/// 添加记录
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Button1_Click(object sender, EventArgs e)
{
CF.Model.InWarehouse model = new CF.Model.InWarehouse();
CF.BLL.InWarehouse bll = new CF.BLL.InWarehouse();
model.InID = bll.GetMaxId();
model.GoodsID = int.Parse(DropDownList1.SelectedValue);
model.AdminID = int.Parse(DropDownList2.SelectedValue);
model.InNumber = int.Parse(InNumber.Text.Trim());
model.InDate = DateTime.Now;
model.InQuantity = int.Parse(InQuantity.Text.Trim());
model.Price = Convert.ToDecimal(Price.Text.Trim());
int priceTmp = Convert.ToInt32(Price.Text.Trim()) * model.InQuantity;
model.PriceAmount = Convert.ToDecimal(priceTmp);
model.Stock = 0;
model.FHAdminID = -1;
model.IsInWarehouse = false;
model.Note = Note.Text.Trim();
model.InRank = 0;
model.Place = Place.Text.Trim();
bll.Add(model);
Label4.Text = "添加成功!";
GridViewBind();
InQuantity.Text = "";
Price.Text = "";
InNumber.Text = "";
Place.Text = "";
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
Label2.Text = "当前页码是" + Convert.ToString(GridView1.PageIndex + i);
GridViewBind();
}
/// <summary>
/// 更新、删除记录
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
switch (e.CommandName)
{
case "up":
Button1.Visible = false;
Button2.Visible = true;
//获取行编号
index = Convert.ToInt32(e.CommandArgument);
//根据行编号,获取整行
GridViewRow selectedRowu = this.GridView1.Rows[index];
//获取记录编号
CNo = selectedRowu.Cells[0].Text;
CF.BLL.InWarehouse bll = new CF.BLL.InWarehouse();
CF.Model.InWarehouse model = bll.GetModel(int.Parse(CNo));
InID.Text = model.InID.ToString();
DropDownList1.SelectedValue = model.GoodsID.ToString();
DropDownList2.SelectedValue = model.AdminID.ToString();
InNumber.Text = model.InNumber.ToString();
InDate.Text = model.InDate.ToString();
InQuantity.Text = model.InQuantity.ToString();
Price.Text = model.Price.ToString();
Note.Text = model.Note;
Place.Text = model.Place;
break;
case "del":
//获取行编号
index = Convert.ToInt32(e.CommandArgument);
//根据行编号,获取整行
GridViewRow selectedRowu1 = this.GridView1.Rows[index];
//获取记录编号
CNo = selectedRowu1.Cells[0].Text;
CF.BLL.InWarehouse bll2 = new CF.BLL.InWarehouse();
bll2.Delete(int.Parse(CNo));
GridViewBind();
break;
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
{
((LinkButton)e.Row.Cells[12].Controls[0]).Attributes.Add("onclick", "javascript:return confirm('你确认要删除入库商品:/"" + e.Row.Cells[1].Text.Trim() + "/"吗?')");
}
}
}
/// <summary>
/// 更新记录
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Button2_Click(object sender, EventArgs e)
{
CF.Model.InWarehouse model = new CF.Model.InWarehouse();
CF.BLL.InWarehouse bll = new CF.BLL.InWarehouse();
model.InID = int.Parse(InID.Text);
model.GoodsID = int.Parse(DropDownList1.SelectedValue);
model.AdminID = int.Parse(DropDownList2.SelectedValue);
model.InNumber = int.Parse(InNumber.Text.Trim());
model.InDate = DateTime.Now;
model.InQuantity = int.Parse(InQuantity.Text.Trim());
model.Price = Convert.ToDecimal(Price.Text.Trim());
//int priceTmp = model.Price * int.Parse(InQuantity.Text.Trim());
model.PriceAmount = model.Price * int.Parse(InQuantity.Text.Trim());
model.Stock = 0;
model.FHAdminID = -1;
model.IsInWarehouse = false;
model.Note = Note.Text.Trim();
model.InRank = 0;
model.Place = Place.Text.Trim();
bll.Update(model);
Label4.Text = "更新成功!";
GridViewBind();
InQuantity.Text = "";
Price.Text = "";
InNumber.Text = "";
Place.Text = "";
Button1.Visible = true;
Button2.Visible = false;
}
- 管理示例代码
- IOS内存管理示例代码
- 碟片管理系统代码重构示例
- 如何在Visual Studio中直接使用示例代码浏览器搜索下载和管理代码示例
- 代码示例
- 代码示例
- 示例代码
- 示例代码
- PHP5对Mysql5的任意数据库表的管理代码示例(一)
- PHP5对Mysql5的任意数据库表的管理代码示例(二)
- PHP5对Mysql5的任意数据库表的管理代码示例(三)
- PHP5对Mysql5的任意数据库表的管理代码示例(四)
- 用泛型技术对业务管理Bean抽象_实现_测试(代码示例)
- ASP.NET MVC4 菜鸟项目之路(一)改造示例代码扩展用户信息管理
- ASP.NET MVC4 菜鸟项目之路(一)改造示例代码扩展用户信息管理
- ASP.NET MVC4 菜鸟项目之路(一)改造示例代码扩展用户信息管理
- oracle数据库创建用户、 创建角色和权限管理代码示例
- 表目管理代码示例(迸发访问,多重索引查找,添加,删除,)
- 爱
- 新发现的游戏开发专业站点 www.yidongyou.com 游戏开发资料很多嘛
- 惹恼程序员的十件事情
- 技术的突破--公司快速开发平台研发
- 通过底层驱动破解正版地图
- 管理示例代码
- 再读《华为真相》,剖析中国IT企业核心竞争力
- 采购作业
- setTimeout( )
- DataTable、DataView、DataSet 区别
- .net 久违了!
- js 操作Select标记
- Visual Studio 2005和Visual Studio 2008 WEB开发时实现拖动控件放在绝对位置(所见即所得)
- 套接字I/O模型之四重叠I/O