Drug names
Answer / 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 |
What is the stock exchange name of China?
Two persons on death bed, one is whom u love n anothr is who loves u. U can save only one. Whom would u n why?
I have only four months exp in banking field.. but i am searching for a better job.. in interview they are asking, what is the reason for changing the job so soon. the reason is to get high pay.. but if i tell like that.. they will not select me..so i want the best answer for this.. i am keep on searching for a better job.. so please me.. right now i am getting 6000rupees in HDFC BANK.. but i am expecting above 9000rupees.. so please help me to get a good job with a good pay..
hi friends,im doing masters in us and in a short span of time i will get a job,my husband who is a designer completed his degree working in a MNC can come to us on dependent visa?please answer me.....
what would you like to chage in IT field.2 things.
According to you what is important recruitment or retaining?
I AM A 8 LETTER INDIAN PLACE. LAST 4 LETTERS IS THE FIRST NAME OF A LADY TENNIS PLAYER. 4,5,6 LETTERS IS USED TO CARRY GOODS AND PASSENGERS. 6,5,7,2,3 IS A HILL STATION.
last month i attend for an inreview in indus ind bank ltd,iterviewer asked me tell something about ur self i have told him about my present job&responsibilities my education and my family back ground he told me iam not maintain hierarchy u please tell me how to answer to tell something about ur self in a perfect way
4 Answers Aviva, Call Centre, IBM,
What is the difference between subjective and objective career?
what is diffrence windows 98 and 2000
define success?
is a professor working in government college a gazetted officer?? someone plz rply soon