Answer Posted / santro
/*pgDrugnames.aspx.cs*/
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class pgDrugnames : System.Web.UI.Page
{
string strConnectionstring;
SqlConnection con;
SqlDataAdapter da;
protected void Page_Load(object sender, EventArgs e)
{
strConnectionstring =
ConfigurationManager.AppSettings["strSample"];
con = new SqlConnection(strConnectionstring);
if (!IsPostBack)
{
BindDrugDetails();
}
Button2.Attributes.Add
("onclick", "javascript:return ConfirmDelete();");
Button5.Attributes.Add("onclick", "window.open
('ReportViewer.aspx','newwindow','width=800,height=600,resiz
able=1,scrollbars=1'); return false");
}
protected void ListBox1_SelectedIndexChanged(object
sender, EventArgs e)
{
TextBox1.Text = ListBox1.SelectedItem.Text.ToString
();
}
protected void Button1_Click(object sender, EventArgs e)
{
ListBox1.Visible = false;
Label1.Text = "Edit Mode";
TextBox1.Text = string.Empty;
TextBox1.Focus();
Button2.Enabled = false;
Button3.Enabled = true;
Button5.Enabled = false;
Button4.Text = "Cancel";
}
protected void Button4_Click(object sender, EventArgs e)
{
if (Button4.Text == "Cancel")
{
ListBox1.Visible = true;
Label1.Text = "view mode";
Button2.Enabled = true;
Button5.Enabled = true;
Button3.Enabled = false;
Button4.Text = "Close";
TextBox1.Text =
ListBox1.SelectedItem.Text.ToString();
}
else if (Button4.Text.ToUpper().ToString()
== "CLOSE")
{
Response.Redirect("Default.aspx");
}
}
protected void Button3_Click(object sender, EventArgs e)
{
con.Open();
string strmax;
int intMaxId;
strmax = "select max(drugid)+1 from drugmaster";
SqlCommand cmdmax = new SqlCommand();
cmdmax.CommandText = strmax;
cmdmax.CommandType = CommandType.Text;
cmdmax.Connection = con;
intMaxId=int.Parse(cmdmax.ExecuteScalar().ToString
());
con.Close();
con.Open();
SqlCommand cmdInsert = new SqlCommand();
cmdInsert.CommandText = "INSERT INTO DRUGMASTER
VALUES("+ intMaxId+",'"+TextBox1.Text.ToString() +"',1)";
cmdInsert.CommandType = CommandType.Text;
cmdInsert.Connection = con;
cmdInsert.ExecuteNonQuery();
BindDrugDetails();
TextBox1.Text = string.Empty;
}
protected void BindDrugDetails()
{
DataSet ds = new DataSet();
da = new SqlDataAdapter("select * from drugmaster
order by drugname", con);
da.Fill(ds, "drugname");
ListBox1.Visible = true;
ListBox1.DataSource = ds;
ListBox1.DataTextField = "drugname";
ListBox1.DataValueField = "drugID";
ListBox1.DataBind();
ListBox1.SelectedIndex = 0;
TextBox1.Text = ListBox1.SelectedItem.Text.ToString
();
}
protected void Button2_Click(object sender, EventArgs e)
{
string strDel;
int intDrugId = int.Parse
(ListBox1.SelectedValue.ToString());
strDel = "delete from drugmaster where drugid=" +
intDrugId + "";
SqlCommand cmdDel = new SqlCommand();
cmdDel.CommandText = strDel;
cmdDel.CommandType = CommandType.Text;
con.Open();
cmdDel.Connection = con;
cmdDel.ExecuteNonQuery();
Page.RegisterStartupScript("OnClick", AlertScript
("Record Deleted Successfully"));
BindDrugDetails();
}
string AlertScript(string message)
{
string strScript = "";
strScript = "<script>";
strScript = strScript + "alert( '" + message
+ "');";
strScript = strScript + "</script>";
return strScript;
}
}
/*pgDrugnames.aspx - source
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript" language="javascript">
function ConfirmDelete()
{
if(confirm('Are You Sure You Want to Delete?'))
{
return true;
}
return false;
}
</script>
</head>*/
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
Is it right to leave TCS & join Accenture for 2 years experienced Software Professional ?
what is the number of biodiversity in india
hi i m laxmi pandit inm in waiting list of karnataka bank.anyone tell me what is it mean.is it surity of selection.they provide me last date 31 march 2013.help me i m confuse
hi has anybody faced SBI associates PO GDPI? mine is on 29th. please share
i want to be manager in sotre and purchase
3918512522. Decode by subsitituting with letters to get the final response
Tell us how do you discharge your duties in your duty post?
I am serving as bank office in mmgs all grade and I have applied for uppcs lower subordinate exam schedule on 6 april 2014 presently I am getting net salary of 34000 around ,what will be the net salary of uppcs lower subordinate and will it be good for me to leave the job of bank and join uppcs lower subordinate if selected.
Pl. Brief scope for Bsc nursing in India
plz mail me the latest topics for discriptive papers or latest topics for bank clerical exams
Why do you want to join Genpact?
what is the main difference between direct & indirect marketing?
Helo there. Whoever have been shortlisted for sbi interview and have it before 4th may,plz update wt questions where asked in the interview
hi, i've cleared union bank of india's clerical cadre written exam. and called for interview on 18th of this month. I dont have the copy of fee payment challan and print out of online application. whether these things are very important or not?
iam getting offers for back door process .form the comapanies medhasolutions,lanticsolutions,precessglobal.inc(banglore) cybate commitment 1 lakh salary 1.44per annum mind tech soft commitment 90000rs salary 1.44per annum profilent commitment 90000rs salary 1.80per annum config commitment 70000rs salary 1.20per annum v one infotech commitment 1 lakh salary 1.44per annum finch commitment 90000rs salary 1.44per annum bin soft tech commitment 1.20 lakh salary 2.40per annum impact commitment 1 lakh salary 2.44per annum jkl consol commitment 1 lakh salary 1.8 - 2.4per annum oligoi solutions commitment 1lakh 2.64 per annum plz tell me which one to beleve if any one know details plz send me msg @9885090595