protected void ButtonPrint_Barcode_Click(object sender, EventArgs e) { string barcode = ""; //barcode = ((Button)sender).CommandArgument.ToString(); GridViewRow row = (GridViewRow)(((Button)sender).NamingContainer); Label barcodelabel = (Label)row.FindControl("BookBarcode"); barcode = barcodelabel.Text; //Barcode generation test if (barcode != "") { MyBarcodeGenerator.Generate(barcode); DataTable dt = new DataTable(); dt.Columns.Add("name"); DataRow dr = dt.NewRow(); dr["name"] = barcode + ".jpg"; dt.Rows.Add(dr); DataListbookbarcode.Enabled = true; DataListbookbarcode.DataSource = dt; DataListbookbarcode.DataBind(); BindDataTogvResult(); // Button buttonprint = (Button)row.FindControl("Button2"); //ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>doPrint();</script>"); //Response.Write("<script>alert('" + barcode + "')</script>"); //var barcodeImage = MyBarcodeGenerator.Generate(barcode) as System.Drawing.Image; //MyBarcodeGenerator.ShowBarcode(barcode, this.Response); } else { Response.Write("<script>alert('Error!')<script/>"); } }
/* protected int bind() * { * //MyBarcodeGenerator.Generate(barcode); * DataTable dt = new DataTable(); * dt.Columns.Add("name"); * DataRow dr = dt.NewRow(); * dr["name"] = "0000000091000.jpg"; * dt.Rows.Add(dr); * DataListbookbarcode.Enabled = true; * DataListbookbarcode.DataSource = dt; * DataListbookbarcode.DataBind(); * return 0; * }*/ protected int deletebind() { DataListbookbarcode.Enabled = false; DataListbookbarcode.DataSource = null; DataListbookbarcode.DataBind(); return(0); }
protected void ButtonPrint_Click(object sender, EventArgs e) { string to_barcode = ""; GridViewRow row = (GridViewRow)(((Button)sender).NamingContainer); Label barcodelabel = (Label)row.FindControl("BookBarcode"); to_barcode = barcodelabel.Text; if (to_barcode != "") { DataListbookbarcode.Enabled = false; DataListbookbarcode.DataSource = null; DataListbookbarcode.DataBind(); BindDataTogvResult(); MyBarcodeGenerator.Generate(to_barcode); Session["info_barcode"] = to_barcode; Response.AddHeader("Refresh", "0"); Response.Redirect("BarcodePrint.aspx"); return; } }
protected int flag = 0;//1--Barcode,2--info_barcode protected void Page_Load(object sender, EventArgs e) { if (!this.Page.IsPostBack) { if (Session["Barcode"] != null) { string[] al = Session["Barcode"] as string[]; DataTable dt = new DataTable(); dt.Columns.Add("name"); foreach (string barcode in al) { DataRow dr = dt.NewRow(); dr["name"] = barcode + ".jpg"; dt.Rows.Add(dr); } DataListbookbarcode.Enabled = true; DataListbookbarcode.DataSource = dt; DataListbookbarcode.DataBind(); Session["Barcode"] = null; Session.Remove("Barcode"); flag = 1; } if (Session["info_barcode"] != null) { string barcode = Session["info_barcode"].ToString(); DataTable dt = new DataTable(); dt.Columns.Add("name"); DataRow dr = dt.NewRow(); dr["name"] = barcode + ".jpg"; dt.Rows.Add(dr); DataListbookbarcode.Enabled = true; DataListbookbarcode.DataSource = dt; DataListbookbarcode.DataBind(); Session["info_barcode"] = null; Session.Remove("info_barcode"); flag = 2; } //this.Page.RegisterClientScriptBlock(typeof(this),"","window.onload=doPrint(0"); } }
protected void Page_Load(object sender, EventArgs e) { DataListbookbarcode.Enabled = false; DataListbookbarcode.DataSource = null; DataListbookbarcode.DataBind(); if (!this.IsPostBack) { string bookId = Request["book_id"]; string OLMSDBConnectionString = ConfigurationManager.ConnectionStrings["OLMSDB"].ConnectionString; MySqlConnection OLMSDBConnection = new MySqlConnection(OLMSDBConnectionString); try { string book_id_sql = "select * from Books where BookId=" + bookId; OLMSDBConnection.Open(); MySqlCommand cmd1 = new MySqlCommand(book_id_sql, OLMSDBConnection); ArrayList books_list = new ArrayList(); MySqlDataReader reader = cmd1.ExecuteReader(); while (reader.Read()) { if (reader.HasRows) { Image1.ImageUrl = reader["ImageURL"].ToString(); TextBoxtitle.Text = reader["Title"].ToString(); TextBoxauthor.Text = reader["Author"].ToString(); TextBoxpubdate.Text = Convert.ToDateTime(reader["PubDate"]).ToString("yyyy-MM-dd"); TextBoxprice.Text = reader["Price"].ToString(); TextBoxisbn13.Text = reader["ISBN13"].ToString(); TextBoxisbn10.Text = reader["ISBN10"].ToString(); TextBoxpages.Text = reader["Pages"].ToString(); TextBoxpublisher.Text = reader["Publisher"].ToString(); } } reader.Close(); ////////////////////////////////////////////////图书位置信息///////////////////////////////////////// string shelfid = ""; string stackid = ""; string book_shelfid = "select Shelfid from BookBarcodes where BookId='" + bookId + "';"; MySqlCommand cmd2 = new MySqlCommand(book_shelfid, OLMSDBConnection); MySqlDataReader reader1 = cmd2.ExecuteReader(); while (reader1.Read()) { if (reader1.HasRows) { shelfid = reader1["Shelfid"].ToString(); break; } } reader1.Close(); //原书本位置 /* string book_stackid = "select StackId from Shelves where ShelfId='" + shelfid + "';"; * MySqlCommand cmd3 = new MySqlCommand(book_stackid, OLMSDBConnection); * MySqlDataReader reader2 = cmd3.ExecuteReader(); * if (reader2.Read()) * { * stackid = reader2["StackId"].ToString(); * } * reader2.Close(); * DropDownList1.Items.Add(shelfid + "," + stackid); * string additems = "select ShelfId,StackId from Shelves where ShelfId<>'" + shelfid + "';"; * MySqlCommand cmdadditems = new MySqlCommand(additems, OLMSDBConnection); * MySqlDataReader reader3 = cmdadditems.ExecuteReader(); * while (reader3.Read()) * { * DropDownList1.Items.Add(reader3["ShelfId"].ToString() + "," + reader3["StackId"].ToString()); * } * reader3.Close();*/ ////////////////////////////////////////////////Barcode表///////////////////////////////////////// BindDataTogvResult(); Bindtocategory(); } catch (MySqlException ex) { Console.WriteLine(ex.Message); } finally { OLMSDBConnection.Close(); } } }