📄 addbookcount.aspx.cs
字号:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using OnlineBookSell.BLLFactory;
using OnlineBookSell.Model;
using OnlineBookSell.IBLL;
using OnlineBookSell.DBUtility;
public partial class ljian_admin_book_addbookcount : System.Web.UI.Page
{
private IBookBLL ibookbll = BLLFactory.getInstance().createBookBLL();
private static IList<BookInfo> booklist = new List<BookInfo>();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void list_onitemcommand(object source, RepeaterCommandEventArgs e)
{
for (int i = 0; i < booklist.Count;i++ )
{
if (booklist[i].Isbn == e.CommandArgument.ToString())
booklist.Remove(booklist[i]);
}
list.DataSource = booklist;
list.DataBind();
}
protected void isbn_TextChanged(object sender, EventArgs e)
{
if (isbn.Text.Trim() != "")
{
using (SqlDataReader r = SQLHelper.ExecuteReader(SQLHelper .ConnectionStringLocalTransaction,CommandType.Text,"select * from bookinfo where isbn='"+isbn .Text .Trim ()+"'"))
{
if (r.Read())
add.Enabled = true;
else
{
System.Web.UI.ScriptManager.RegisterClientScriptBlock(this.add, this.add.GetType(), "success", "alert('该书还未编目,请先编目!');", true);
add.Enabled = false;
return;
}
}
BookInfo book = ibookbll.GetBookByISBN(isbn.Text .Trim ());
id.Text = book.Id.ToString ();
classid.Text = book.BookconcernID.ToString();
bookname.Text = book.Bookname;
bookclass.Text = book.Class1name;
bookclass.ForeColor = System.Drawing.Color.Red;
agocost.Text = book.Cost.ToString();
booknum.Text = "";
}
}
protected void add2_Click(object sender, EventArgs e)
{
if (booklist.Count == 0)
{
System.Web.UI.ScriptManager.RegisterClientScriptBlock(this.add, this.add.GetType(), "success", "alert('进货单为空,请先添加书目!');", true);
return;
}
string orderid = DateTime.Now.ToString().Replace("-", "").Replace(" ", "").Replace (":","");
foreach (BookInfo bi in booklist)
{
int num = SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionStringLocalTransaction, CommandType.Text, "insert into bookbuyin (orderid,bookid,concernid,num,updatecost,nowcost,agocost,addtime)values('"+orderid+"',"+bi.Id+","+bi.BookconcernID +","+bi.Stocks +","+bi.Cost +","+bi.Nowcost +","+bi.Agocost +",'"+DateTime .Now +"')");
if (num <= 0)
{
System.Web.UI.ScriptManager.RegisterClientScriptBlock(this.add, this.add.GetType(), "success", "alert('发生错误,请重试!');", true);
return;
}
}
System.Web.UI.ScriptManager.RegisterClientScriptBlock(this.add2, this.add2.GetType(), "success", "alert('入库成功,系统将自动调整变更书目的价格!');", true);
BookInfo b = null;
foreach (BookInfo bi in booklist)
{
b=ibookbll.GetBookById(bi.Id);
b.Cost = bi.Cost;
SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionStringLocalTransaction,CommandType.Text,"update book set cost="+bi.Cost +",stocks=stocks+"+bi.Stocks +" where bookid="+bi.Id);
}
}
protected void add_Click(object sender, EventArgs e)
{
foreach (BookInfo bi in booklist)
{
if (bi.Isbn == isbn.Text.Trim())
{
bi.Stocks = bi.Stocks + Convert.ToInt32(booknum.Text .Trim ());
list.DataSource = booklist;
list.DataBind();
return;
}
}
BookInfo book = new BookInfo();
book.Id = Convert.ToInt32(id.Text);
book.BookconcernID = Convert.ToInt32(classid.Text);
book.Isbn = isbn.Text.Trim();
book.Bookname = bookname.Text.Trim();
book.Class1name = bookclass.Text;
book.Stocks = Convert.ToInt32(booknum.Text.Trim ());
book.Nowcost = Convert.ToDouble (nowcost .Text .Trim ());
book.Cost = Convert.ToDouble(cost.Text.Trim());
book.Agocost = Convert.ToDouble(agocost.Text.Trim());
booklist.Add(book);
list.DataSource = booklist;
list.DataBind();
add.Enabled = false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -