<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Demand</title>
<link rel="stylesheet" type="text/css" href="" />
<style type="text/css">
.style1
{
height: 21px;
width: 209px;
}
.style3
{
height: 21px;
width: 200px;
}
.style4
{
width: 992px;
}
.style5
{
height: 21px;
width: 124px;
}
.style6
{
height: 21px;
width: 189px;
}
</style>
<script language="javascript" type="text/javascript">
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Panel ID="Panel1" runat="server" Width="930px">
<table style="width: 978px">
<tr>
<td class="tdheadingcss" id="Td1"
style="background-color:ButtonFace; width: 885px;" align="center"
runat="server">
<asp:Label Text = "Demand" ID="Label10" runat="server">
</tr>
</table>
<table style="width: 976px">
<tr>
<td class="style1" valign="top">District</td>
<td class="style3" valign="top">
<asp:DropDownList ID="DropDownList1" runat="server"
>
</td>
<td class="tdcss" valign="top" style="height: 21px; width: 146px;">
Financial Year</td>
<td class="tdcss" valign="top" style="height: 21px; width: 310px;">
<asp:DropDownList ID="DropDownList4" runat="server">
<asp:ListItem>
<asp:ListItem>2010-2011
<asp:ListItem>2011-2012
<asp:ListItem>2012-2013
<asp:ListItem>2013-2014
<asp:ListItem>2014-2015
<asp:ListItem>2015-2016
<asp:ListItem>2016-2017
<asp:ListItem>2017-2018
<asp:ListItem>2018-2019
<asp:ListItem>2019-2020
<asp:ListItem>2020-2021
</td>
</tr>
<tr>
<td class="style1" valign="top">Quarter</td>
<td class="style3" valign="top">
<asp:DropDownList ID="DropDownList2" runat="server">
<asp:ListItem>
<asp:ListItem>Q1
<asp:ListItem>Q2
<asp:ListItem>Q3
<asp:ListItem>Q4
</td>
</tr>
<tr>
<td class="style1" valign="top">SHC</td>
<td class="style3" valign="top">
<asp:DropDownList ID="DropDownList3" runat="server"
>
</td></tr>
</table>
<table style="width: 977px">
<tr>
<td align="center" colspan="6" style="width: 925px">
</td>
</tr>
</table>
<asp:Panel ID="Panel2" runat="server" Width="930px">
<table style="width: 978px">
<tr>
<td class="style4" id="Td2"
style="background-color:ButtonFace; " align="center"
runat="server">
<asp:Label Text = "Medicine Details" ID="Label2" runat="server">
</tr>
</table>
<table style="width: 978px">
<tr>
<td class="style5" valign="top">Medicine</td>
<td class="style6" valign="top">
<asp:DropDownList ID="DropDownList5" runat="server"
>
</td>
<td class="style3" valign="top"></td>
</tr>
<tr>
<td class="style5" valign="top">Quantity</td>
<td class="style6" valign="top">
<asp:TextBox ID="TextBox1" runat="server"></td>
<td class="style3" valign="top"></td>
</tr>
<tr>
<td class="style5" valign="top"></td>
<td class="style6" valign="top">
<asp:Button ID="Button1" runat="server" Text="Save" onclick="Button1_Click" /></td>
<td class="style7" valign="top">
<asp:Button ID="Exit" runat="server" onclick="Exit_Click" Text="Exit" />
</td>
</tr>
</table>
<table style="width: 931px">
<tr>
<td class="style5" valign="top">
</td>
</tr>
</table>
</div>
<asp:GridView ID="GridView1" runat="server" >
</form>
</body>
</html>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class Default2 : System.Web.UI.Page
{
static string constr = System.Configuration.ConfigurationManager.AppSettings["ConnectionInfo"];
SqlConnection con = new SqlConnection(constr);
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
filldistrict();
fillSHC();
fillMedicine();
}
}
public void filldistrict()
{
DataTable dt = new DataTable();
string sql = "SELECT * FROM tbl_District ";
con.Open();
SqlDataAdapter objAdapter = new SqlDataAdapter(sql, con);
objAdapter.Fill(dt);
if (dt.Rows.Count > 0)
{
DropDownList1.Items.Add(new ListItem("-Select-", "0"));
for (int i = 0; i < dt.Rows.Count; i++)
{
DropDownList1.Items.Add(new ListItem(dt.Rows[i]["DistrictName"].ToString(), dt.Rows[i]["Dcode"].ToString()));
}
}
else
{
}
con.Close();
}
public void fillSHC()
{
DataTable dt = new DataTable();
string sql = "SELECT * FROM tblSC ";
con.Open();
SqlDataAdapter objAdapter = new SqlDataAdapter(sql, con);
objAdapter.Fill(dt);
if (dt.Rows.Count > 0)
{
DropDownList3.Items.Add(new ListItem("-Select-", "0"));
for (int i = 0; i < dt.Rows.Count; i++)
{
DropDownList3.Items.Add(new ListItem(dt.Rows[i]["SCName"].ToString(), dt.Rows[i]["SCID"].ToString()));
}
}
else
{
}
con.Close();
}
public void fillMedicine()
{
DataTable dt = new DataTable();
string sql = "SELECT * FROM Drug ";
con.Open();
SqlDataAdapter objAdapter = new SqlDataAdapter(sql, con);
objAdapter.Fill(dt);
if (dt.Rows.Count > 0)
{
DropDownList5.Items.Add(new ListItem("-Select-", "0"));
for (int i = 0; i < dt.Rows.Count; i++)
{
DropDownList5.Items.Add(new ListItem(dt.Rows[i]["medicine"].ToString(), dt.Rows[i]["eml_code"].ToString()));
}
}
else
{
}
con.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand sqlCommand = new SqlCommand("insert into tbldemand values ('" + DropDownList1.SelectedItem.Value + "','" + DropDownList4.SelectedItem.Value + "','" + DropDownList2.SelectedItem.Value + "','" + DropDownList3.SelectedItem.Value + "','" + DropDownList5.SelectedItem.Value + "','" + TextBox1.Text + "')", con);
sqlCommand.ExecuteNonQuery();
string med = "select medicine,Quantity from tbldemand ,drug where tbldemand.Med_ID=drug.eml_code";
DataTable dt = new DataTable();
SqlDataAdapter adapt = new SqlDataAdapter(med, con);
adapt.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataMember = "med";
GridView1.DataBind();
con.Close();
}
protected void Exit_Click(object sender, EventArgs e)
{
}
}