protected void databind3() { string text = ListBox5.SelectedItem.ToString(); ListBox6.DataSource = Roles.GetUsersInRole(text); ListBox6.DataBind(); }
protected void Button2_Click(object sender, EventArgs e) { int r = ListBox7.SelectedIndex; ListBox7.Items.RemoveAt(r); ListBox8.Items.RemoveAt(r); int p = Convert.ToInt32(ListBox9.Items[r].Text); ListBox9.Items.RemoveAt(r); x -= p; Label1.Text = x.ToString(); ListBox6.ClearSelection(); }
private void Fillshiftdrp() { string strSql = "select SHIFT_ID,replace(convert(char(31),ltrim(SHIFT_ID))+SHIFT_DESCRIPTION,' ','�' ) as SHIFTNAME from ta_shift where SHIFT_ISDELETED='0'"; SqlConnection con = new SqlConnection(m_connectons); con.Open(); SqlCommand cmd = new SqlCommand(strSql, con); SqlDataAdapter adpt = new SqlDataAdapter(cmd); DataSet thisDataSet = new DataSet(); adpt.Fill(thisDataSet); ListBox6.DataValueField = "SHIFT_ID"; ListBox6.DataTextField = "SHIFTNAME"; ListBox6.DataSource = thisDataSet.Tables[0]; ListBox6.DataBind(); }
protected void Button5_Click(object sender, EventArgs e) // all pair { var accounts1 = new Dictionary <string, int>(); accounts1["Gilgit"] = 0; accounts1["Chitral"] = 1; accounts1["Dasu"] = 2; accounts1["Dir"] = 3; accounts1["Malakand"] = 4; accounts1["Noshera"] = 5; accounts1["Mansehra"] = 6; accounts1["Hassan Abdal"] = 7; accounts1["Peshawar"] = 8; accounts1["Attock"] = 9; accounts1["Kohat"] = 10; accounts1["Islamabad"] = 11; accounts1["Murree"] = 12; accounts1["Rawat"] = 13; accounts1["Balkasar"] = 14; accounts1["Chakwal"] = 15; accounts1["Mianwali"] = 16; accounts1["Bhera"] = 17; accounts1["Sargoda"] = 18; accounts1["Pindi Bhattian"] = 19; accounts1["Jhang"] = 20; accounts1["Faisalabad"] = 21; accounts1["Lahore"] = 22; accounts1["Dina"] = 23; accounts1["Gujranwala"] = 24; accounts1["Multan"] = 25; accounts1["DG Khan"] = 26; accounts1["Bahwalpur"] = 27; accounts1["Sukkur"] = 28; accounts1["Rajanpur"] = 29; accounts1["Loralai"] = 30; accounts1["Jacobabad"] = 31; accounts1["Quetta"] = 32; accounts1["Khuzdar"] = 33; accounts1["Karachi"] = 34; accounts1["Lasbela"] = 35; accounts1["Gwadar"] = 36; accounts1["Awaran"] = 37; accounts1["Turbat"] = 38; var accounts = new Dictionary <int, string>(); accounts[0] = "Gilgit"; accounts[1] = "Chitral"; accounts[2] = "Dasu"; accounts[3] = "Dir"; accounts[4] = "Malakand"; accounts[5] = "Noshera"; accounts[6] = "Mansehra"; accounts[7] = "Hassan Abdal"; accounts[8] = "Peshawar"; accounts[9] = "Attock"; accounts[10] = "Kohat"; accounts[11] = "Islamabad"; accounts[12] = "Murree"; accounts[13] = "Rawat"; accounts[14] = "Balkasar"; accounts[15] = "Chakwal"; accounts[16] = "Mianwali"; accounts[17] = "Bhera"; accounts[18] = "Sargoda"; accounts[19] = "Pindi Bhattian"; accounts[20] = "Jhang"; accounts[21] = "Faisalabad"; accounts[22] = "Lahore"; accounts[23] = "Dina"; accounts[24] = "Gujranwala"; accounts[25] = "Multan"; accounts[26] = "DG Khan"; accounts[27] = "Bahwalpur"; accounts[28] = "Sukkur"; accounts[29] = "Rajanpur"; accounts[30] = "Loralai"; accounts[31] = "Jacobabad"; accounts[32] = "Quetta"; accounts[33] = "Khuzdar"; accounts[34] = "Karachi"; accounts[35] = "Lasbela"; accounts[36] = "Gwadar"; accounts[37] = "Awaran"; accounts[38] = "Turbat"; string src = TextBox4.Text; string dst = TextBox5.Text; int src1 = accounts1[src]; int dst1 = accounts1[dst]; string res = findpath(D, src1, dst1, 39); string[] values = res.Split(','); for (int i = 0; i < values.Length; i++) { values[i] = values[i].Trim(); } //Label1.Text = values[0]; // Label2.Text = accounts[3]; for (int i = 0; i < values.Length - 1; i++) { values[i] = accounts[Convert.ToInt32(values[i])]; } ListBox6.DataSource = values; ListBox6.DataBind(); Page.ClientScript.RegisterStartupScript(this.GetType(), "script", " <script>allpairoshrt();</script>"); }
/// <summary> /// 绑定下拉框的数据 /// </summary> public void refredatabind() { ListItem lt1 = new ListItem(); lt1.Value = ""; /* 绑定供应商 */ List <Provider> ps = new DAL.ProviderDAO().getAllProviders(); ListBox6.DataSource = ps; ListBox6.DataTextField = "providerName"; ListBox6.DataValueField = "providerNum"; ListBox6.DataBind(); ListBox6.Items.Add(lt1); ListBox6.SelectedValue = ""; /* 绑定库柜 */ List <Chest> cs = new DAL.ChestDAO().getAllChests(); ListBox4.DataSource = cs; ListBox4.DataTextField = "chestName"; ListBox4.DataValueField = "chestNum"; ListBox4.DataBind(); ListBox4.Items.Add(lt1); ListBox4.SelectedValue = ""; /* 绑定经办人 */ List <SysUser> sys = new DAL.SysUserDAO().getAllUsers(); ListBox5.DataSource = sys; ListBox5.DataTextField = "userId"; ListBox5.DataValueField = "staffnum"; ListBox5.DataBind(); ListBox5.Items.Add(lt1); ListBox5.SelectedValue = ""; /* 绑定物品类别第一项 */ List <GoodsType> gts = new DAL.GoodsTypeDAO().getParentGoodsTypes(); ListBox1.DataSource = gts; ListBox1.DataTextField = "goodsTypeName"; ListBox1.DataValueField = "goodsTypeNum"; ListBox1.DataBind(); ListBox1.Items.Add(lt1); ListBox1.SelectedValue = ""; /* 绑定gridview数据源 */ BoundField bf1 = new BoundField(); bf1.HeaderText = "序号"; BoundField bf2 = new BoundField(); bf2.DataField = "inID"; bf2.HeaderText = "编号"; BoundField bf3 = new BoundField(); bf3.DataField = "goods.goodsName"; bf3.HeaderText = "物品名称"; BoundField bf4 = new BoundField(); bf4.DataField = "goods.goodsType.goodsTypeName"; bf4.HeaderText = "物品类别"; BoundField bf5 = new BoundField(); bf5.DataField = "position.positionNum"; bf5.HeaderText = "库位编号"; BoundField bf6 = new BoundField(); bf6.DataField = "date"; bf6.HeaderText = "入库时间"; BoundField bf7 = new BoundField(); bf7.DataField = "inAmount"; bf7.HeaderText = "入库量"; BoundField bf8 = new BoundField(); bf8.DataField = "batch.provider.providername"; bf8.HeaderText = "供应商"; BoundField bf9 = new BoundField(); bf9.DataField = "sysuser.staff.staffname"; bf9.HeaderText = "经办人"; GridView1.Columns.Add(bf1); GridView1.Columns.Add(bf2); GridView1.Columns.Add(bf3); GridView1.Columns.Add(bf4); GridView1.Columns.Add(bf5); GridView1.Columns.Add(bf6); GridView1.Columns.Add(bf7); GridView1.Columns.Add(bf8); GridView1.Columns.Add(bf9); BoundField bf11 = new BoundField(); bf11.HeaderText = "序号"; BoundField bf12 = new BoundField(); bf12.DataField = "ouID"; bf12.HeaderText = "编号"; BoundField bf13 = new BoundField(); bf13.DataField = "goods.goodsName"; bf13.HeaderText = "物品名称"; BoundField bf14 = new BoundField(); bf14.DataField = "goods.goodsType.goodsTypeName"; bf14.HeaderText = "物品类别"; BoundField bf15 = new BoundField(); bf15.DataField = "position.positionNum"; bf15.HeaderText = "库位编号"; BoundField bf16 = new BoundField(); bf16.DataField = "date"; bf16.HeaderText = "出库时间"; BoundField bf17 = new BoundField(); bf17.DataField = "outAmount"; bf17.HeaderText = "出库量"; BoundField bf18 = new BoundField(); bf18.DataField = "batch.receiver.receivername"; bf18.HeaderText = "收货商"; BoundField bf19 = new BoundField(); bf19.DataField = "sysuser.staff.staffname"; bf19.HeaderText = "经办人"; GridView2.Columns.Add(bf11); GridView2.Columns.Add(bf12); GridView2.Columns.Add(bf13); GridView2.Columns.Add(bf14); GridView2.Columns.Add(bf15); GridView2.Columns.Add(bf16); GridView2.Columns.Add(bf17); GridView2.Columns.Add(bf18); GridView2.Columns.Add(bf19); }
void UpdateBookByID() { try { int actual_stock = Convert.ToInt32(TextBox10.Text.Trim()); int current_stock = Convert.ToInt32(TextBox11.Text.Trim()); if (global_actual_stock == actual_stock) { } else { if (actual_stock < global_issued_books) { Response.Write("<script>alert('Actual stock value can not be less than the issued books');</script>"); return; } else { current_stock = actual_stock - global_issued_books; TextBox8.Text = "" + current_stock; } } string genres = ""; foreach (int i in ListBox6.GetSelectedIndices()) { genres = genres + ListBox6.Items[i] + ";"; } genres = genres.Remove(genres.Length - 1); string filepath = "~/images/BookInventory/books1"; string filename = Path.GetFileName(FileUpload1.PostedFile.FileName); if (filename == "" || filename == null) { filepath = global_filepath; } else { FileUpload1.SaveAs(Server.MapPath("images/BookInventory/" + filename)); filepath = "~/images/BookInventory/" + filename; } SqlConnection conn = new SqlConnection(constr); //checking whether the connection is open or not if (conn.State == ConnectionState.Closed) { conn.Open(); } SqlCommand cmd = new SqlCommand("UPDATE book_tbl SET book_name=@bnm, genre=@gn, author_name=@an, publisher_name=@pn, publish_date=@pd, language=@lan, eddition=@edd, book_cost=@bc, no_of_pages=@pgs, book_description=@bdes, actual_stock=@astk, current_stock=@cstk, book_img_link=@blnk WHERE book_id='" + TextBox12.Text.Trim() + "'", conn); cmd.Parameters.AddWithValue("@bnm", TextBox13.Text.Trim()); cmd.Parameters.AddWithValue("@gn", genres); cmd.Parameters.AddWithValue("@an", DropDownList3.SelectedItem.Value); cmd.Parameters.AddWithValue("@pn", DropDownList2.SelectedItem.Value); cmd.Parameters.AddWithValue("@pd", TextBox1.Text.Trim()); cmd.Parameters.AddWithValue("@lan", DropDownList1.SelectedItem.Value); cmd.Parameters.AddWithValue("@edd", TextBox7.Text.Trim()); cmd.Parameters.AddWithValue("@bc", TextBox8.Text.Trim()); cmd.Parameters.AddWithValue("@pgs", TextBox9.Text.Trim()); cmd.Parameters.AddWithValue("@bdes", TextBox2.Text.Trim()); cmd.Parameters.AddWithValue("@astk", actual_stock.ToString()); cmd.Parameters.AddWithValue("@cstk", current_stock.ToString()); cmd.Parameters.AddWithValue("@blnk", filepath); cmd.ExecuteNonQuery(); conn.Close(); GridView1.DataBind(); Response.Write("<script>alert('Book Updated successfully');</script>"); } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); } }
void GetBookByID() { try { SqlConnection conn = new SqlConnection(constr); //checking whether the connection is open or not if (conn.State == ConnectionState.Closed) { conn.Open(); } SqlCommand cmd = new SqlCommand("SELECT author_name FROM author_tbl;", conn); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); DropDownList3.DataSource = dt; DropDownList3.DataValueField = "author_name"; DropDownList3.DataBind(); cmd = new SqlCommand("SELECT * FROM book_tbl WHERE book_id='" + TextBox12.Text.Trim() + "';", conn); da = new SqlDataAdapter(cmd); dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count >= 1) { TextBox13.Text = dt.Rows[0]["book_name"].ToString().Trim(); TextBox1.Text = dt.Rows[0]["publish_date"].ToString().Trim(); TextBox7.Text = dt.Rows[0]["eddition"].ToString().Trim(); TextBox8.Text = dt.Rows[0]["book_cost"].ToString().Trim(); TextBox9.Text = dt.Rows[0]["no_of_pages"].ToString().Trim(); TextBox2.Text = dt.Rows[0]["book_description"].ToString(); TextBox10.Text = dt.Rows[0]["actual_stock"].ToString().Trim(); TextBox11.Text = dt.Rows[0]["current_stock"].ToString().Trim(); TextBox14.Text = "" + (Convert.ToInt32(dt.Rows[0]["current_stock"].ToString()) - Convert.ToInt32(dt.Rows[0]["actual_stock"].ToString())); DropDownList1.SelectedValue = dt.Rows[0]["language"].ToString().Trim(); DropDownList2.SelectedValue = dt.Rows[0]["publisher_name"].ToString().Trim(); DropDownList3.SelectedValue = dt.Rows[0]["author_name"].ToString().Trim(); //filling genre multi-select listbox details string[] genre = dt.Rows[0]["genre"].ToString().Trim().Split(';'); ListBox6.ClearSelection(); for (int i = 0; i < genre.Length; i++) { for (int j = 0; j < ListBox6.Items.Count; j++) { if (ListBox6.Items[j].ToString() == genre[i]) { ListBox6.Items[j].Selected = true; } } }//genre filling ends here global_actual_stock = Convert.ToInt32(dt.Rows[0]["actual_stock"].ToString().Trim()); global_current_stock = Convert.ToInt32(dt.Rows[0]["current_stock"].ToString().Trim()); global_issued_books = global_current_stock - global_current_stock; global_filepath = dt.Rows[0]["book_img_link"].ToString().Trim(); } else { Response.Write("<script>alert('Invalid book id');</script>"); } } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); } }
void AddNewBook() { if (TextBox12.Text.Trim() == "" || TextBox12.Text.Trim() == null) { Response.Write("<script>alert('Please enter a valid book id');</script>"); } else { try { string genres = ""; foreach (int i in ListBox6.GetSelectedIndices()) { genres = genres + ListBox6.Items[i] + ";"; } genres = genres.Remove(genres.Length - 1); string filepath = "~/images/BookInventory/book1.png"; string filename = Path.GetFileName(FileUpload1.PostedFile.FileName); FileUpload1.SaveAs(Server.MapPath("images/BookInventory/" + filename)); filepath = "~/images/BookInventory/" + filename; SqlConnection conn = new SqlConnection(constr); //checking whether the connection is open or not if (conn.State == ConnectionState.Closed) { conn.Open(); } SqlCommand cmd = new SqlCommand("INSERT INTO book_tbl (book_id, book_name, genre, author_name, publisher_name, publish_date, language,eddition, book_cost, no_of_pages, book_description, actual_stock, current_stock, book_img_link) VALUES(@bid, @bnm, @gn, @an, @pn, @pd, @lan, @edd, @bc, @pgs, @bdes, @astk, @cstk, @blnk);", conn); cmd.Parameters.AddWithValue("@bid", TextBox12.Text.Trim()); // cmd.Parameters.AddWithValue("@bnm", TextBox13.Text.Trim()); // cmd.Parameters.AddWithValue("@gn", genres); cmd.Parameters.AddWithValue("@an", DropDownList3.SelectedItem.Value); // cmd.Parameters.AddWithValue("@pn", DropDownList2.SelectedItem.Value); // cmd.Parameters.AddWithValue("@pd", TextBox1.Text.Trim()); // cmd.Parameters.AddWithValue("@lan", DropDownList1.SelectedItem.Value); // cmd.Parameters.AddWithValue("@edd", TextBox7.Text.Trim()); // cmd.Parameters.AddWithValue("@bc", TextBox8.Text.Trim()); // cmd.Parameters.AddWithValue("@pgs", TextBox9.Text.Trim()); // cmd.Parameters.AddWithValue("@bdes", TextBox2.Text.Trim()); // cmd.Parameters.AddWithValue("@astk", TextBox10.Text.Trim()); // cmd.Parameters.AddWithValue("@cstk", TextBox10.Text.Trim()); cmd.Parameters.AddWithValue("@blnk", filepath); cmd.ExecuteNonQuery(); conn.Close(); Response.Write("<script>alert('A new book added successfully');</script>"); GridView1.DataBind(); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); } } }