protected void Button_DelItem_Click(object sender, EventArgs e) //删除一个选项 { int[] arr = ListBox1.GetSelectedIndices(); int len = arr.Length; for (int i = 0; i < len; ++i) { string strdel = ListBox1.Items[arr[i]].Text; ListBox1.Items.Remove(strdel); Response.Write(arr[i].ToString() + " " + strdel); SalesListDetail sld = new SalesListDetail(); sld = saleslist[arr[i]]; decimal curTot = Convert.ToDecimal(TextBox_Cur_TotMoney.Text) - sld.SubTotalMoney; TextBox_Cur_TotMoney.Text = curTot.ToString(); saleslist.Remove(sld); string pid = sld.ProductId; if (htProidToCnt.Contains(pid)) { int preCnt = (int)htProidToCnt[pid]; htProidToCnt.Remove(pid); if (preCnt > sld.Quantity) { htProidToCnt.Add(pid, preCnt - sld.Quantity); } } } }
protected void View2_Activate(object sender, EventArgs e) { String[] selected = new String[4]; int j = 0; foreach (int i in ListBox1.GetSelectedIndices()) { selected[j++] = ListBox1.Items[i].ToString() + " Starts From : "; } if (j >= 4) { Label10.Text = selected[3]; Row4.Visible = true; } if (j >= 3) { Label9.Text = selected[2]; Row3.Visible = true; } if (j >= 2) { Label8.Text = selected[1]; Row2.Visible = true; } if (j >= 1) { Label7.Text = selected[0]; Row1.Visible = true; } }
//user defined function //adaugam o noua rezervare void addNewRezervation() { try { //cream un obiect con , cu parametrul strcon SqlConnection con = new SqlConnection(strcon); if (con.State == ConnectionState.Closed) { con.Open(); } string Scaun = " "; int count = 0; foreach (int i in ListBox1.GetSelectedIndices()) //doar indicii selectati sunt retinuri { count = count + 1; Scaun = Scaun + ListBox1.Items[i] + ","; } Scaun = Scaun.Remove(Scaun.Length - 1); //remove comma from end SqlCommand cmd = new SqlCommand("INSERT INTO Rezervare (UserID, Username, NumarRezervare, NumarBilete) SELECT UserID, @Username, @NumarRezervare, @NumarBilete FROM [User] WHERE Username = @Username ", con); SqlCommand cmd1 = new SqlCommand("INSERT INTO Bilet(FilmID, RezervareID, NumarScaun) VALUES((SELECT FilmID FROM Film WHERE TitluFilm = '" + TextBox4.Text.Trim() + "') , (SELECT RezervareID FROM Rezervare WHERE NumarRezervare = '" + TextBox1.Text.Trim() + "'), @NumarScaun)", con); cmd.Parameters.AddWithValue("@Username", TextBox3.Text.Trim()); cmd.Parameters.AddWithValue("@NumarRezervare", TextBox1.Text.Trim()); cmd.Parameters.AddWithValue("@NumarBilete", count); cmd1.Parameters.AddWithValue("@NumarScaun", Scaun); cmd.ExecuteNonQuery(); //fire the query cmd1.ExecuteNonQuery(); //fire the query ; if (CheckBox1.Checked) { SqlCommand cmd3 = new SqlCommand("INSERT INTO Plata(RezervareID, Platit) VALUES((SELECT RezervareID FROM Rezervare WHERE NumarRezervare = '" + TextBox1.Text.Trim() + "'), 'DA')", con); cmd3.ExecuteNonQuery(); } else { SqlCommand cmd3 = new SqlCommand("INSERT INTO Plata(RezervareID, Platit) VALUES((SELECT RezervareID FROM Rezervare WHERE NumarRezervare = '" + TextBox1.Text.Trim() + "'), 'NU')", con); cmd3.ExecuteNonQuery(); } con.Close(); Response.Write("<script>alert('Rezervare adaugata. ');</script>"); clearForm(); GridView1.DataBind(); // se da refresh automat la tabel // GridView2.DataBind(); // se da refresh automat la tabel } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); } }
void AddBooks() { try { //Genre multi-Selection string Genre = ""; foreach (int i in ListBox1.GetSelectedIndices()) { Genre = Genre + ListBox1.Items[i] + ","; } //Genre=Adventure,Self Help, Genre = Genre.Remove(Genre.Length - 1); //File-Upload string filepath = "~/Book_Inventory/book-wallpaper-full-hd-1920x1080-128859.jpg"; string filename = Path.GetFileName(FileUpload1.PostedFile.FileName); FileUpload1.SaveAs(Server.MapPath("Book_Inventory/" + filename)); filepath = "~/Book_Inventory/" + filename; SqlConnection con = new SqlConnection(Conx); if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("Insert Into Book_Master_tbl(Book_Id,Book_Name,Genre,Author_Name,Publisher_Name,Published_Date,Language,Edition," + "Book_Cost,No_of_Pages,Book_Description,Actual_Stock,Current_Stock,Book_img_Link) Values(@Book_Id,@Book_Name,@Genre,@Author_Name,@Publisher_Name,@Published_Date," + "@Language,@Edition,@Book_Cost,@No_of_Pages,@Book_Description,@Actual_Stock,@Current_Stock," + "@Book_img_Link)", con); cmd.Parameters.AddWithValue("@Book_Id", TextBox1.Text.Trim()); cmd.Parameters.AddWithValue("@Book_Name", TextBox2.Text.Trim()); cmd.Parameters.AddWithValue("@Genre", Genre); cmd.Parameters.AddWithValue("@Author_Name", DropDownList3.SelectedItem.Value); cmd.Parameters.AddWithValue("@Publisher_Name", DropDownList2.SelectedItem.Value); cmd.Parameters.AddWithValue("@Published_Date", TextBox3.Text.Trim()); cmd.Parameters.AddWithValue("@Language", DropDownList1.SelectedItem.Value); cmd.Parameters.AddWithValue("@Edition", TextBox4.Text.Trim()); cmd.Parameters.AddWithValue("@Book_Cost", TextBox5.Text.Trim()); cmd.Parameters.AddWithValue("@Actual_Stock", TextBox7.Text.Trim()); cmd.Parameters.AddWithValue("@Current_Stock", TextBox7.Text.Trim()); cmd.Parameters.AddWithValue("@Book_img_Link", filepath); cmd.Parameters.AddWithValue("@No_of_Pages", TextBox6.Text.Trim()); cmd.Parameters.AddWithValue("@Book_Description", TextBox10.Text.Trim()); cmd.ExecuteNonQuery(); con.Close(); Response.Write("<script>alert('Book Added Successful');</script>"); ClearForm(); GridView1.DataBind(); //Response.Redirect("homepage.aspx", false); //string message = "Sign Up was Successful"; //MessageBox.Show(message); } catch (Exception ex) { MessageBox.Show("AddBooks" + ex.Message); } }
void addNewBook() { string genres = ""; //to iterate through the list box we have to use foreach loop becaue multiple items may be selected in list box. foreach (int i in ListBox1.GetSelectedIndices()) { genres = genres + ListBox1.Items[i] + ","; } //genres=Adventure,Self Help, //to remove the last comma from the string we use built in function. genres = genres.Remove(genres.Length - 1); //File upload code string filepath = "~/book_inventory/books1.png"; string filename = Path.GetFileName(FileUpload1.PostedFile.FileName); FileUpload1.SaveAs(Server.MapPath("book_inventory/" + filename)); filepath = "~/book_inventory/" + filename; try { SqlConnection con = new SqlConnection(strcon); if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("INSERT INTO book_master_tbl (book_id,book_name,genre,author_name,publisher_name," + "publish_date,language," + "edition,book_cost,no_of_pages,book_description,actual_stock,current_stock,book_img_link) VALUES(" + "@book_id,@book_name,@genre,@author_name,@publisher_name,@publish_date,@language," + "@edition,@book_cost,@no_of_pages,@book_description,@actual_stock,@current_stock,@book_img_link)", con); cmd.Parameters.AddWithValue("@book_id", TextBox3.Text.Trim()); cmd.Parameters.AddWithValue("@book_name", TextBox2.Text.Trim()); cmd.Parameters.AddWithValue("@genre", genres); cmd.Parameters.AddWithValue("@author_name", DropDownList3.SelectedItem.Value); cmd.Parameters.AddWithValue("@publisher_name", DropDownList2.SelectedItem.Value); cmd.Parameters.AddWithValue("@publish_date", TextBox1.Text.Trim()); cmd.Parameters.AddWithValue("@language", DropDownList1.SelectedItem.Value); cmd.Parameters.AddWithValue("@edition", TextBox9.Text.Trim()); cmd.Parameters.AddWithValue("@book_cost", TextBox10.Text.Trim()); cmd.Parameters.AddWithValue("@no_of_pages", TextBox11.Text.Trim()); cmd.Parameters.AddWithValue("@book_description", TextBox6.Text.Trim()); cmd.Parameters.AddWithValue("@actual_stock", TextBox4.Text.Trim()); cmd.Parameters.AddWithValue("@current_stock", TextBox4.Text.Trim()); cmd.Parameters.AddWithValue("@book_img_link", filepath); cmd.ExecuteNonQuery(); con.Close(); Response.Write("<script>alert('Book Added Successfully');</alert>"); GridView1.DataBind(); } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); } }
protected void Button3_Click(object sender, EventArgs e) { Label3.Text = ""; foreach (int i in ListBox1.GetSelectedIndices()) { ListItem li = ListBox1.Items[i]; Label3.Text += li.Value + ":" + li.Text + "<br />"; } }
//user defined function for update void updateRezervation() { try { //cream un obiect con , cu parametrul strcon SqlConnection con = new SqlConnection(strcon); if (con.State == ConnectionState.Closed) { con.Open(); } string Scaun = " "; int count = 0; foreach (int i in ListBox1.GetSelectedIndices()) //doar indicii selectati sunt retinuri { count = count + 1; Scaun = Scaun + ListBox1.Items[i] + ","; } Scaun = Scaun.Remove(Scaun.Length - 1); //remove comma from end SqlCommand cmd = new SqlCommand("UPDATE R SET R.NumarBilete = @NumarBilete FROM Rezervare R INNER JOIN [User] U ON U.UserID = R.UserID WHERE U.Username = @Username AND R.NumarRezervare = '" + TextBox1.Text.Trim() + "' ", con); SqlCommand cmd2 = new SqlCommand("UPDATE B SET B.NumarScaun = @NumarScaun FROM Bilet B INNER JOIN Rezervare R ON R.RezervareID = B.RezervareID WHERE R.NumarRezervare = '" + TextBox1.Text.Trim() + "' ", con); cmd.Parameters.AddWithValue("@Username", TextBox3.Text.Trim()); // cmd3.Parameters.AddWithValue("@Platit", "DA"); cmd.Parameters.AddWithValue("@NumarBilete", count); cmd2.Parameters.AddWithValue("@NumarScaun", Scaun); cmd.ExecuteNonQuery(); //fire the query cmd2.ExecuteNonQuery(); if (CheckBox1.Checked) { SqlCommand cmd3 = new SqlCommand("UPDATE P SET Platit = 'DA' FROM Plata P INNER JOIN Rezervare R ON R.RezervareID = P.RezervareID WHERE R.NumarRezervare = '" + TextBox1.Text.Trim() + "' ", con); cmd3.ExecuteNonQuery(); } else { SqlCommand cmd3 = new SqlCommand("UPDATE P SET Platit = 'NU' FROM Plata P INNER JOIN Rezervare R ON R.RezervareID = P.RezervareID WHERE R.NumarRezervare = '" + TextBox1.Text.Trim() + "' ", con); cmd3.ExecuteNonQuery(); } con.Close(); Response.Write("<script>alert('Rezervare modificata');</script>"); clearForm(); GridView1.DataBind(); // se da refresh automat la tabel } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); } }
void AddNewBook() { try { string genres = ""; foreach (int i in ListBox1.GetSelectedIndices()) { genres = genres + ListBox1.Items[i] + ","; } genres = genres.Remove(genres.Length - 1); string filepath = "~/book_inventory/books1.png"; string filename = Path.GetFileName(FileUpload1.PostedFile.FileName); FileUpload1.SaveAs(Server.MapPath("book_inventory/" + filename)); filepath = "~/book_inventory/" + filename; SqlConnection con = new SqlConnection(strcon); if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand(@"insert into book_master_tbl (book_id,book_name,genre,author_name,publisher_name,publish_date, language,edition,book_cost,no_of_pages,book_description,actual_stock,current_stock,book_img_link) values(@book_id,@book_name,@genre,@author_name,@publisher_name,@publish_date, @language,@edition,@book_cost,@no_of_pages,@book_description,@actual_stock,@current_stock,@book_img_link)", con); cmd.Parameters.AddWithValue("@book_id", TextBox3.Text.Trim()); cmd.Parameters.AddWithValue("@book_name", TextBox4.Text.Trim()); cmd.Parameters.AddWithValue("@genre", genres); cmd.Parameters.AddWithValue("@author_name", DropDownList3.SelectedItem.Value); cmd.Parameters.AddWithValue("@publisher_name", DropDownList2.SelectedItem.Value); cmd.Parameters.AddWithValue("@publish_date", TextBox1.Text.Trim()); cmd.Parameters.AddWithValue("@language", DropDownList1.SelectedItem.Value); cmd.Parameters.AddWithValue("@edition", TextBox9.Text.Trim()); cmd.Parameters.AddWithValue("@book_cost", TextBox10.Text.Trim()); cmd.Parameters.AddWithValue("@no_of_pages", TextBox11.Text.Trim()); cmd.Parameters.AddWithValue("@book_description", TextBox6.Text.Trim()); cmd.Parameters.AddWithValue("@actual_stock", TextBox2.Text.Trim()); cmd.Parameters.AddWithValue("@current_stock", TextBox2.Text.Trim()); cmd.Parameters.AddWithValue("@book_img_link", filepath); cmd.ExecuteNonQuery(); con.Close(); Response.Write("<script>alert('Book added successfully!');</script>"); GridView1.DataBind(); } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); } }
protected void Button2_Click(object sender, EventArgs e) { int[] selekcija = ListBox1.GetSelectedIndices(); Label1.Text = ""; foreach (int i in selekcija) { ListItem item = ListBox1.Items[i]; Label1.Text += "<br/>Izbrana destinacija: " + item.Value; } }
//addNewBooks methods protected void addNewBooks() { try { //multiple select values string genre = ""; foreach (int i in ListBox1.GetSelectedIndices()) { genre = genre + ListBox1.Items[i] + ","; } genre = genre.Remove(genre.Length - 1); //img upload string path = Path.GetFileName(FileUpload1.PostedFile.FileName); string savloc = Server.MapPath("bookimage") + "//" + path; FileUpload1.PostedFile.SaveAs(savloc); string imgFileString = "~/bookimage/" + path; SqlConnection con = new SqlConnection(strcon); //establishing connection con.Close(); if (con.State == ConnectionState.Closed) { con.Open(); } string bookInsertQuery = "insert into book_master_tbl (book_id,book_name,genre,auther_name,publisher_name,publish_date,language,edition,book_cost,no_of_pages,book_description,actual_stock,current_stock,book_img_link) values(@book_id,@book_name,@genre,@auther_name,@publisher_name,@publish_date,@language,@edition,@book_cost,@no_of_pages,@book_description,@actual_stock,@current_stock,@book_img_link)"; SqlCommand cmd = new SqlCommand(bookInsertQuery, con); cmd.Parameters.AddWithValue("@book_id", TextBox3.Text.Trim()); cmd.Parameters.AddWithValue("@book_name", TextBox4.Text.Trim()); cmd.Parameters.AddWithValue("@genre", genre); cmd.Parameters.AddWithValue("@auther_name", DropDownList3.SelectedItem.Value); cmd.Parameters.AddWithValue("@publisher_name", DropDownList2.SelectedItem.Value); cmd.Parameters.AddWithValue("@publish_date", TextBox1.Text.Trim()); cmd.Parameters.AddWithValue("@language", DropDownList1.SelectedItem.Value); cmd.Parameters.AddWithValue("@edition", TextBox5.Text.Trim()); cmd.Parameters.AddWithValue("@book_cost", TextBox6.Text.Trim()); cmd.Parameters.AddWithValue("@no_of_pages", TextBox9.Text.Trim()); cmd.Parameters.AddWithValue("@book_description", TextBox10.Text.Trim()); cmd.Parameters.AddWithValue("@actual_stock", TextBox2.Text.Trim()); cmd.Parameters.AddWithValue("@current_stock", TextBox2.Text.Trim()); cmd.Parameters.AddWithValue("@book_img_link", imgFileString); cmd.ExecuteNonQuery(); con.Close(); Response.Write("<script>alert('New book added successfuly');</script>"); } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); } }
protected void ItemDel_Click(object sender, EventArgs e) { if (ListBox1.SelectedItem.Text != "") { int[] indices = ListBox1.GetSelectedIndices(); for (int i = indices.Length - 1; i >= 0; i--) { ListBox1.Items.RemoveAt(indices[i]); } } }
protected void btnRunReport_Click(object sender, EventArgs e) { List <string> lst = new List <string>(); foreach (int n in ListBox1.GetSelectedIndices()) { lst.Add(ListBox1.Items[n].Value); } Context.Items["reportlist"] = lst; Server.Transfer("Page2.aspx"); }
void addNewCar() { try { string tran = ""; foreach (int i in ListBox1.GetSelectedIndices()) { tran = tran + ListBox1.Items[i] + ","; } tran = tran.Remove(tran.Length - 1); string filepath = "~/carinventory/images (2).png"; string filename = Path.GetFileName(FileUpload1.PostedFile.FileName); FileUpload1.SaveAs(Server.MapPath("carinventory/" + filename)); filepath = "~/carinventory/" + filename; SqlConnection con = new SqlConnection(strcon); if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("INSERT INTO car_master_tbl(car_id, car_name, seat, brand_name, transmission,actual_stock, current_stock, car_img_link ,price, cc, added_car, car_description, years, edition) values(@car_id, @car_name, @seat, @brand_name, @transmission, @actual_stock, @current_stock, @car_img_link, @price,@cc, @added_car, @car_description, @years, @edition)", con); cmd.Parameters.AddWithValue("@car_id", TextBox1.Text.Trim()); cmd.Parameters.AddWithValue("@car_name", TextBox2.Text.Trim()); cmd.Parameters.AddWithValue("@seat", DropDownList1.SelectedItem.Value); cmd.Parameters.AddWithValue("@brand_name", DropDownList3.SelectedItem.Value); cmd.Parameters.AddWithValue("@transmission", tran); cmd.Parameters.AddWithValue("@actual_stock", TextBox4.Text.Trim()); cmd.Parameters.AddWithValue("@current_stock", TextBox4.Text.Trim()); cmd.Parameters.AddWithValue("@price", TextBox10.Text.Trim()); cmd.Parameters.AddWithValue("@cc", TextBox11.Text.Trim()); cmd.Parameters.AddWithValue("@added_car", TextBox7.Text.Trim()); cmd.Parameters.AddWithValue("@car_description", TextBox6.Text.Trim()); cmd.Parameters.AddWithValue("@years", TextBox3.Text.Trim()); cmd.Parameters.AddWithValue("@edition", TextBox9.Text.Trim()); cmd.Parameters.AddWithValue("@car_img_link", filepath); cmd.ExecuteNonQuery(); con.Close(); Response.Write("<script>alert('Car added successfully.');</script>"); GridView1.DataBind(); } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); } }
// fonk duzgun CALISIYOR. :) void AddNewMovie() { try { string genres = ""; foreach (int i in ListBox1.GetSelectedIndices()) { genres = genres + ListBox1.Items[i] + ","; } genres = genres.Remove(genres.Length - 1); string filepath = "~/movie_inventory/image_part_016"; string filename = Path.GetFileName(FileUpload1.PostedFile.FileName); FileUpload1.SaveAs(Server.MapPath("movie_inventory/" + filename)); filepath = "~/movie_inventory/" + filename; SqlConnection con = new SqlConnection(strcon); if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("INSERT INTO movie_master_tbl (movie_id, movie_name, genre, director_name, " + "producer_name, publish_date, language, edition, movie_cost, duration,movie_description,actual_stock,current_stock,movie_img_link)" + "VALUES (@movie_id, @movie_name, @genre, @director_name,@producer_name, @publish_date, @language, @edition," + "@movie_cost, @duration,@movie_description,@actual_stock,@current_stock,@movie_img_link)", con); cmd.Parameters.AddWithValue("@movie_id", TextBox2.Text.Trim()); cmd.Parameters.AddWithValue("@movie_name", TextBox3.Text.Trim()); cmd.Parameters.AddWithValue("@genre", genres); cmd.Parameters.AddWithValue("@director_name", DropDownList3.SelectedItem.Value); cmd.Parameters.AddWithValue("@producer_name", DropDownList2.SelectedItem.Value); cmd.Parameters.AddWithValue("@publish_date", TextBox6.Text.Trim()); cmd.Parameters.AddWithValue("@language", DropDownList1.SelectedItem.Value); cmd.Parameters.AddWithValue("@edition", TextBox7.Text.Trim()); //Year text box cmd.Parameters.AddWithValue("@movie_cost", TextBox8.Text.Trim()); cmd.Parameters.AddWithValue("@duration", TextBox9.Text.Trim()); cmd.Parameters.AddWithValue("@movie_description", TextBox10.Text.Trim()); cmd.Parameters.AddWithValue("@actual_stock", TextBox1.Text.Trim()); cmd.Parameters.AddWithValue("@current_stock", TextBox4.Text.Trim()); cmd.Parameters.AddWithValue("@movie_img_link", filepath); cmd.ExecuteNonQuery(); con.Close(); Response.Write("<script>alert('Movie added successfully');</script>"); GridView1.DataBind(); } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); } }
void addNewCellphone() { try { string specifications = ""; foreach (int i in ListBox1.GetSelectedIndices()) { specifications = specifications + ListBox1.Items[i] + ","; } // genres = Adventure,Self Help, specifications = specifications.Remove(specifications.Length - 1); string filepath = "~/cellphone/cellicon.png"; string filename = Path.GetFileName(FileUpload1.PostedFile.FileName); FileUpload1.SaveAs(Server.MapPath("cellphone/" + filename)); filepath = "~/cellphone/" + filename; SqlConnection con = new SqlConnection(strcon); if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("INSERT INTO cellphone_master_tbl(cellphone_id,cellphone_name,specifications,brand_name,model_name,release_date,operating_system,color,price,camera_quality,phone_description,cellphone_img_link) values(@cellphone_id,@cellphone_name,@specifications,@brand_name,@model_name,@release_date,@operating_system,@color,@price,@camera_quality,@phone_description,@cellphone_img_link)", con); cmd.Parameters.AddWithValue("@cellphone_id", TextBox1.Text.Trim()); cmd.Parameters.AddWithValue("@cellphone_name", TextBox2.Text.Trim()); cmd.Parameters.AddWithValue("@specifications", specifications); cmd.Parameters.AddWithValue("@brand_name", DropDownList3.SelectedItem.Value); cmd.Parameters.AddWithValue("@model_name", DropDownList2.SelectedItem.Value); cmd.Parameters.AddWithValue("@release_date", TextBox3.Text.Trim()); cmd.Parameters.AddWithValue("@operating_system", DropDownList1.SelectedItem.Value); cmd.Parameters.AddWithValue("@color", TextBox9.Text.Trim()); cmd.Parameters.AddWithValue("@price", TextBox10.Text.Trim()); cmd.Parameters.AddWithValue("@camera_quality", TextBox11.Text.Trim()); cmd.Parameters.AddWithValue("@phone_description", TextBox6.Text.Trim()); cmd.Parameters.AddWithValue("@cellphone_img_link", filepath); cmd.ExecuteNonQuery(); con.Close(); Response.Write("<script>alert('Cellphone added successfully.');</script>"); GridView1.DataBind(); } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); } }
void AddNewBook() { try { string genres = ""; foreach (int i in ListBox1.GetSelectedIndices()) { genres = genres + ListBox1.Items[i] + ","; } // genres = Adventure,Self Help, genres = genres.Remove(genres.Length - 1); string filepath = "~/book_inventory/books1.png"; string filename = Path.GetFileName(FileUpload1.PostedFile.FileName); FileUpload1.SaveAs(Server.MapPath("book_inventory/" + filename)); filepath = "~/book_inventory/" + filename; SqlConnection con = new SqlConnection(strcon); if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("INSERT INTO book_master_tbl(book_id,book_name,genre,author_name,publisher_name,publisher_date,language,edition,book_cost,no_of_pages,Book_description,actual_stock,current_stock,book_img_link) " + "values(@0,@1,@2,@3,@4,@5,@6,@7,@8,@9,@10,@11,@12,@13)", con); cmd.Parameters.AddWithValue("@0", txtBookId.Text.Trim()); cmd.Parameters.AddWithValue("@1", txtBookName.Text.Trim()); cmd.Parameters.AddWithValue("@2", genres); cmd.Parameters.AddWithValue("@3", DropDownList3.SelectedItem.ToString()); cmd.Parameters.AddWithValue("@4", DropDownList2.SelectedItem.ToString()); cmd.Parameters.AddWithValue("@5", txtPublishDate.Text.Trim()); cmd.Parameters.AddWithValue("@6", DropDownList1.SelectedItem.Value); cmd.Parameters.AddWithValue("@7", txtEdition.Text.Trim()); cmd.Parameters.AddWithValue("@8", txtBookCost.Text.Trim()); cmd.Parameters.AddWithValue("@9", txtPages.Text.Trim()); cmd.Parameters.AddWithValue("@10", txtBookDescription.Text.Trim()); cmd.Parameters.AddWithValue("@11", txtActualStock.Text.Trim()); cmd.Parameters.AddWithValue("@12", txtActualStock.Text.Trim()); cmd.Parameters.AddWithValue("@13", filepath); cmd.ExecuteNonQuery(); con.Close(); Response.Write("<script>alert('Book Added Successfully.')</script>"); GridView1.DataBind(); clearform(); } catch (Exception ex) { } }
void addNewBook() { try { string genres = ""; foreach (int i in ListBox1.GetSelectedIndices()) { genres = genres + ListBox1.Items[i] + ","; } genres = genres.Remove(genres.Length - 1); string filepath = "~/bookinventory/logo.jpg"; string filename = Path.GetFileName(FileUpload1.PostedFile.FileName); FileUpload1.SaveAs(Server.MapPath("bookinventory/" + filename)); filepath = "~/bookinventory/" + filename; SqlConnection con = new SqlConnection(strcon); if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("INSERT INTO book_table(BookId,Isbn,BookName,genre,Author,PublisherName,publishDate,edition,sellingPrice,bookDescription,actualStock,bookImageLink) values(@BookId,@Isbn,@BookName,@genre,@Author,@PublisherName,@publishDate,@edition,@sellingPrice,@bookDescription,@actualStock,@bookImageLink)", con); cmd.Parameters.AddWithValue("@BookId", TextBox1.Text.Trim()); cmd.Parameters.AddWithValue("@Isbn", TextBox8.Text.Trim()); cmd.Parameters.AddWithValue("@BookName", TextBox2.Text.Trim()); cmd.Parameters.AddWithValue("@genre", genres); cmd.Parameters.AddWithValue("@Author", DropDownList3.SelectedItem.Value); cmd.Parameters.AddWithValue("@PublisherName", DropDownList2.SelectedItem.Value); cmd.Parameters.AddWithValue("@publishDate", TextBox3.Text.Trim()); cmd.Parameters.AddWithValue("@edition", TextBox9.Text.Trim()); cmd.Parameters.AddWithValue("@sellingPrice", TextBox10.Text.Trim()); cmd.Parameters.AddWithValue("@bookDescription", TextBox6.Text.Trim()); cmd.Parameters.AddWithValue("@actualStock", TextBox4.Text.Trim()); cmd.Parameters.AddWithValue("@bookImageLink", filepath); cmd.ExecuteNonQuery(); con.Close(); Response.Write("<script>alert('Book added successfully.');</script>"); GridView1.DataBind(); } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); } }
void addNewMovie() { try { string Gen = " "; foreach (int i in ListBox1.GetSelectedIndices()) //doar indicii selectati sunt retinuri { Gen = Gen + ListBox1.Items[i] + ","; } // genres = Adventure,Self Help, Gen = Gen.Remove(Gen.Length - 1); string filepath = "~/movie_inventory/cienamdan.png"; string filename = Path.GetFileName(FileUpload1.PostedFile.FileName); FileUpload1.SaveAs(Server.MapPath("movie_inventory/" + filename)); filepath = "~/movie_inventory/" + filename; SqlConnection con = new SqlConnection(strcon); if (con.State == ConnectionState.Closed) { con.Open(); } //Trim = removes blankspaces SqlCommand cmd = new SqlCommand("INSERT INTO Film (TitluFilm, DescriereFilm, Gen, Limba, film_img, SalaID) VALUES (@TitluFilm, @DescriereFilm, @Gen, @Limba, @film_img, (SELECT SalaID FROM Sala WHERE NumeSala = '" + DropDownList1.SelectedItem.Value + "' )) ", con); cmd.Parameters.AddWithValue("@TitluFilm", TextBox1.Text.Trim()); cmd.Parameters.AddWithValue("@DescriereFilm", TextBox6.Text.Trim()); cmd.Parameters.AddWithValue("@Gen", Gen); cmd.Parameters.AddWithValue("@Limba", DropDownList2.SelectedItem.Value); cmd.Parameters.AddWithValue("@NumeSala", DropDownList1.SelectedItem.Value); cmd.Parameters.AddWithValue("@film_img", filepath); cmd.ExecuteNonQuery(); //fire the query Response.Write("<script>alert('Filmul a fost adaugat.');</script>"); con.Close(); GridView1.DataBind(); // se da refresh automat la tabel clearForm(); } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); } }
void addNewBook() { try { string genres = ""; foreach (int i in ListBox1.GetSelectedIndices()) { genres = genres + ListBox1.Items[i] + ","; } genres = genres.Remove(genres.Length - 1); string filepath = "~/imgs/books1.png"; string filename = Path.GetFileName(FileUpload1.PostedFile.FileName); FileUpload1.SaveAs(Server.MapPath("book_inventory/" + filename)); filepath = "~/book_inventory/" + filename; SqlConnection connection = new SqlConnection(connectionString); if (connection.State == ConnectionState.Closed) { connection.Open(); } SqlCommand sqlCmd = new SqlCommand("INSERT INTO book_master_tbl(book_id,book_name,genre,author_name,publisher_name,publish_date," + "language,edition,book_cost,no_of_pages,book_description,actual_stock,current_stock,book_img_link) " + "values(@book_id,@book_name,@genre,@author_name,@publisher_name,@publish_date,@language,@edition,@book_cost,@no_of_pages," + "@book_description,@actual_stock,@current_stock,@book_img_link)", connection); sqlCmd.Parameters.AddWithValue("@book_id", TextBox1.Text.Trim()); sqlCmd.Parameters.AddWithValue("@book_name", TextBox2.Text.Trim()); sqlCmd.Parameters.AddWithValue("@genre", genres); sqlCmd.Parameters.AddWithValue("@author_name", DropDownList3.SelectedItem.Value); sqlCmd.Parameters.AddWithValue("@publisher_name", DropDownList2.SelectedItem.Value); sqlCmd.Parameters.AddWithValue("@publish_date", TextBox3.Text.Trim()); sqlCmd.Parameters.AddWithValue("@language", DropDownList1.SelectedItem.Value); sqlCmd.Parameters.AddWithValue("@edition", TextBox9.Text.Trim()); sqlCmd.Parameters.AddWithValue("@book_cost", TextBox10.Text.Trim()); sqlCmd.Parameters.AddWithValue("@no_of_pages", TextBox11.Text.Trim()); sqlCmd.Parameters.AddWithValue("@book_description", TextBox6.Text.Trim()); sqlCmd.Parameters.AddWithValue("@actual_stock", TextBox4.Text.Trim()); sqlCmd.Parameters.AddWithValue("@current_stock", TextBox4.Text.Trim()); sqlCmd.Parameters.AddWithValue("@book_img_link", filepath); sqlCmd.ExecuteNonQuery(); connection.Close(); this.Page.ClientScript.RegisterStartupScript(this.GetType(), "toastr_message", "toastr.success('Book added successfully')", true); //GridView1.DataBind(); } catch (Exception ex) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "toastr_message", "toastr.error('Error!!')", true); } }
protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e) { int selected = 0; foreach (int i in ListBox1.GetSelectedIndices()) { selected++; } if (selected > 4) { foreach (int i in ListBox1.GetSelectedIndices()) { ListBox1.Items[i].Selected = false; } } }
public void Check_Clicked(object check, EventArgs c) { if (checkbox2.Checked && ListBox1.GetSelectedIndices().Count() == 0) { StringA = "Search4"; Session["param"] = "Search4"; } else if (checkbox2.Checked && ListBox1.GetSelectedIndices().Count() == 1) { StringA = "SelectandOrderByNutrient"; } else { StringA = "Search3"; Session["param"] = ""; } checkboxhidden.Value = StringA; }
protected void ListBox1_SelectedIndexChanged1(object sender, EventArgs e) { DropDownList3.Enabled = true; ImageButton1.Enabled = true; DropDownList3.Items.Insert(0, "Select one"); string TescoYear = "select distinct(Tesco_Year) from tbl_TescoCalender where Tesco_Year > 2012 order by Tesco_Year "; DataSet dsYear = bn.DatabindingTeam(TescoYear); DropDownList3.DataSource = dsYear; DropDownList3.DataTextField = "Tesco_Year"; DropDownList3.DataValueField = "Tesco_Year"; DropDownList3.DataBind(); DropDownList3.Items.Insert(0, "--Select One--"); if (DropDownList6.SelectedValue == "Team Report" || DropDownList6.SelectedValue == "DetailedTeamReport") { DropDownList2.Enabled = false; } else { DropDownList2.Enabled = true; } int i = ListBox1.GetSelectedIndices().Length; if (i > 1) { int j = DropDownList2.Items.Count; DropDownList2.Enabled = false; //Label3.Visible = false; } else { // CrystalReportViewer1.Enabled = false; string Team = ListBox1.SelectedValue; string Emp = " select t1.FirstName+' '+t1.LastName as EmpName from tbl_UserDetails t1, tbl_Team t2 where t1.TeamID = t2.TeamID and t2.TeamName=" + "'" + Team + "'"; DataSet ds1 = bn.DatabindingTeam(Emp); DropDownList2.DataSource = ds1; DropDownList2.DataTextField = "EmpName"; DropDownList2.DataValueField = "EmpName"; DropDownList2.DataBind(); // CrystalReportViewer1.Enabled = false; } }
void add_new_book() { try { string genres = ""; foreach (int i in ListBox1.GetSelectedIndices()) { genres = genres + ListBox1.Items[i] + ","; } genres = genres.Remove(genres.Length - 1); SqlConnection con = new SqlConnection(strcon); if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("INSERT INTO book_master_table(book_id,book_name,genre,author_name,publisher_name,publish_date,language,edition,book_cost,no_of_pages,book_description,actual_stock,current_stock) values(@book_id,@book_name,@genre,@author_name,@publisher_name,@publish_date,@language,@edition,@book_cost,@no_of_pages,@book_description,@actual_stock,@current_stock)", con); cmd.Parameters.AddWithValue("@book_id", TextBox3.Text.Trim()); cmd.Parameters.AddWithValue("@book_name", TextBox4.Text.Trim()); cmd.Parameters.AddWithValue("@genre", genres); cmd.Parameters.AddWithValue("@author_name", DropDownList3.SelectedItem.Value); cmd.Parameters.AddWithValue("@publisher_name", DropDownList2.SelectedItem.Value); cmd.Parameters.AddWithValue("@publish_date", TextBox1.Text.Trim()); cmd.Parameters.AddWithValue("@language", DropDownList1.SelectedItem.Value); cmd.Parameters.AddWithValue("@edition", TextBox9.Text.Trim()); cmd.Parameters.AddWithValue("@book_cost", TextBox10.Text.Trim()); cmd.Parameters.AddWithValue("@no_of_pages", TextBox11.Text.Trim()); cmd.Parameters.AddWithValue("@book_description", TextBox6.Text.Trim()); cmd.Parameters.AddWithValue("@actual_stock", TextBox2.Text.Trim()); cmd.Parameters.AddWithValue("@current_stock", TextBox2.Text.Trim()); cmd.ExecuteNonQuery(); Response.Write("<script>alert('Carte adaugata cu succes!.');</script>"); GridView1.DataBind(); con.Close(); } catch (Exception ex) { string str = ex.Message; Response.Write("<script language=javascript>alert('" + str + "');</script>"); } }
protected void Button3_Click(object sender, EventArgs e) { foreach (var i in ListBox1.GetSelectedIndices()) { string Scope = RadioButtonList1.SelectedValue; string PromotionalItem = ListBox1.Items[i].ToString(); if (Scope == "Storewide") { PromotionalItem = "N/A"; } DateTime StartDate = Convert.ToDateTime(TextBox17.Text); DateTime EndDate = Convert.ToDateTime(TextBox18.Text); int Discount = Convert.ToInt32(TextBox20.Text); BusinessLogic.adddiscount(Scope, PromotionalItem, StartDate, EndDate, Discount); var promotionlist = BusinessLogic.GetPromotionbyScope(Scope); GridView2.DataSource = promotionlist; GridView2.DataBind(); } }
protected void ListBox1_SelectedIndexChanged1(object sender, EventArgs e) { DropDownList2.Enabled = true; int i = ListBox1.GetSelectedIndices().Length; if (i > 1) { int j = DropDownList2.Items.Count; DropDownList2.Enabled = false; //Label3.Visible = false; } else { // CrystalReportViewer1.Enabled = false; string Team = ListBox1.SelectedValue; string Emp = " select t1.FirstName+' '+t1.LastName as EmpName from tbl_UserDetails t1, tbl_Team t2 where t1.TeamID = t2.TeamID and t2.TeamName=" + "'" + Team + "'"; DataSet ds1 = bn.DatabindingTeam(Emp); DropDownList2.DataSource = ds1; DropDownList2.DataTextField = "EmpName"; DropDownList2.DataValueField = "EmpName"; DropDownList2.DataBind(); // CrystalReportViewer1.Enabled = false; } }
// UPDATE BOOKS void updateBookByID() { if (checkIfBookExists()) { try { int actual_stock = Convert.ToInt32(TextBox4.Text.Trim()); int current_stock = Convert.ToInt32(TextBox5.Text.Trim()); if (global_actual_stock == actual_stock) { } else { if (actual_stock < global_issued_books) { Response.Write("<script>alert('Actual Stock value cannot be less than the Issued books');</script>"); return; } else { current_stock = actual_stock - global_issued_books; TextBox5.Text = "" + current_stock; } } string genres = ""; foreach (int i in ListBox1.GetSelectedIndices()) { genres = genres + ListBox1.Items[i] + ","; } genres = genres.Remove(genres.Length - 1); string filepath = "~/book_inventory/books1"; string filename = Path.GetFileName(FileUpload1.PostedFile.FileName); if (filename == "" || filename == null) { filepath = global_filepath; } else { FileUpload1.SaveAs(Server.MapPath("book_inventory/" + filename)); filepath = "~/book_inventory/" + filename; } SqlConnection con = new SqlConnection(strcon); if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("UPDATE book_inventory_table set book_name=@book_name, genre=@genre, author_name=@author_name, publisher_name=@publisher_name, publish_date=@publish_date, language=@language, edition=@edition, book_description=@book_description, actual_stock=@actual_stock, current_stock=@current_stock, book_img_link=@book_img_link where book_id='" + TextBox1.Text.Trim() + "'", con); cmd.Parameters.AddWithValue("@book_name", TextBox2.Text.Trim()); cmd.Parameters.AddWithValue("@genre", genres); cmd.Parameters.AddWithValue("@author_name", DropDownList3.SelectedItem.Value); cmd.Parameters.AddWithValue("@publisher_name", DropDownList2.SelectedItem.Value); cmd.Parameters.AddWithValue("@publish_date", TextBox3.Text.Trim()); cmd.Parameters.AddWithValue("@language", DropDownList1.SelectedItem.Value); cmd.Parameters.AddWithValue("@edition", TextBox9.Text.Trim()); cmd.Parameters.AddWithValue("@book_description", TextBox6.Text.Trim()); cmd.Parameters.AddWithValue("@actual_stock", actual_stock.ToString()); cmd.Parameters.AddWithValue("@current_stock", current_stock.ToString()); cmd.Parameters.AddWithValue("@book_img_link", filepath); cmd.ExecuteNonQuery(); con.Close(); GridView1.DataBind(); Response.Write("<script>alert('Book Updated Successfully');</script>"); } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); } } else { Response.Write("<script>alert('Invalid Book ID');</script>"); } }
protected void Button1_Click(object sender, EventArgs e) { string UserName = TextBox1.Text.ToUpper(); StringBuilder UserChoice = new StringBuilder(); foreach (int item in ListBox1.GetSelectedIndices()) { //if (ListBox1.SelectedValue == ListBox1.Items[item].Value) UserChoice.Append(ListBox1.Items[item].Text); } if (RadioButton1.Checked) { UserChoice.Append(" to " + RadioButton1.Text); } if (RadioButton2.Checked) { UserChoice.Append(" " + RadioButton2.Text); } //StringBuilder UserSelection = new StringBuilder(); //if (CheckBox1.Checked) //{ // UserSelection.Append(";" + CheckBox1.Text); // TextBox8.Text = "You selected " + UserChoice.ToString(); //} //if (CheckBox2.Checked) //{ // UserSelection.Append("," + CheckBox2.Text); //} //if (CheckBox3.Checked) //{ // UserSelection.Append("," + CheckBox3.Text); //} //if (CheckBox4.Checked) //{ // UserSelection.Append("," + CheckBox4.Text); //} // TextBox8.Text = "Hi " + UserName + " you ordered " + UserChoice.ToString(); StringBuilder UserSelections = new StringBuilder(); if (CheckBox1.Checked) { //UserSelections.Insert(0, CheckBox1.Text); UserSelections.Append(CheckBox1.Text); } if (CheckBox2.Checked) { // UserSelections.Insert(1, CheckBox2.Text.ToString()); UserSelections.Append("\n" + CheckBox2.Text); } if (CheckBox3.Checked) { //UserSelections.Insert(2, CheckBox3.Text.ToString()); UserSelections.Append("\n" + CheckBox3.Text); } if (CheckBox4.Checked) { // UserSelections.Insert(3,CheckBox4.Text.ToString()); UserSelections.Append("\n" + CheckBox4.Text); } // if (TextBox1.Text == string.Empty) //{ // TextBox8.Text = "The form was not submited, please fill all required fields."; //TextBox8.Text = "You selected " + UserSelections.ToString(); // } //else //{ if (!Page.IsValid) { TextBox8.ForeColor = System.Drawing.Color.Red; TextBox8.Text = "Submission failed, Please fill all required field (*)"; } else { TextBox8.ForeColor = System.Drawing.Color.Black; TextBox8.Text = "Hi " + UserName + " you ordered " + UserChoice.ToString() + "\n" + "You selected Toppings\n" + UserSelections.ToString(); } }
void updateBookByID() { if (checkIfBookExist()) { try { int actual_stock = Convert.ToInt32(TextBox4.Text.Trim()); int current_stock = Convert.ToInt32(TextBox5.Text.Trim()); if (global_actual_stock == actual_stock) { } else { if (actual_stock < global_issued_books) { Response.Write("<script>alert('Actual stock value cannot be less than the issued books.');</script>"); return; } else { current_stock = actual_stock - global_issued_books; TextBox5.Text = "" + current_stock; } } //this is to fetch the multiple values from list box and save it in the string. string genres = ""; foreach (int i in ListBox1.GetSelectedIndices()) { genres = genres + ListBox1.Items[i] + ","; } genres = genres.Remove(genres.Length - 1); //this code is to check whether the new image link is added or if it was empty then the old link of the image // be save. string filepath = "~/book_inventory/books1.png"; string filename = Path.GetFileName(FileUpload1.PostedFile.FileName); if (filename == "" || filename == null) { filepath = global_filepath; } else { FileUpload1.SaveAs(Server.MapPath("book_inventory/" + filename)); filepath = "~/book_inventory/" + filename; } SqlConnection con = new SqlConnection(strcon); if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("UPDATE book_master_tbl SET book_name=@book_name,genre=@genre,author_name=@author_name," + "publisher_name=@publisher_name,publish_date=@publish_date,language=@language,edition=@edition,book_cost=@book_cost," + "no_of_pages=@no_of_pages,book_description=@book_description,actual_stock=@actual_stock,current_stock=@current_stock," + "book_img_link=@book_img_link WHERE book_id='" + TextBox3.Text.Trim() + "'", con); cmd.Parameters.AddWithValue("@book_id", TextBox3.Text.Trim()); cmd.Parameters.AddWithValue("@book_name", TextBox2.Text.Trim()); cmd.Parameters.AddWithValue("@genre", genres); cmd.Parameters.AddWithValue("@author_name", DropDownList3.SelectedItem.Value); cmd.Parameters.AddWithValue("@publisher_name", DropDownList2.SelectedItem.Value); cmd.Parameters.AddWithValue("@publish_date", TextBox1.Text.Trim()); cmd.Parameters.AddWithValue("@language", DropDownList1.SelectedItem.Value); cmd.Parameters.AddWithValue("@edition", TextBox9.Text.Trim()); cmd.Parameters.AddWithValue("@book_cost", TextBox10.Text.Trim()); cmd.Parameters.AddWithValue("@no_of_pages", TextBox11.Text.Trim()); cmd.Parameters.AddWithValue("@book_description", TextBox6.Text.Trim()); cmd.Parameters.AddWithValue("@actual_stock", actual_stock.ToString()); cmd.Parameters.AddWithValue("@current_stock", current_stock.ToString()); cmd.Parameters.AddWithValue("@book_img_link", filepath); cmd.ExecuteNonQuery(); con.Close(); GridView1.DataBind(); Response.Write("<script>alert('Book updated Successfully.')</script>"); } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "')</script>"); } } else { Response.Write("<script>alert('Invalid Book Id')</script>"); } }
void UpdateMovieByID() { if (CheckMovieExist()) { try { int actual_stock = Convert.ToInt32(TextBox1.Text.Trim()); int current_stock = Convert.ToInt32(TextBox4.Text.Trim()); if (global_actual_stock == actual_stock) { } else { if (actual_stock < global_issued_movies) { Response.Write("<script>alert('Actual Stock value cannot be less than the issued movies');</script>"); return; } else { current_stock = actual_stock - global_issued_movies; TextBox4.Text = "" + current_stock; } } string genres = ""; foreach (int i in ListBox1.GetSelectedIndices()) { genres = genres + ListBox1.Items[i] + ","; } genres = genres.Remove(genres.Length - 1); string filepath = "~/movie_inventory/image_part_016"; string filename = Path.GetFileName(FileUpload1.PostedFile.FileName); if (filename == "" || filename == null) { filepath = global_filepath; } else { FileUpload1.SaveAs(Server.MapPath("movie_inventory/" + filename)); filepath = "~/movie_inventory/" + filename; } SqlConnection con = new SqlConnection(strcon); //check connection is open with the database if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("UPDATE movie_master_tbl SET movie_name=@movie_name," + "genre=@genre, director_name=@director_name, producer_name=@producer_name, language=@language," + "edition=@edition, movie_cost=@movie_cost, duration=@duration, movie_description=@movie_description," + "actual_stock=@actual_stock, current_stock=@current_stock, movie_img_link=@movie_img_link" + "WHERE movie_id='" + TextBox2.Text.Trim() + "' ", con); cmd.Parameters.AddWithValue("@movie_name", TextBox3.Text.Trim()); cmd.Parameters.AddWithValue("@genre", genres); cmd.Parameters.AddWithValue("@director_name", DropDownList3.SelectedItem.Value); cmd.Parameters.AddWithValue("@producer_name", DropDownList2.SelectedItem.Value); cmd.Parameters.AddWithValue("@language", DropDownList1.SelectedItem.Value); cmd.Parameters.AddWithValue("@edition", TextBox7.Text.Trim()); cmd.Parameters.AddWithValue("@movie_cost", TextBox8.Text.Trim()); cmd.Parameters.AddWithValue("@duration", TextBox9.Text.Trim()); cmd.Parameters.AddWithValue("@movie_description", TextBox10.Text.Trim()); cmd.Parameters.AddWithValue("@actual_stock", actual_stock.ToString()); cmd.Parameters.AddWithValue("@current_stock", current_stock.ToString()); cmd.Parameters.AddWithValue("@movie_img_link", filepath); cmd.ExecuteNonQuery(); con.Close(); GridView1.DataBind(); Response.Write("<script>alert('Movie updated successfully');</script>"); } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); //Response.Write("<script>alert('olmadı');</script>"); } } else { Response.Write("<script>alert('Invalid Movie ID');</script>"); } }
void update_book_by_ID() { if (check_if_book_exist()) { try { SqlConnection con = new SqlConnection(strcon); if (con.State == ConnectionState.Closed) { con.Open(); } int actual_stock = Convert.ToInt32(TextBox2.Text.Trim()); int current_stock = Convert.ToInt32(TextBox5.Text.Trim()); if (global_actual_stock == actual_stock) { } else { if (actual_stock < global_issued_books) { Response.Write("<script>alert('Stocul curent nu poate fi mai mic decat cartile imprumutate!');</script>"); return; } else { current_stock = actual_stock - global_issued_books; TextBox5.Text = "" + current_stock; } } string genres = ""; foreach (int i in ListBox1.GetSelectedIndices()) { genres = genres + ListBox1.Items[i] + ","; } genres = genres.Remove(genres.Length - 1); SqlCommand cmd = new SqlCommand("UPDATE book_master_table SET book_name=@book_name, genre=@genre, author_name=@author_name, publisher_name=@publisher_name, publish_date=@publish_date, language=@language, edition=@edition, book_cost=@book_cost, no_of_pages=@no_of_pages, book_description=@book_description, actual_stock=@actual_stock, current_stock=@current_stock, WHERE book_id='" + TextBox3.Text.Trim() + "'", con); cmd.Parameters.AddWithValue("@book_name", TextBox4.Text.Trim()); cmd.Parameters.AddWithValue("@genre", genres); cmd.Parameters.AddWithValue("@author_name", DropDownList3.SelectedItem.Value); cmd.Parameters.AddWithValue("@publisher_name", DropDownList2.SelectedItem.Value); cmd.Parameters.AddWithValue("@publish_date", TextBox1.Text.Trim()); cmd.Parameters.AddWithValue("@language", DropDownList1.SelectedItem.Value); cmd.Parameters.AddWithValue("@edition", TextBox9.Text.Trim()); cmd.Parameters.AddWithValue("@book_cost", TextBox10.Text.Trim()); cmd.Parameters.AddWithValue("@no_of_pages", TextBox11.Text.Trim()); cmd.Parameters.AddWithValue("@book_description", TextBox6.Text.Trim()); cmd.Parameters.AddWithValue("@actual_stock", actual_stock.ToString()); cmd.Parameters.AddWithValue("@current_stock", current_stock.ToString()); cmd.ExecuteNonQuery(); con.Close(); GridView1.DataBind(); Response.Write("<script>alert('Carte actualizata cu succses!');</script>"); } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); } } else { Response.Write("<script>alert('ID invalid!');</script>"); } }