protected void Button5_Click(object sender, EventArgs e) { ListItem itm = ListBox2.SelectedItem; Label4.Text = " "; KeyValuePair <int, int> r = lst1.SingleOrDefault(x => x.Key == Convert.ToInt32(itm.Value)); //Label3.Text = r.Key.ToString(); ProductService.IproductsClient client = new ProductService.IproductsClient(); ProductService.Product p = client.GetProduct(Convert.ToInt32(itm.Value)); total -= r.Value * p.ProductPrice; Label5.Text = total.ToString(); lst1.Remove(r); Label4.Text = ""; foreach (var element in lst1) { Label4.Text += element; } ListBox2.Items.Remove(ListBox2.SelectedItem); ListBox1.Items.Add(itm); ListBox1.ClearSelection(); }
protected void SeleccionarEquipoTrabajoAcreditador(int codigoProyecto, bool selectTeam = true) { bool seleccionoAlguien = false; var equipoTrabajo = Negocio.PlanDeNegocioV2.Utilidad.ProyectoGeneral.GetEquipoTrabajo(codigoProyecto); ListBox1.ClearSelection(); foreach (Int32 integrante in equipoTrabajo) { var contacto = ListBox1.Items.FindByValue(integrante.ToString()); if (contacto != null) { contacto.Selected = selectTeam; seleccionoAlguien = true; } } if (selectTeam && seleccionoAlguien) { PlanDeNegocioV2.Formulacion.Utilidad.Utilidades.PresentarMsj("Se seleccionó el emprendedor del proyecto.", this, "Alert"); } else { PlanDeNegocioV2.Formulacion.Utilidad.Utilidades.PresentarMsj("El proyecto no cuenta con emprendedores activos.", this, "Alert"); } }
protected void Button1_Click(object sender, EventArgs e) { SqlConnection conn = new SqlConnection("Data Source= .\\sql19; Initial Catalog = ComputerStore; Persist Security Info = True; User ID = ProjectUser; Password = 123"); String sql; sql = "SELECT * FROM product where name ='" + TextBox2.Text + "' "; SqlCommand comm = new SqlCommand(sql, conn); conn.Open(); SqlDataReader reader = comm.ExecuteReader(); if (reader.Read()) { TextBox1.Text = Convert.ToString((int)reader["Id"]); TextBox3.Text = Convert.ToString((int)reader["price"]); TextBox4.Text = Convert.ToString((int)reader["quantity"]); RadioButton2.Checked = (Boolean)reader["NoDiscount"]; RadioButton1.Checked = (Boolean)reader["WithDiscount"]; ListBox1.SelectedValue = (string)reader["category"]; Label1.Visible = true; Label1.Text = "Item Selected"; } else { TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; TextBox4.Text = ""; ListBox1.ClearSelection(); Label1.Visible = true; Label1.Text = "This name doesn't exist"; } reader.Close(); }
protected void Button2_Click(object sender, EventArgs e) { SqlConnection conn = new SqlConnection("Data Source= .\\sql19; Initial Catalog = ComputerStore; Persist Security Info = True; User ID = ProjectUser; Password = 123"); string sql; sql = "update product set name ='" + TextBox2.Text + "', price = '" + TextBox3.Text + "' ,WithDiscount = '" + RadioButton1.Checked + "',NoDiscount = '" + RadioButton2.Checked + "', quantity = '" + TextBox4.Text + "', category = '" + ListBox1.SelectedValue + "' where name ='" + TextBox2.Text + "'"; SqlCommand comm = new SqlCommand(sql, conn); try { conn.Open(); comm.ExecuteNonQuery(); TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; TextBox4.Text = ""; ListBox1.ClearSelection(); RadioButton2.Checked = false; RadioButton1.Checked = false; Label1.Visible = false; Label8.Visible = true; Label8.Text = "Item Updated"; } catch { Label1.Visible = false; Label8.Visible = true; Label8.Text = "No Name Found"; } finally { conn.Close(); } }
// tìm sách theo ID void getBookByID() { try { SqlConnection con = new SqlConnection(strcon); if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("SELECT * from book_master_tbl WHERE book_id='" + TextBox7.Text.Trim() + "';", con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count >= 1) { TextBox8.Text = dt.Rows[0]["book_name"].ToString(); TextBox4.Text = dt.Rows[0]["publisher_date"].ToString(); TextBox3.Text = dt.Rows[0]["edition"].ToString(); TextBox6.Text = dt.Rows[0]["cost"].ToString().Trim(); TextBox9.Text = dt.Rows[0]["pages"].ToString().Trim(); TextBox1.Text = dt.Rows[0]["actual_stock"].ToString().Trim(); TextBox2.Text = dt.Rows[0]["current_stock"].ToString().Trim(); TextBox5.Text = "" + (Convert.ToInt32(dt.Rows[0]["actual_stock"].ToString()) - Convert.ToInt32(dt.Rows[0]["current_stock"].ToString())); TextBox10.Text = dt.Rows[0]["book_description"].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(); ListBox1.ClearSelection(); string[] genre = dt.Rows[0]["genre"].ToString().Trim().Split(','); for (int i = 0; i < genre.Length; i++) { for (int j = 0; j < ListBox1.Items.Count; j++) { if (ListBox1.Items[j].ToString() == genre[i]) { ListBox1.Items[j].Selected = true; } } } 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_actual_stock - global_current_stock; global_filepath = dt.Rows[0]["book_img_link"].ToString(); } else { Response.Write("<script>alert('Mã sách không tồn tại!');</script>"); } } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); } }
void GetMovieByID() { try { SqlConnection con = new SqlConnection(strcon); //check connection is open with the database if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("SELECT * FROM movie_master_tbl WHERE movie_id='" + TextBox2.Text.Trim() + "';", con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count >= 1) { TextBox3.Text = dt.Rows[0]["movie_name"].ToString(); TextBox6.Text = dt.Rows[0]["publish_date"].ToString(); TextBox7.Text = dt.Rows[0]["year"].ToString(); TextBox8.Text = dt.Rows[0]["movie_cost"].ToString().Trim(); TextBox9.Text = dt.Rows[0]["duration"].ToString().Trim(); TextBox1.Text = dt.Rows[0]["actual_stock"].ToString().Trim(); TextBox4.Text = dt.Rows[0]["current_stock"].ToString().Trim(); TextBox10.Text = dt.Rows[0]["movie_description"].ToString(); TextBox5.Text = "" + (Convert.ToInt32(dt.Rows[0]["actual_stock"].ToString()) - Convert.ToInt32(dt.Rows[0]["current_stock"].ToString())); DropDownList1.SelectedValue = dt.Rows[0]["language"].ToString().Trim(); DropDownList2.SelectedValue = dt.Rows[0]["producer_name"].ToString().Trim(); DropDownList3.SelectedValue = dt.Rows[0]["director_name"].ToString().Trim(); string[] genre = dt.Rows[0]["genre"].ToString().Trim().Split(','); ListBox1.ClearSelection(); for (int i = 0; i < genre.Length; i++) { for (int j = 0; j < ListBox1.Items.Count; j++) { if (ListBox1.Items[j].ToString() == genre[i]) { ListBox1.Items[j].Selected = true; } } } 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_movies = global_actual_stock - global_current_stock; global_filepath = dt.Rows[0]["movie_img_link"].ToString(); } else { Response.Write("<script>alert('Invalid movie id');</script>"); } } catch (Exception ex) { } }
void GetBookID() { try { SqlConnection Connx = new SqlConnection(Conx); if (Connx.State == ConnectionState.Closed) { Connx.Open(); } SqlCommand cmd = new SqlCommand("Select * from Book_Master_tbl where " + "Book_Id = '" + TextBox1.Text.Trim() + "'", Connx); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count >= 1) //if dt datatable gets a row with the entered value { TextBox2.Text = dt.Rows[0]["Book_name"].ToString(); TextBox3.Text = dt.Rows[0]["Published_Date"].ToString(); TextBox4.Text = dt.Rows[0]["Edition"].ToString(); TextBox5.Text = dt.Rows[0]["book_cost"].ToString().Trim(); TextBox6.Text = dt.Rows[0]["No_of_Pages"].ToString().Trim(); TextBox7.Text = dt.Rows[0]["actual_stock"].ToString().Trim(); TextBox8.Text = dt.Rows[0]["Current_Stock"].ToString().Trim(); TextBox10.Text = dt.Rows[0]["Book_Description"].ToString(); TextBox9.Text = "" + (Convert.ToInt32(dt.Rows[0]["actual_stock"].ToString()) - Convert.ToInt32(dt.Rows[0]["current_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(); ListBox1.ClearSelection(); string[] Genre = dt.Rows[0]["Genre"].ToString().Trim().Split(','); for (int i = 0; i < Genre.Length; i++) { for (int j = 0; j < ListBox1.Items.Count; j++) { if (ListBox1.Items[j].ToString() == Genre[i]) { ListBox1.Items[j].Selected = true; } } } 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_actual_stock - global_current_stock; global_filepath = dt.Rows[0]["Book_img_Link"].ToString(); } else { Response.Write("<script>alert('Invalid Credentials');</script>"); } } catch (Exception ex) { MessageBox.Show("GetBookID" + ex.Message); } }
void getBookByID() { try { SqlConnection connection = new SqlConnection(connectionString); if (connection.State == ConnectionState.Closed) { connection.Open(); } SqlCommand sqlCmd = new SqlCommand("SELECT * FROM book_master_tbl WHERE book_id='" + TextBox1.Text.Trim() + "';", connection); SqlDataAdapter dataAdapter = new SqlDataAdapter(sqlCmd); DataTable dataTable = new DataTable(); dataAdapter.Fill(dataTable); if (dataTable.Rows.Count >= 1) { TextBox2.Text = dataTable.Rows[0]["book_name"].ToString(); TextBox3.Text = dataTable.Rows[0]["publish_date"].ToString(); TextBox9.Text = dataTable.Rows[0]["edition"].ToString(); TextBox10.Text = dataTable.Rows[0]["book_cost"].ToString().Trim(); TextBox11.Text = dataTable.Rows[0]["no_of_pages"].ToString().Trim(); TextBox4.Text = dataTable.Rows[0]["actual_stock"].ToString().Trim(); TextBox5.Text = dataTable.Rows[0]["current_stock"].ToString().Trim(); TextBox6.Text = dataTable.Rows[0]["book_description"].ToString(); TextBox7.Text = "" + (Convert.ToInt32(dataTable.Rows[0]["actual_stock"].ToString()) - Convert.ToInt32(dataTable.Rows[0]["current_stock"].ToString())); DropDownList1.SelectedValue = dataTable.Rows[0]["language"].ToString().Trim(); DropDownList2.SelectedValue = dataTable.Rows[0]["publisher_name"].ToString().Trim(); DropDownList3.SelectedValue = dataTable.Rows[0]["author_name"].ToString().Trim(); ListBox1.ClearSelection(); string[] genre = dataTable.Rows[0]["genre"].ToString().Trim().Split(','); for (int i = 0; i < genre.Length; i++) { for (int j = 0; j < ListBox1.Items.Count; j++) { if (ListBox1.Items[j].ToString() == genre[i]) { ListBox1.Items[j].Selected = true; } } } global_actual_stock = Convert.ToInt32(dataTable.Rows[0]["actual_stock"].ToString().Trim()); global_current_stock = Convert.ToInt32(dataTable.Rows[0]["current_stock"].ToString().Trim()); global_issued_books = global_actual_stock - global_current_stock; global_filepath = dataTable.Rows[0]["book_img_link"].ToString(); } else { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "toastr_message", "toastr.error('Invalid Book ID')", true); } } catch (Exception ex) { } }
void getBookByID() { try { SqlConnection con = new SqlConnection(strcon); if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("SELECT * from book_table WHERE BookId='" + TextBox1.Text.Trim() + "';", con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count >= 1) { TextBox2.Text = dt.Rows[0]["BookName"].ToString(); TextBox8.Text = dt.Rows[0]["Isbn"].ToString(); TextBox3.Text = dt.Rows[0]["publishDate"].ToString(); TextBox9.Text = dt.Rows[0]["edition"].ToString(); TextBox10.Text = dt.Rows[0]["sellingPrice"].ToString().Trim(); TextBox4.Text = dt.Rows[0]["actualStock"].ToString().Trim(); TextBox5.Text = dt.Rows[0]["currentStock"].ToString().Trim(); TextBox6.Text = dt.Rows[0]["bookDescription"].ToString(); TextBox7.Text = "" + (Convert.ToInt32(dt.Rows[0]["actualStock"].ToString()) - Convert.ToInt32(dt.Rows[0]["currentStock"].ToString())); DropDownList2.SelectedValue = dt.Rows[0]["PublisherName"].ToString().Trim(); DropDownList3.SelectedValue = dt.Rows[0]["Author"].ToString().Trim(); ListBox1.ClearSelection(); string[] genre = dt.Rows[0]["genre"].ToString().Trim().Split(','); for (int i = 0; i < genre.Length; i++) { for (int j = 0; j < ListBox1.Items.Count; j++) { if (ListBox1.Items[j].ToString() == genre[i]) { ListBox1.Items[j].Selected = true; } } } global_actual_stock = Convert.ToInt32(dt.Rows[0]["actualStock"].ToString().Trim()); global_current_stock = Convert.ToInt32(dt.Rows[0]["currentStock"].ToString().Trim()); global_issued_books = global_actual_stock - global_current_stock; global_filepath = dt.Rows[0]["bookImageLink"].ToString(); } else { Response.Write("<script>alert('Invalid Book ID');</script>"); } } catch (Exception ex) { } }
protected void ListBox3_TextChanged(object sender, EventArgs e) { PlaceHolder4.Visible = true; ListBox1.ClearSelection(); ListBox2.ClearSelection(); ddeven.Items.Clear(); int value = int.Parse(ListBox3.SelectedItem.Value); if (value == 3) { bindlist(value.ToString()); PlaceHolder1.Visible = true; PlaceHolder2.Visible = false; PlaceHolder3.Visible = false; ddeven.Items.Insert(0, new ListItem("显示二级菜单", "0")); ddeven.Items.Insert(1, new ListItem("点击事件", "click")); ddeven.Items.Insert(2, new ListItem("链接地址", "url")); } else { ddeven.Items.Insert(0, new ListItem("点击事件", "click")); ddeven.Items.Insert(1, new ListItem("链接地址", "url")); Cms.BLL.wx_menu wm = new Cms.BLL.wx_menu(); DataTable dt = wm.GetList("id=" + value).Tables[0]; if (dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; string type = dr["type"].ToString(); if (type == "click") { ddeven.SelectedValue = "click"; PlaceHolder1.Visible = false; PlaceHolder2.Visible = true; PlaceHolder3.Visible = false; tbkey.Text = dr["keys"].ToString(); tinfo.Value = dr["info"].ToString(); tcontent.Value = dr["content"].ToString(); } else { ddeven.SelectedValue = "url"; PlaceHolder1.Visible = false; PlaceHolder2.Visible = false; PlaceHolder3.Visible = true; tburl.Text = dr["url"].ToString(); } } } tbname.Text = ListBox3.SelectedItem.Text; }
protected void Wizard1_CancelButtonClick1(object sender, EventArgs e) { TextBox4.Text = String.Empty; TextBox5.Text = String.Empty; TextBox6.Text = String.Empty; RadioButtonList1.ClearSelection(); CheckBoxList1.ClearSelection(); ListBox1.ClearSelection(); Calendar1.SelectedDate = DateTime.Now; Result_Wizard.Text = ""; }
void getPhoneByID() { try { SqlConnection con = new SqlConnection(strcon); if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("SELECT * from cellphone_master_tbl WHERE cellphone_id='" + TextBox1.Text.Trim() + "';", con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count >= 1) { TextBox2.Text = dt.Rows[0]["cellphone_name"].ToString(); TextBox3.Text = dt.Rows[0]["release_date"].ToString(); TextBox9.Text = dt.Rows[0]["color"].ToString(); TextBox10.Text = dt.Rows[0]["price"].ToString().Trim(); TextBox11.Text = dt.Rows[0]["camera_quality"].ToString().Trim(); TextBox6.Text = dt.Rows[0]["phone_description"].ToString(); DropDownList1.SelectedValue = dt.Rows[0]["operating_system"].ToString().Trim(); DropDownList2.SelectedValue = dt.Rows[0]["model_name"].ToString().Trim(); DropDownList3.SelectedValue = dt.Rows[0]["brand_name"].ToString().Trim(); ListBox1.ClearSelection(); string[] specifications = dt.Rows[0]["specifications"].ToString().Trim().Split(','); for (int i = 0; i < specifications.Length; i++) { for (int j = 0; j < ListBox1.Items.Count; j++) { if (ListBox1.Items[j].ToString() == specifications[i]) { ListBox1.Items[j].Selected = true; } } } global_filepath = dt.Rows[0]["cellphone_img_link"].ToString(); } else { Response.Write("<script>alert('Invalid Phone ID');</script>"); } } catch (Exception ex) { } }
protected void Button1_Click(object sender, EventArgs e) { String sql; int OriginalPrice = 0; Boolean WithDiscount = true; Boolean NoDiscount = true; if (RadioButton1.Checked) { int DisPrice = (Convert.ToInt32(TextBox3.Text) * 50) / 100; OriginalPrice = DisPrice; WithDiscount = true; NoDiscount = false; } else { OriginalPrice = Convert.ToInt32(TextBox3.Text); WithDiscount = false; NoDiscount = true; } SqlConnection con = new SqlConnection("Data Source= .\\sql19; Initial Catalog = ComputerStore; Persist Security Info = True; User ID = ProjectUser; Password = 123"); sql = "insert into product(name,price,quantity,category,WithDiscount,NoDiscount) values ('" + TextBox2.Text + "','" + OriginalPrice + "','" + TextBox4.Text + "','" + ListBox1.SelectedValue + "','" + WithDiscount + "','" + NoDiscount + "')"; SqlCommand comm = new SqlCommand(sql, con); try { con.Open(); comm.ExecuteNonQuery(); con.Close(); Label1.Visible = true; Label1.Text = "Item Inserted"; TextBox2.Text = ""; TextBox3.Text = ""; TextBox4.Text = ""; ListBox1.ClearSelection(); RadioButton1.Checked = false; RadioButton2.Checked = false; } catch { Label1.Visible = true; Label1.Text = "something went wrong nothing was inserted"; } finally { con.Close(); } }
protected void ListBox3_SelectedIndexChanged(object sender, EventArgs e) { DataTable dt = new DataTable(); dt.Columns.Add("ProductName", System.Type.GetType("System.String")); dt.Columns.Add("CategoryName", System.Type.GetType("System.String")); dt.Columns.Add("SupplierName", System.Type.GetType("System.String")); ListBox1.ClearSelection(); ListBox2.ClearSelection(); ListBox4.ClearSelection(); ListBox5.ClearSelection(); ListBox6.Items.Clear(); // ListBox7.Items.Clear(); String selection = ListBox3.SelectedItem.Text; System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(); conn.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;" + @"Data source= C:\Users\OK\Documents\Ecafe.accdb"; conn.Open(); String my_querry1 = "select Item from Items where Type = '" + selection + "'"; OleDbCommand cmd1 = new OleDbCommand(my_querry1, conn); var dr1 = cmd1.ExecuteReader(); // MessageBox.Show("Query executed"); while (dr1.Read()) { ListBox6.Items.Add(dr1[0].ToString()); //MessageBox.Show(dr1[1].ToString()); } Label2.Text = selection; ListBox6.Visible = true; ListBox7.Visible = true; ListBox8.Visible = true; ListBox9.Visible = true; Label1.Visible = true; Label2.Visible = true; Label3.Visible = true; Label5.Visible = true; Label6.Visible = true; Label7.Visible = true; Label8.Visible = true; Label9.Visible = true; Label10.Visible = true; TextBox2.Visible = true; Button1.Visible = true; Button2.Visible = true; }
void ClearForm() { TextBox1.Text = ""; TextBox2.Text = ""; ListBox1.ClearSelection(); DropDownList3.ClearSelection(); DropDownList2.ClearSelection(); TextBox3.Text = ""; DropDownList1.ClearSelection(); TextBox4.Text = ""; TextBox5.Text = ""; TextBox7.Text = ""; TextBox8.Text = ""; TextBox6.Text = ""; TextBox10.Text = ""; }
protected void Button47_Click(object sender, EventArgs e) { TextBox9.Text = ""; string result = ""; foreach (ListItem li in ListBox1.Items) { result += li.Value + ","; } // Remove the trailing comma in the end TextBox9.Text = result.Remove(result.LastIndexOf(","), 1); ModalPopupExtender1.Hide(); showdropdown(); ListBox1.ClearSelection(); }
void getRezervationByNumber() { try { //cream un obiect con , cu parametrul strcon SqlConnection con = new SqlConnection(strcon); if (con.State == ConnectionState.Closed) { con.Open(); } //Trim = removes blankspaces SqlCommand cmd = new SqlCommand("SELECT * FROM Rezervare R FULL JOIN Plata P ON P.RezervareID = R.RezervareID FULL JOIN Bilet B ON B.RezervareID = R.RezervareID LEFT JOIN Film F ON F.FilmID = B.FilmID WHERE R.NumarRezervare ='" + TextBox1.Text.Trim() + "' ", con); //verificam daca exista rezervarea SqlDataAdapter da = new SqlDataAdapter(cmd); //pasam cmd de la query DataTable dt = new DataTable(); da.Fill(dt); // umplem tabela =temporara dt cu orice primeste din SELECT //fetch and fills the datatable if (dt.Rows.Count >= 1) // exista o rezervare deja { TextBox3.Text = dt.Rows[0][2].ToString(); TextBox4.Text = dt.Rows[0]["TitluFilm"].ToString(); ListBox1.ClearSelection(); string[] Scaun = dt.Rows[0]["NumarScaun"].ToString().Trim().Split(','); for (int i = 0; i < Scaun.Length; i++) { for (int j = 0; j < ListBox1.Items.Count; j++) { if (ListBox1.Items[j].ToString() == Scaun[i]) { ListBox1.Items[j].Selected = true; } } } } else { Response.Write("<script>alert('Rezervare invalida');</script>"); } } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); } }
void ClearText() { TextBox2.Text = ""; TextBox1.Text = ""; TextBox3.Text = ""; TextBox9.Text = ""; TextBox10.Text = ""; TextBox11.Text = ""; TextBox4.Text = ""; TextBox5.Text = ""; TextBox6.Text = ""; TextBox7.Text = ""; ListBox1.ClearSelection(); DropDownList1.SelectedValue = ""; DropDownList2.SelectedValue = ""; DropDownList3.SelectedValue = ""; }
protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e) { try { Button1.Enabled = true; Button2.Enabled = false; string jesus = ListBox1.SelectedItem.Value; SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\Serverdatabase.mdf;Integrated Security=True;User Instance=True"); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; string sql; sql = "select * from lectureReg where Lecture_id ='" + jesus + "'"; cmd.CommandText = sql; con.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { lblID.Text = dr["Lecture_id"].ToString(); lblName.Text = dr["Lecturer_Name"].ToString(); lblDept.Text = dr["Experience_Stream"].ToString(); lblSubject.Text = dr["Subject"].ToString(); lblEmpID.Text = lblID.Text; lblEmpName.Text = lblName.Text; } else { dr.Close(); Button1.Enabled = false; Button2.Enabled = false; lblID.Text = ""; lblName.Text = ""; lblDept.Text = ""; lblSubject.Text = ""; } } catch (IndexOutOfRangeException ex) { ListBox1.ClearSelection(); Response.Write("Message From Manjunath:" + ex); } catch (SqlException sql) { Response.Write("Message From Manjunath:" + sql); } }
void GetMovieByTitle() { try { SqlConnection con = new SqlConnection(strcon); if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("SELECT * FROM Film where TitluFilm = '" + TextBox1.Text.Trim() + "'", con); SqlDataAdapter da = new SqlDataAdapter(cmd); //cream un data table, il umplem, deci adapterul adapteaza outputul lui cmd. DataTable dt = new DataTable(); da.Fill(dt); // avem aici toate datele din film if (dt.Rows.Count >= 1) { TextBox6.Text = dt.Rows[0]["DescriereFilm"].ToString(); DropDownList2.SelectedValue = dt.Rows[0]["Limba"].ToString().Trim(); DropDownList1.SelectedValue = dt.Rows[0]["NumeSala"].ToString().Trim(); ListBox1.ClearSelection(); string[] Gen = dt.Rows[0]["Gen"].ToString().Trim().Split(','); for (int i = 0; i < Gen.Length; i++) { for (int j = 0; j < ListBox1.Items.Count; j++) { if (ListBox1.Items[j].ToString() == Gen[i]) { ListBox1.Items[j].Selected = true; } } } global_filepath = dt.Rows[0]["film_img"].ToString(); } else { Response.Write("<script>alert('Titlul nu este valabil');</script>"); } } catch (Exception ex) { } }
public void ClearAll() { TextBox11.Text = string.Empty; TextBox12.Text = string.Empty; TextBox13.Text = string.Empty; TextBox14.Text = string.Empty; TextBox15.Text = string.Empty; TextBox16.Text = string.Empty; TextBox3.Text = string.Empty; TextBox4.Text = string.Empty; TextBox5.Text = string.Empty; TextBox6.Text = string.Empty; TextBox7.Text = string.Empty; TextBox8.Text = string.Empty; TextBoxFirst.Text = string.Empty; ListBox1.ClearSelection(); DropDownList1.ClearSelection(); DropDownList2.ClearSelection(); DropDownList4.ClearSelection(); DropDownList5.ClearSelection(); }
/// <summary> /// 画面ロード処理 /// </summary> protected void Page_Load(object sender, EventArgs e) { // ポストバック時はリターン if (IsPostBack == true) { return; } CommonLogic bcom = new CommonLogic(); ListBox1.ClearSelection(); try { String infoFilePath, fldSight = ""; fldSight = "fldChangeImage"; infoFilePath = System.Web.Configuration.WebConfigurationManager.AppSettings[fldSight]; string txtInfo = HttpContext.Current.Server.MapPath(infoFilePath); //ChangeImageフォルダ内のファイルをすべて取得する System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(txtInfo); IEnumerable <System.IO.FileInfo> files = di.EnumerateFiles("*", System.IO.SearchOption.AllDirectories); //ファイル名を列挙する foreach (System.IO.FileInfo f in files) { ListBox1.Items.Add(new ListItem(f.Name, f.FullName)); } } catch (Exception ex) { // システムエラー処理(ログ出力&エラーページ表示) bcom.ErrorProcess("frmTopPage", "btn_ChangeImage_Click", ex, this.Response); } }
// tìm sách theo ID void getBookByID() { try { SqlConnection con = new SqlConnection(strcon); if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("SELECT * from book_master_tbl WHERE book_id='" + TextBox7.Text.Trim() + "';", con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count >= 1) { SqlCommand ncmd = new SqlCommand("Select quantity from cart_items_tbl where book_id='" + TextBox7.Text.Trim() + "'; ", con); SqlDataAdapter nda = new SqlDataAdapter(ncmd); DataTable ndt = new DataTable(); nda.Fill(ndt); TextBox1.Text = ndt.Rows[0]["quantity"].ToString(); TextBox8.Text = dt.Rows[0]["book_name"].ToString(); TextBox4.Text = dt.Rows[0]["publisher_date"].ToString(); TextBox3.Text = dt.Rows[0]["edition"].ToString(); TextBox6.Text = dt.Rows[0]["cost"].ToString().Trim(); TextBox9.Text = dt.Rows[0]["pages"].ToString().Trim(); TextBox10.Text = dt.Rows[0]["book_description"].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(); ListBox1.ClearSelection(); string[] genre = dt.Rows[0]["genre"].ToString().Trim().Split(','); for (int i = 0; i < genre.Length; i++) { for (int j = 0; j < ListBox1.Items.Count; j++) { if (ListBox1.Items[j].ToString() == genre[i]) { ListBox1.Items[j].Selected = true; } } } } else { Response.Write("<script>alert('Sách không tồn tại trong giỏ hàng!');</script>"); } } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); } }
void getBookByID() { try { SqlConnection con = new SqlConnection(strcon); if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("SELECT * FROM book_master_tbl WHERE book_id='" + TextBox3.Text.Trim() + "';", con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count >= 1) { TextBox2.Text = dt.Rows[0]["book_name"].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(); TextBox1.Text = dt.Rows[0]["publish_date"].ToString(); TextBox9.Text = dt.Rows[0]["edition"].ToString(); TextBox10.Text = dt.Rows[0]["book_cost"].ToString().Trim(); TextBox11.Text = dt.Rows[0]["no_of_pages"].ToString().Trim(); TextBox4.Text = dt.Rows[0]["actual_stock"].ToString().Trim(); TextBox5.Text = dt.Rows[0]["current_stock"].ToString().Trim(); //issued books we have to minus the actual stock from current stock then we get the issued books TextBox7.Text = "" + (Convert.ToInt32(dt.Rows[0]["actual_stock"].ToString()) - Convert.ToInt32(dt.Rows[0]["current_stock"].ToString())); TextBox6.Text = dt.Rows[0]["book_description"].ToString(); //It is when we have change the book id new record is fetch then we have to remove all the previous selection we have made in listbox. ListBox1.ClearSelection(); // To seprate the value of genre by comma seprated. string[] genre = dt.Rows[0]["genre"].ToString().Trim().Split(','); // we have to make nested loop to make match the items in database from the list box.The items in // listbox which are match we have to select them. for (int i = 0; i < genre.Length; i++) { for (int j = 0; j < ListBox1.Items.Count; j++) { if (ListBox1.Items[j].ToString() == genre[i]) { ListBox1.Items[j].Selected = true; } } } 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_actual_stock - global_current_stock; global_filepath = dt.Rows[0]["book_img_link"].ToString(); } else { Response.Write("<script>alert('Invalid Book ID');</script>"); } } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); } }
protected void Button1_Click(object sender, EventArgs e) { Label2.Text = "Hello " + TextBox1.Text + " " + TextBox2.Text + "!"; Label2.Visible = true; Label5.Text = "Gender: " + DropDownList1.Text; Label5.Visible = true; int[] interests = ListBox1.GetSelectedIndices(); foreach (int index in interests) { ListItem li = ListBox1.Items[index]; Label7.Text += li.Text + " "; } Label7.Visible = true; ListBox1.ClearSelection(); foreach (ListItem li in CheckBoxList1.Items) { if (li.Selected) { Label9.Text += li.Text + " "; } } Label9.Visible = true; foreach (ListItem li in RadioButtonList1.Items) { if (li.Selected) { Label11.Text += li.Text + " "; } } Label11.Visible = true; if (CheckBox1.Checked) { Label13.Text = "I agree"; } else { Label13.Text = "I do not agree "; } Label13.Visible = true; foreach (ListItem li in RadioButtonList2.Items) { if (li.Selected) { if (li.Text == "Yes") { Label15.Text = "Please, add me to the discussion list"; } else { Label15.Text = "Don't add me to the discussion list"; } } } Label15.Visible = true; }
protected void Button4_Click(object sender, EventArgs e) { ListBox1.ClearSelection(); Response.Redirect("AccountsHome.aspx"); }
protected void Button1_Click(object sender, EventArgs e) { ListBox1.ClearSelection(); Response.Redirect("flight_detail.aspx"); }