TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
sathish kumar
NA
117
165.1k
i want to select only one radio button based on gridview row selection
Jul 10 2012 2:20 AM
hi friends...
i want to select only one radio button based on gridview row selection
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="welcome">
<asp:Label ID="lblMenu" runat="server" Text="General Collection"
Font-Size="Medium"></asp:Label>
<asp:label ID="Label32" runat="server" text="(*) - Mandatory Fields"
ForeColor="Red"></asp:label>
</td>
</tr>
<tr>
<td height="1" style="background:images/undertext_bg.gif" class="bgx"><img alt= "" src="images/spacer.gif" width="1" height="1" /></td>
</tr>
</table>
<table>
<tr>
<td class="style14">
<asp:Label ID="Label1" runat="server" Text="Receipt No"></asp:Label>
<asp:Label ID="Label41" runat="server" ForeColor="Red" Text="(*)"></asp:Label>
<asp:TextBox ID="txtReceiptNo" runat="server" ForeColor="#000099" Width="100px"></asp:TextBox>
<asp:Label ID="Label2" runat="server" Text="Date"></asp:Label>
<asp:Label ID="Label44" runat="server" ForeColor="Red" Text="(*)"></asp:Label>
<asp:TextBox ID="txtDate" runat="server" ForeColor="#000099"
Width="77px"></asp:TextBox>
<asp:Label ID="Label38" runat="server" Text="Patient Type"></asp:Label>
<asp:Label ID="Label31" runat="server" ForeColor="Red" Text="(*)"></asp:Label>
<asp:RadioButton ID="rbIP" runat="server" GroupName="a" Text="IP"
AutoPostBack="true" oncheckedchanged="rbIP_CheckedChanged"/>
<asp:RadioButton ID="rbOP" runat="server" GroupName="a" Text="OP"
AutoPostBack="true" oncheckedchanged="rbOP_CheckedChanged" />
<asp:RadioButton ID="rbDirect" runat="server" GroupName="a" Text="Direct"
AutoPostBack="true" oncheckedchanged="rbDirect_CheckedChanged" />
<br />
<br />
<asp:Label ID="Label3" runat="server" Text="Hospital No"></asp:Label>
<asp:Label ID="Label28" runat="server" ForeColor="Red" Text="(*)"></asp:Label>
<asp:TextBox ID="txtHospitalNo" runat="server" ForeColor="#000099" Width="103px"></asp:TextBox>
<asp:Label ID="Label4" runat="server" Text="Patient Name"></asp:Label>
<asp:Label ID="Label40" runat="server" ForeColor="Red" Text="(*)"></asp:Label>
<asp:DropDownList ID="ddlTitle" runat="server"
Height="22px" ForeColor="#000099"
onselectedindexchanged="ddlTitle_SelectedIndexChanged">
<asp:ListItem><--Title--></asp:ListItem>
<asp:ListItem>Sri.</asp:ListItem>
<asp:ListItem>Kumar</asp:ListItem>
<asp:ListItem>Kumari</asp:ListItem>
<asp:ListItem>Mr.</asp:ListItem>
<asp:ListItem>Mrs.</asp:ListItem>
<asp:ListItem>Miss</asp:ListItem>
<asp:ListItem>Ms.</asp:ListItem>
<asp:ListItem>Dr.</asp:ListItem>
<asp:ListItem>Prof.</asp:ListItem>
<asp:ListItem>Master</asp:ListItem>
<asp:ListItem>Mother Of</asp:ListItem>
<asp:ListItem>Brother Of</asp:ListItem>
<asp:ListItem>Baby Of</asp:ListItem>
<asp:ListItem>Father Of</asp:ListItem>
<asp:ListItem>Others</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="ddlPatientName" runat="server" Height="22px"
Width="254px" ForeColor="#000099" AutoPostBack="True">
</asp:DropDownList>
<br />
<br />
<asp:Label ID="Label42" runat="server" Text="Visit Type"></asp:Label>
<asp:Label ID="Label43" runat="server" ForeColor="Red" Text="(*)"></asp:Label>
<asp:DropDownList ID="ddlVisitType" runat="server" Height="22px" Width="202px" ForeColor="#000099">
</asp:DropDownList>
</td>
</tr>
</table>
<table>
<tr>
<td class="style17" align="center">
<asp:Label ID="Label5" runat="server" Text="Transaction Type"></asp:Label></td>
<td class="style16" align="center"> <asp:Label ID="Label6" runat="server" Text="Charge"></asp:Label> </td>
</tr>
<tr>
<td class="style18">
<asp:DropDownList ID="ddlTransactionType" runat="server" Height="20px"
Width="239px" ForeColor="#000099" AutoPostBack="True"
onselectedindexchanged="ddlTransactionType_SelectedIndexChanged">
</asp:DropDownList>
</td>
<td class="style12">
<asp:TextBox ID="txtCharge" runat="server" ForeColor="#000099" AutoPostBack="True"></asp:TextBox></td>
<td class="style15">
<asp:Button ID="cmdAddItem" runat="server" Font-Bold="True" Font-Names="Tahoma"
Font-Size="X-Small" Height="26px" onclick="cmdAddItem_Click" Text="ADD ITEM"
Width="84px" />
<br />
</td>
</tr>
</table>
<table class="style4">
<tr>
<td>
<asp:GridView ID="gvGeneralCollection" runat="server" DataKeyNames="TransName"
CellPadding="4" ForeColor="#333333" GridLines="None"
Width="579px" AllowPaging="True" AutoGenerateColumns="False" ShowFooter="True"
EmptyDataText="No Records found !!" style="margin-left: 30px"
onrowdeleting="gvGeneralCollection_RowDeleting" onrowdatabound="gvGeneralCollection_RowDataBound"
>
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<Columns>
<asp:BoundField DataField="TransName" HeaderText="TransName"
SortExpression="TransName">
</asp:BoundField>
<asp:TemplateField HeaderText="Charge">
<ItemTemplate>
<asp:Label ID="lbltotalAmount" runat="server" Text='<%# Eval("Charge")%>' ></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lbltotalAmount" runat="server" Text="0.00"></asp:Label>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField >
<ItemTemplate>
<asp:LinkButton ID="LinkButton1"
CommandArgument='<%# Eval("TransName") %>'
CommandName="Delete" runat="server" OnClientClick="javascript:return confirm('Do you really want to \ndelete the item?');">
Delete</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerSettings Position="Top" FirstPageText="First" LastPageText="Last"
Mode="NextPreviousFirstLast" NextPageText="Next" PreviousPageText="Previous" />
<FooterStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
<RowStyle CssClass="RowStyle" />
<PagerStyle CssClass="PagerStyle" />
<SelectedRowStyle CssClass="SelectedRowStyle" />
<HeaderStyle CssClass="HeaderStyle" />
<EditRowStyle CssClass="EditRowStyle" />
<AlternatingRowStyle CssClass="AltRowStyle" />
</asp:GridView>
</td>
</tr>
</table>
<table class="style5">
<tr>
<td class="style10">
<br />
<asp:Label ID="Label7" runat="server" Text="a Sum of Rs"></asp:Label>
<asp:TextBox ID="txtSum" runat="server" Width="107px" ForeColor="#000099"></asp:TextBox>
<asp:Label ID="Label8" runat="server" Text="By"></asp:Label>
<asp:RadioButton ID="rbCash" runat="server" Text="Cash" GroupName="b"
AutoPostBack="true" oncheckedchanged="rbCash_CheckedChanged"/>
<asp:RadioButton ID="rbCheque" runat="server" Text="Cheque" GroupName="b"
AutoPostBack="true" oncheckedchanged="rbCheque_CheckedChanged" />
<asp:RadioButton ID="rbDD" runat="server" Text="DD" GroupName="b"
AutoPostBack="true" oncheckedchanged="rbDD_CheckedChanged"/>
<asp:RadioButton ID="rbCreditCard" runat="server" Text="Credit Card"
GroupName="b" AutoPostBack="true"
oncheckedchanged="rbCreditCard_CheckedChanged"/>
<asp:RadioButton ID="rbDebitCard" runat="server" Text="Debit Card"
GroupName="b" AutoPostBack="true"
oncheckedchanged="rbDebitCard_CheckedChanged" />
<asp:RadioButton ID="rbAmountCollectLater" runat="server"
Text="Amount Collect Later" GroupName="b" AutoPostBack="true"
oncheckedchanged="rbAmountCollectLater_CheckedChanged" />
<br />
</td>
</tr>
<tr><td class="style13">
<asp:Label ID="Label9" runat="server" Text="Vide No"></asp:Label>
<asp:TextBox ID="txtVideNo" runat="server" Width="109px" ForeColor="#000099"></asp:TextBox>
<asp:Label ID="Label10" runat="server" Text="Dated"></asp:Label>
<asp:TextBox ID="txtDated" runat="server" Width="81px"
ForeColor="#000099"></asp:TextBox>
<asp:Label ID="Label11" runat="server" Text="Drawn On"></asp:Label>
<asp:TextBox ID="txtDrawnOn" runat="server" Width="119px"
ForeColor="#000099"></asp:TextBox>
<br />
</td></tr>
<tr>
<td class="style13">
<asp:Label ID="Label12" runat="server" Text="Select Consulted Doctor"></asp:Label>
<asp:DropDownList ID="ddlConsultedDoctor" runat="server" Height="22px"
ForeColor="#000099" Width="324px">
</asp:DropDownList>
<br />
</td>
</tr>
<tr>
<td class="style13">
<asp:Label ID="Label13" runat="server" Text="Remarks"></asp:Label>
<asp:TextBox ID="txtRemarks" runat="server" style="margin-left: 14px"
TextMode="MultiLine" Width="548px" ForeColor="#000099"></asp:TextBox>
</td>
</tr>
</table>
<table >
<tr><td></td></tr>
<tr>
<td >
</td>
<td class="Name">
<asp:Button ID="cmdAdd" runat="server" Text="ADD" Width="84px" Font-Bold="True"
Font-Names="Tahoma" Font-Size="X-Small" onclick="cmdAdd_Click" />
<asp:Button ID="cmdModify" runat="server" Text="MODIFY" Width="84px" Font-Bold="True"
Font-Names="Tahoma" Font-Size="X-Small" onclick="cmdModify_Click" />
<asp:Button ID="cmdDelete" runat="server" Text="DELETE" Width="84px" Font-Bold="True"
Font-Names="Tahoma" Font-Size="X-Small" onclick="cmdDelete_Click" />
<asp:Button ID="cmdCancel" runat="server" Text="RESET" Width="84px" Font-Bold="True"
Font-Names="Tahoma" Font-Size="X-Small" onclick="cmdCancel_Click" />
</td>
</tr>
</table>
<div class="styleDiv">
<br />
<asp:Label ID="LblSearch" runat="server"
Text="Filter By "></asp:Label>
<asp:DropDownList ID="ddlSearch" runat="server" ForeColor="#000099">
<asp:ListItem Text="Receipt No" Value="ReceiptNo" />
<asp:ListItem Text="Hospital No" Value="HospitalNo" />
<asp:ListItem Text="Payment Type" Value="Payment_Type" />
<asp:ListItem Text="Remarks" Value="Remarks" />
</asp:DropDownList>
<asp:TextBox ID="TxtSearch" runat="server" Width="130px" ForeColor="#000099"></asp:TextBox>
<asp:Button ID="CmdSearch" runat="server" Height="20px"
onclick="CmdSearch_Click" Text="Search" Width="84px" />
<asp:Button ID="CmdClear" runat="server" Height="20px" onclick="CmdClear_Click"
Text="Clear" Width="84px" />
<br />
<br />
<asp:Label ID="lblSearchRecords" runat="server" Text="Label"></asp:Label>
<br />
<asp:Label ID="lblPage" runat="server"
Text="Label"></asp:Label>
<asp:Label ID="lblPageList" runat="server" Text="Go to"></asp:Label>
<asp:DropDownList ID="ddlPageList" runat="server"
onselectedindexchanged="ddlPageList_SelectedIndexChanged"
AutoPostBack = "true" ForeColor="#000099"></asp:DropDownList>
<asp:Label ID="Label33" runat="server" Text="Page"></asp:Label>
<br />
<asp:Label
ID="Label36" runat="server" Text="Total Records :"></asp:Label>
<asp:Label ID="lblRecords" runat="server" Text="(Label )"></asp:Label>
</div>
<table class="GridViewStyle">
<tr>
<td class="style3">
<asp:Panel ID="scrollableGridArea" runat="server" ScrollBars ="Auto"
style="overflow:scroll; height: 290px; width:700px" Height="240px"
Width="787px">
<asp:GridView ID="gvCollection" runat="server" AllowPaging="True"
AutoGenerateColumns="False" CellPadding="4" DataSourceID="SqlCollection"
EmptyDataText="No Records found !!" ForeColor="#333333" GridLines="None"
Height="289px" ondatabound="gvCollection_DataBound"
onprerender="gvCollection_PreRender"
onrowcommand="gvCollection_RowCommand"
onselectedindexchanged="gvCollection_SelectedIndexChanged"
ShowFooter="True" Width="482px">
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<Columns>
<asp:CommandField ShowSelectButton="true" />
<asp:BoundField DataField="ReceiptNo" HeaderText="ReceiptNo" SortExpression="ReceiptNo" />
<asp:BoundField DataField="ReceiptDate" HeaderText="ReceiptDate"
SortExpression="ReceiptDate" />
<asp:BoundField DataField="Patient_ID" HeaderText="Patient ID"
SortExpression="Patient_ID" />
<asp:BoundField DataField="DoctorID" HeaderText="DoctorID" SortExpression="DoctorID" />
<asp:BoundField DataField="Amount" HeaderText="Amount"
SortExpression="Amount" />
<asp:BoundField DataField="Payment_Type" HeaderText="Payment Type"
SortExpression="Payment_Type" />
<asp:BoundField DataField="Cheque_No" HeaderText="Cheque No"
SortExpression="Cheque_No" />
<asp:BoundField DataField="Cheque_Date" HeaderText="Cheque Date "
SortExpression="Cheque_Date" />
<asp:BoundField DataField="Banker" HeaderText="Banker"
SortExpression="Banker" />
<asp:BoundField DataField="DateCreated" HeaderText="DateCreated"
SortExpression="DateCreated" />
<asp:BoundField DataField="Remarks" HeaderText="Remarks"
SortExpression="Remarks" />
</Columns>
<FooterStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
<PagerStyle CssClass="PagerStyle" />
<SelectedRowStyle CssClass="SelectedRowStyle" />
<HeaderStyle CssClass="HeaderStyle" />
<EditRowStyle CssClass="EditRowStyle" />
<AlternatingRowStyle CssClass="AltRowStyle" />
<PagerSettings FirstPageText="First" LastPageText="Last"
Mode="NextPreviousFirstLast" NextPageText="Next" PageButtonCount="5"
Position="Top" PreviousPageText="Previous" />
</asp:GridView>
<asp:SqlDataSource ID="SqlCollection" runat="server"
ConnectionString="<%$ ConnectionStrings:CMC %>"
SelectCommand=" SELECT COLLECTION_TRANS.ReceiptNo, COLLECTION_TRANS.ReceiptDate, COLLECTION_TRANS.DoctorID, COLLECTION_TRANS.Charge,payment_details.Patient_ID, payment_details.Payment_Type, payment_details.Amount, payment_details.Cheque_No, payment_details.Cheque_Date,payment_details.Banker, payment_details.DateCreated, payment_details.Remarks FROM COLLECTION_TRANS INNER JOIN payment_details ON COLLECTION_TRANS.HospitalNo = payment_details.HospitalNo"
FilterExpression="{0} LIKE '{1}%'">
<FilterParameters>
<asp:ControlParameter Name="FieldToSearch" ControlID="ddlSearch" PropertyName="SelectedValue" />
<asp:ControlParameter Name="SearchCriteria" ControlID="TxtSearch"
PropertyName="Text" />
</FilterParameters>
</asp:SqlDataSource>
</asp:Panel>
</td>
</tr>
</table>
below is my aspx.cs code
public partial class GeneralCollection : System.Web.UI.Page
{
decimal grdAmount = 0;
private string PatientType = "";
private string PaymentType = "";
private string SearchString = "";
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack == false)
{
VisitType();
TransactionType();
ReceiptNo();
PatientName();
ConsultedDoctor();
Grid_clear();
txtReceiptNo.ReadOnly = true;
txtDate.Enabled = false;
txtHospitalNo.ReadOnly = true;
ddlVisitType.Enabled = false;
ddlPatientName.Enabled = false;
ddlTitle.Enabled = false;
ddlTransactionType.Enabled = false;
txtCharge.Enabled = false;
txtSum.Enabled = false;
txtVideNo.Enabled = false;
ddlConsultedDoctor.Enabled = false;
txtDrawnOn.Enabled = false;
txtDated.Enabled = false;
txtRemarks.Enabled = false;
cmdModify.Enabled = false;
cmdDelete.Enabled = false;
cmdDelete.Attributes.Add("OnClick", "return WarningDelete()");
lblSearchRecords.Visible = false;
//User = Request.QueryString["txtuser"];
// this.txtDrawnOn.Text = Request.QueryString["txtuser"];
}
}
protected void ReceiptNo()
{
string dbConn = ConfigurationManager.ConnectionStrings["CMC"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(dbConn);
sqlConn.Open();
string strSQL = "Select MAX(CID) from COLLECTION_TRANS ";
SqlCommand cmd = new SqlCommand(strSQL, sqlConn);
object No = cmd.ExecuteScalar();
if (No == DBNull.Value)
{
txtReceiptNo.Text = "1";
}
else
{
int m = Convert.ToInt32(No.ToString());
int n = m + 1;
txtReceiptNo.Text = n.ToString();
}
sqlConn.Close();
}
protected void VisitType()
{
ddlVisitType.Items.Clear();
string strSQL;
string dbConn = ConfigurationManager.ConnectionStrings["CMC"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(dbConn);
sqlConn.Open();
strSQL = " select VisitName from VisitTypes ";
SqlCommand cmdRoomType = new SqlCommand(strSQL, sqlConn);
ddlVisitType.Items.Add("<======Select=====>");
SqlDataReader dr = cmdRoomType.ExecuteReader();
while (dr.Read())
{
ddlVisitType.Items.Add(dr[0].ToString());
}
sqlConn.Close();
}
protected void TransactionType()
{
ddlTransactionType.Items.Clear();
string strSQL;
string dbConn = ConfigurationManager.ConnectionStrings["CMC"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(dbConn);
sqlConn.Open();
strSQL = " select TypeName from TransactionType ";
SqlCommand cmdRoomType = new SqlCommand(strSQL, sqlConn);
ddlTransactionType.Items.Add("<======Select=====>");
SqlDataReader dr = cmdRoomType.ExecuteReader();
while (dr.Read())
{
ddlTransactionType.Items.Add(dr[0].ToString());
}
sqlConn.Close();
}
protected void ConsultedDoctor()
{
ddlConsultedDoctor.Items.Clear();
string strSQL;
string dbConn = ConfigurationManager.ConnectionStrings["CMC"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(dbConn);
sqlConn.Open();
strSQL = "select Name from doctor_details";
SqlCommand cmdConsultedDoctor = new SqlCommand(strSQL, sqlConn);
ddlConsultedDoctor.Items.Add("<============Select==========>");
SqlDataReader drConsultedDoctor = cmdConsultedDoctor.ExecuteReader();
while (drConsultedDoctor.Read())
{
ddlConsultedDoctor.Items.Add(drConsultedDoctor[0].ToString());
}
sqlConn.Close();
}
protected void PatientName()
{
ddlPatientName.Items.Clear();
string strSQL;
string dbConn = ConfigurationManager.ConnectionStrings["CMC"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(dbConn);
sqlConn.Open();
strSQL = "select Patient_Name from registration_details";
SqlCommand cmdPatientName = new SqlCommand(strSQL, sqlConn);
ddlPatientName.Items.Add("<============Select==========>");
SqlDataReader drPatientName = cmdPatientName.ExecuteReader();
while (drPatientName.Read())
{
ddlPatientName.Items.Add(drPatientName[0].ToString());
}
sqlConn.Close();
}
public static string DoctorID(string strDoctorCode)
{
string Code = "";
string strSQL;
string dbConn = ConfigurationManager.ConnectionStrings["CMC"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(dbConn);
sqlConn.Open();
strSQL = " select RegID from doctor_details where Name='" + strDoctorCode + "'";
SqlCommand cmdTestHeads = new SqlCommand(strSQL, sqlConn);
SqlDataReader drTestHeads = cmdTestHeads.ExecuteReader();
if (drTestHeads.Read())
{
Code = drTestHeads[0].ToString();
}
sqlConn.Close();
return Code;
}
public static string PatientCode(string strPatientId)
{
string Code = "";
string strSQL;
string dbConn = ConfigurationManager.ConnectionStrings["CMC"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(dbConn);
sqlConn.Open();
strSQL = " select RegID from registration_details where Patient_Name='" + strPatientId + "'";
SqlCommand cmdTestHeads = new SqlCommand(strSQL, sqlConn);
SqlDataReader drTestHeads = cmdTestHeads.ExecuteReader();
if (drTestHeads.Read())
{
Code = drTestHeads[0].ToString();
}
sqlConn.Close();
return Code;
}
protected void ddlTransactionType_SelectedIndexChanged(object sender, EventArgs e)
{
string strSQL;
string dbConn = ConfigurationManager.ConnectionStrings["CMC"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(dbConn);
sqlConn.Open();
strSQL = "select Charge from TransactionType where TypeName='"+ddlTransactionType.SelectedItem.ToString()+"'";
SqlCommand cmdWardDetails = new SqlCommand(strSQL, sqlConn);
SqlDataReader drWardDetails = cmdWardDetails.ExecuteReader();
if(drWardDetails.Read())
{
txtCharge.Text = drWardDetails[0].ToString();
}
sqlConn.Close();
}
protected void ClearFields()
{
txtReceiptNo.Text = "";
txtDate.Text = "";
txtHospitalNo.Text = "";
ddlVisitType.SelectedIndex = 0;
ddlPatientName.SelectedIndex = 0;
ddlTitle.SelectedIndex = 0;
ddlTransactionType.SelectedIndex = 0;
ddlConsultedDoctor.SelectedIndex = 0;
txtCharge.Text = "";
txtSum.Text = "";
txtVideNo.Text = "";
txtDrawnOn.Text = "";
txtDated.Text = "";
txtRemarks.Text = "";
}
protected void cmdAddItem_Click(object sender, EventArgs e)
{
gvGeneralCollection.Visible = true;
try
{
if (ddlTransactionType.SelectedIndex != 0)
{
gvGeneralCollection.Visible = true;
string dbConn = ConfigurationManager.ConnectionStrings["CMC"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(dbConn);
sqlConn.Open();
string strSQL1 = " INSERT INTO [tmpTransList](THID,TransName,Charge)VALUES('" + txtReceiptNo.Text + "','" + ddlTransactionType.SelectedItem.ToString() + "','" + txtCharge.Text + "')";
SqlCommand cmd1 = new SqlCommand(strSQL1, sqlConn);
cmd1.ExecuteNonQuery();
SqlDataAdapter dadapter = new SqlDataAdapter(" SELECT THID,TransName,Charge from tmpTransList", sqlConn);
DataSet dset = new DataSet();
dadapter.Fill(dset);
gvGeneralCollection.DataSource = dset;
gvGeneralCollection.DataBind();
sqlConn.Close();
ddlTransactionType.SelectedIndex = 0;
txtCharge.Text = "";
}
else
{
Response.Write("<script language='javascript'>alert('Select Transaction Type!!!');</script>");
}
}
catch (Exception)
{
Response.Write("<script language='javascript'>alert('Invalid Data!!!');</script>");
}
}
protected void rbIP_CheckedChanged(object sender, EventArgs e)
{
if (rbIP.Checked == true)
{
PatientType = "IP";
string dbConn = ConfigurationManager.ConnectionStrings["CMC"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(dbConn);
sqlConn.Open();
string strSQL = "Select MAX(RegID) from registration_details ";
SqlCommand cmdRegistration = new SqlCommand(strSQL, sqlConn);
object No = cmdRegistration.ExecuteScalar();
if (No == DBNull.Value)
{
txtHospitalNo.Text = "CMC1";
}
else
{
int m = Convert.ToInt32(No.ToString());
int n = m + 1;
txtHospitalNo.Text = "CMC" + n.ToString();
}
}
}
protected void rbOP_CheckedChanged(object sender, EventArgs e)
{
if (rbOP.Checked == true)
{
PatientType = "OP";
string dbConn = ConfigurationManager.ConnectionStrings["CMC"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(dbConn);
sqlConn.Open();
string strSQL = "Select MAX(RegID) from registration_details ";
SqlCommand cmdRegistration = new SqlCommand(strSQL, sqlConn);
object No = cmdRegistration.ExecuteScalar();
if (No == DBNull.Value)
{
txtHospitalNo.Text = "CMC1";
}
else
{
int m = Convert.ToInt32(No.ToString());
int n = m + 1;
txtHospitalNo.Text = "CMC" + n.ToString();
}
}
}
protected void rbDirect_CheckedChanged(object sender, EventArgs e)
{
if (rbDirect.Checked == true)
{
PatientType = "Direct";
string dbConn = ConfigurationManager.ConnectionStrings["CMC"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(dbConn);
sqlConn.Open();
string strSQL = "Select MAX(RegID) from registration_details ";
SqlCommand cmdRegistration = new SqlCommand(strSQL, sqlConn);
object No = cmdRegistration.ExecuteScalar();
if (No == DBNull.Value)
{
txtHospitalNo.Text = "RF1";
}
else
{
int m = Convert.ToInt32(No.ToString());
int n = m + 1;
txtHospitalNo.Text = "RF" + n.ToString();
}
}
}
protected void Save_Record()
{
try
{
if (validate_data())
{
string DocId = DoctorID(ddlConsultedDoctor.SelectedValue);
string PId = PatientCode(ddlPatientName.SelectedValue);
string User = Request.QueryString["txtuser"];
string Computer = System.Environment.MachineName;
string strSQL;
string dbConn = ConfigurationManager.ConnectionStrings["CMC"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(dbConn);
sqlConn.Open();
strSQL = "INSERT INTO [COLLECTION_TRANS](ReceiptNo,ReceiptDate,DoctorID,HospitalNo,Charge,UserLogged,DateCreated)VALUES ('" + txtReceiptNo.Text + "','" + txtDate.Text + "','" + DocId + "','" + txtHospitalNo.Text + "','" + txtSum.Text + "','" + User + "','" + System.DateTime.Now.ToString("dd/MM/yyyy") + "')";
SqlCommand cmdCollection = new SqlCommand(strSQL, sqlConn);
cmdCollection.ExecuteNonQuery();
// string strSQL1 = "INSERT INTO [payment_details](Receipt_Number,Receipt_Date,HospitalNo,Patient_ID,Amount,Payment_Type,Cheque_No,Cheque_Date,Banker,DateCreated,Remarks)VALUES ('" + txtReceiptNo.Text + "','" + txtDate.Text + "','" + txtHospitalNo.Text + "','" + PId + "','" + txtSum.Text + "','" + PaymentType + "','" + txtVideNo.Text + "','" + txtDated.Text + "','" + txtDrawnOn.Text + "','" + System.DateTime.Now.ToString("dd/MM/yyyy") + "','" + txtRemarks.Text + "')";
//string strSQL1 = "INSERT INTO [payment_details](Receipt_Number,Receipt_Date,HospitalNo,Patient_ID,Amount,Payment_Type,Cheque_No,ComputerName,Banker,DateCreated,Remarks,Cheque_Date)VALUES ('" + txtReceiptNo.Text + "','" + txtDate.Text + "','" + txtHospitalNo.Text + "','" + PId + "','" + txtSum.Text + "','" + PaymentType + "','" + txtVideNo.Text + "','" + Computer + "','" + txtDrawnOn.Text + "','" + System.DateTime.Now.ToString("dd/MM/yyyy") + "','" + txtRemarks.Text + "','"+txtDated.Text+"')";
//SqlCommand cmdPaymentDetails = new SqlCommand(strSQL1, sqlConn);
//cmdPaymentDetails.ExecuteNonQuery();
//sqlConn.Close();
Response.Write("<script language='javascript'>alert('Data Saved Successfully...');</script>");
Load_Record();
}
}
catch (Exception)
{
Response.Write("<script language='javascript'>alert('Data Not Saved Successfully...');</script>");
}
}
protected void Delete_Record()
{
string strSQL;
string dbConn = ConfigurationManager.ConnectionStrings["CMC"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(dbConn);
sqlConn.Open();
strSQL = "Delete [COLLECTION_TRANS] Where ReceiptNo ='"+txtReceiptNo.Text+"'";
SqlCommand cmdWardDetails = new SqlCommand(strSQL, sqlConn);
cmdWardDetails.ExecuteNonQuery();
sqlConn.Close();
Response.Write("<script language='javascript'>alert('Entry Deleted Successfully...');</script>");
Load_Record();
// Record_Count();
}
protected void Load_Record()
{
SqlCollection.SelectCommand = " SELECT COLLECTION_TRANS.ReceiptNo, COLLECTION_TRANS.ReceiptDate, COLLECTION_TRANS.TransType, COLLECTION_TRANS.DoctorID,COLLECTION_TRANS.HospitalNo, COLLECTION_TRANS.DateCreated, payment_details.Amount, payment_details.Payment_Type,payment_details.Cheque_No, payment_details.Cheque_Date, payment_details.Banker, payment_details.Patient_ID, payment_details.Remarks,payment_details.DateCreated AS Expr1 FROM COLLECTION_TRANS CROSS JOIN payment_details";
SqlCollection.SelectCommand="SELECT COLLECTION_TRANS.ReceiptNo, COLLECTION_TRANS.ReceiptDate, COLLECTION_TRANS.DoctorID, COLLECTION_TRANS.Charge,payment_details.Patient_ID, payment_details.Payment_Type, payment_details.Amount, payment_details.Cheque_No, payment_details.Cheque_Date,payment_details.Banker, payment_details.DateCreated, payment_details.Remarks FROM COLLECTION_TRANS INNER JOIN payment_details ON COLLECTION_TRANS.HospitalNo = payment_details.HospitalNo";
}
protected void Update_Record()
{
try
{
string strSQL;
string dbConn = ConfigurationManager.ConnectionStrings["CMC"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(dbConn);
sqlConn.Open();
strSQL = "Update [COLLECTION_TRANS] Set ReceiptDate='" + txtDate.Text + "',TransType='" + ddlTransactionType.SelectedItem.ToString() + "',HospitalNo='" + txtHospitalNo.Text + "' ,Charge='" + txtCharge.Text + "' Where ReceiptNo ='" +txtReceiptNo.Text+ "'";
SqlCommand cmdWardDetails = new SqlCommand(strSQL, sqlConn);
cmdWardDetails.ExecuteNonQuery();
sqlConn.Close();
Response.Write("<script language='javascript'>alert('Data Updated Successfully...');</script>");
Load_Record();
}
catch (Exception)
{
Response.Write("<script language='javascript'>alert('Rate per Bed Value Should be Numeric !!!...');</script>");
}
}
protected bool validate_data()
{
// string strSQL;
// string strName;
// strName = "";
// string dbConn = ConfigurationManager.ConnectionStrings["CMC"].ConnectionString;
// SqlConnection sqlConn = new SqlConnection(dbConn);
// sqlConn.Open();
//// strSQL = "Select ReceiptDate,TransType,DoctorID,HospitalNo,Charge from [COLLECTION_TRANS] Where ReceiptNo='" + txtReceiptNo.Text + "'";
// strSQL = "SELECT COLLECTION_TRANS.ReceiptNo, COLLECTION_TRANS.ReceiptDate, COLLECTION_TRANS.DoctorID, COLLECTION_TRANS.Charge,payment_details.Patient_ID, payment_details.Payment_Type, payment_details.Amount, payment_details.Cheque_No, payment_details.Cheque_Date,payment_details.Banker, payment_details.DateCreated, payment_details.Remarks FROM COLLECTION_TRANS INNER JOIN payment_details ON COLLECTION_TRANS.HospitalNo = payment_details.HospitalNo";
// SqlCommand cmdWardDetails = new SqlCommand(strSQL, sqlConn);
// SqlDataReader drWard = cmdWardDetails.ExecuteReader();
// while (drWard.Read())
// {
// strName = drWard[0].ToString();
// }
// sqlConn.Close();
// if (strName != "")
// {
// Response.Write("<script language='javascript'>alert('This Receipt No Already Exists!!!');</script>");
// return false;
// }
// if (txtDate.Text== "")
// {
// Response.Write("<script language='javascript'>alert('Please Enter Date!!!');</script>");
// return false;
// }
// if (txtHospitalNo.Text == "")
// {
// Response.Write("<script language='javascript'>alert('Please Enter Hospital No!!!');</script>");
// return false;
// }
return true;
}
protected void Display_Record(string strCode)
{
string strSQL;
string dbConn = ConfigurationManager.ConnectionStrings["CMC"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(dbConn);
sqlConn.Open();
// strSQL = "Select ReceiptDate,TransType,DoctorID,HospitalNo,Charge from [COLLECTION_TRANS] where ReceiptNo='" +txtReceiptNo.Text+ "' ";
strSQL = "SELECT COLLECTION_TRANS.ReceiptNo, COLLECTION_TRANS.ReceiptDate, COLLECTION_TRANS.DoctorID, COLLECTION_TRANS.Charge,payment_details.Patient_ID, payment_details.Payment_Type, payment_details.Amount, payment_details.Cheque_No, payment_details.Cheque_Date,payment_details.Banker, payment_details.DateCreated, payment_details.Remarks FROM COLLECTION_TRANS INNER JOIN payment_details ON COLLECTION_TRANS.HospitalNo = payment_details.HospitalNo";
SqlCommand cmdWardDetails = new SqlCommand(strSQL, sqlConn);
SqlDataReader drWardDetails = cmdWardDetails.ExecuteReader();
while (drWardDetails.Read())
{
txtReceiptNo.Text= drWardDetails[0].ToString();
txtDate.Text= drWardDetails[1].ToString();
ddlConsultedDoctor.SelectedItem.Text = drWardDetails[2].ToString();
txtSum.Text = drWardDetails[3].ToString();
ddlPatientName.SelectedItem.Text = drWardDetails[4].ToString();
}
sqlConn.Close();
}
protected void cmdAdd_Click(object sender, EventArgs e)
{
string strAdd;
strAdd = cmdAdd.Text;
if (strAdd == "ADD")
{
ClearFields();
ReceiptNo();
string DocId = DoctorID(ddlConsultedDoctor.SelectedValue);
txtDate.Text = System.DateTime.Now.ToString("dd-MM-yyyy");
cmdAdd.Text = "SAVE";
txtReceiptNo.Enabled = true;
txtDate.Enabled = true;
txtHospitalNo.Enabled = true;
ddlVisitType.Enabled = true;
ddlPatientName.Enabled = true;
ddlTitle.Enabled = true;
ddlTransactionType.Enabled = true;
txtCharge.Enabled = true;
txtSum.Enabled = true;
txtVideNo.Enabled = true;
ddlConsultedDoctor.Enabled = true;
txtDrawnOn.Enabled = true;
txtDated.Enabled = true;
txtRemarks.Enabled = true;
cmdDelete.Enabled = false;
cmdModify.Enabled = false;
}
else if (strAdd == "SAVE")
{
if (txtReceiptNo.Text == "" || txtDate.Text == "" || txtHospitalNo.Text == "" || ddlPatientName.SelectedItem.Text == "" || txtSum.Text == "")
{
Response.Write("<script language='javascript'>alert('(*) fields are Required to Save the Data!!!');</script>");
}
else
{
Save_Record();
}
cmdAdd.Text = "ADD";
ClearFields();
cmdDelete.Enabled = false;
cmdModify.Enabled = false;
txtReceiptNo.Enabled = false;
txtDate.Enabled = false;
txtHospitalNo.Enabled = false;
ddlVisitType.Enabled = false;
ddlPatientName.Enabled = false;
ddlTitle.Enabled = false;
ddlTransactionType.Enabled = false;
txtCharge.Enabled = false;
txtSum.Enabled = false;
txtVideNo.Enabled = false;
ddlConsultedDoctor.Enabled = false;
txtDrawnOn.Enabled = false;
txtDated.Enabled = false;
txtRemarks.Enabled = false;
}
}
protected void cmdModify_Click(object sender, EventArgs e)
{
string strAdd;
strAdd = cmdModify.Text;
if (strAdd == "MODIFY")
{
txtReceiptNo.Enabled = false;
txtDate.Enabled = false;
txtHospitalNo.Enabled = false;
ddlVisitType.Enabled = false;
ddlPatientName.Enabled = false;
ddlTitle.Enabled = false;
ddlTransactionType.Enabled = false;
txtCharge.Enabled = false;
txtSum.Enabled = false;
txtVideNo.Enabled = false;
ddlConsultedDoctor.Enabled = false;
txtDrawnOn.Enabled = false;
txtDated.Enabled = false;
txtRemarks.Enabled = false;
cmdModify.Text = "UPDATE";
cmdDelete.Enabled = false;
cmdAdd.Enabled = false;
}
else if (strAdd == "UPDATE")
{
if (txtReceiptNo.Text == "" || txtDate.Text == "" || txtHospitalNo.Text == "" || ddlPatientName.SelectedItem.Text == "" || txtSum.Text == "")
{
Response.Write("<script language='javascript'>alert('Entry Not Selected for Modification!!!');</script>");
}
else
{
Update_Record();
}
cmdModify.Text = "MODIFY";
ClearFields();
cmdModify.Enabled = false;
cmdDelete.Enabled = false;
cmdAdd.Enabled = true;
txtReceiptNo.Enabled = false;
txtDate.Enabled = false;
txtHospitalNo.Enabled = false;
ddlVisitType.Enabled = false;
ddlPatientName.Enabled = false;
ddlTitle.Enabled = false;
ddlTransactionType.Enabled = false;
txtCharge.Enabled = false;
txtSum.Enabled = false;
txtVideNo.Enabled = false;
ddlConsultedDoctor.Enabled = false;
txtDrawnOn.Enabled = false;
txtDated.Enabled = false;
txtRemarks.Enabled = false;
}
}
protected void cmdDelete_Click(object sender, EventArgs e)
{
if (txtReceiptNo.Text== "")
{
Response.Write("<script language='javascript'>alert('Entry Not Selected for Deletion!!!');</script>");
}
else
{
Delete_Record();
}
}
protected void cmdCancel_Click(object sender, EventArgs e)
{
cmdAdd.Text = "ADD";
cmdModify.Text = "MODIFY";
gvGeneralCollection.Visible = false;
ClearFields();
Grid_clear();
txtReceiptNo.Enabled = false;
txtDate.Enabled = false;
txtHospitalNo.Enabled = false;
ddlVisitType.Enabled = false;
ddlPatientName.Enabled = false;
ddlTitle.Enabled = false;
ddlTransactionType.Enabled = false;
txtCharge.Enabled = false;
txtSum.Enabled = false;
txtVideNo.Enabled = false;
ddlConsultedDoctor.Enabled = false;
txtDrawnOn.Enabled = false;
txtDated.Enabled = false;
txtRemarks.Enabled = false;
cmdAdd.Enabled = true;
cmdModify.Enabled = false;
cmdDelete.Enabled = false;
Grid_clear();
}
protected void Grid_clear()
{
string dbConn = ConfigurationManager.ConnectionStrings["CMC"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(dbConn);
sqlConn.Open();
string strSQL;
strSQL = "Delete from tmpTransList ";
SqlCommand cmdPoOreder = new SqlCommand(strSQL, sqlConn);
cmdPoOreder.ExecuteNonQuery();
sqlConn.Close();
}
protected void BindGrid()
{
string dbConn = ConfigurationManager.ConnectionStrings["CMC"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(dbConn);
sqlConn.Open();
SqlDataAdapter ItemIssueAdapter = new SqlDataAdapter("Select * from tmpTransList", sqlConn);
DataSet datasetItemIssues = new DataSet();
ItemIssueAdapter.Fill(datasetItemIssues);
gvGeneralCollection.DataSource = datasetItemIssues.Tables[0];
gvGeneralCollection.DataBind();
}
protected void gvGeneralCollection_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
try
{
string TransName = gvGeneralCollection.DataKeys[e.RowIndex].Values[0].ToString();
string dbConn = ConfigurationManager.ConnectionStrings["CMC"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(dbConn);
sqlConn.Open();
SqlDataAdapter da = new SqlDataAdapter("", sqlConn);
da.DeleteCommand = new SqlCommand("delete from tmpTransList where TransName='" + TransName + "'", sqlConn);
da.DeleteCommand.ExecuteNonQuery();
BindGrid();
sqlConn.Close();
}
catch (Exception)
{
Response.Write("<script language='javascript'>alert('No Records Found to Delete Item!!!');</script>");
}
}
protected void gvGeneralCollection_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowType == DataControlRowType.EmptyDataRow)
{
grdAmount = 0;
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
decimal TotalAmount = Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Charge"));
grdAmount = grdAmount + TotalAmount;
}
if (e.Row.RowType == DataControlRowType.Footer)
{
Label lb4 = (Label)e.Row.FindControl("lbltotalAmount");
lb4.Text = grdAmount.ToString();
txtSum.Text= grdAmount.ToString();
}
}
catch (Exception)
{
// Response.Write("<script language='javascript'>alert('Data Table is null...');</script>");
}
}
protected void rbCash_CheckedChanged(object sender, EventArgs e)
{
if (rbCash.Checked == true)
{
PaymentType= "Cash";
}
}
protected void rbCheque_CheckedChanged(object sender, EventArgs e)
{
PaymentType = "Cheque";
}
protected void rbDD_CheckedChanged(object sender, EventArgs e)
{
PaymentType = "DD";
}
protected void rbCreditCard_CheckedChanged(object sender, EventArgs e)
{
PaymentType = "Credit Card";
}
protected void rbDebitCard_CheckedChanged(object sender, EventArgs e)
{
PaymentType = "Debit Card";
}
protected void rbAmountCollectLater_CheckedChanged(object sender, EventArgs e)
{
PaymentType = "Amount Collect Later";
}
protected void ddlTitle_SelectedIndexChanged(object sender, EventArgs e)
{
//ddlPatientName.Items.Clear();
//string strSQL;
//string dbConn = ConfigurationManager.ConnectionStrings["CMC"].ConnectionString;
//SqlConnection sqlConn = new SqlConnection(dbConn);
//sqlConn.Open();
//strSQL = "select Patient_Name from registration_details where Title='"+ddlTitle.SelectedItem.ToString()+"'";
//SqlCommand cmdPatientName = new SqlCommand(strSQL, sqlConn);
//ddlPatientName.Items.Add("<============Select==========>");
//SqlDataReader drPatientName = cmdPatientName.ExecuteReader();
//while (drPatientName.Read())
//{
// ddlPatientName.Items.Add(drPatientName[0].ToString());
//}
//sqlConn.Close();
}
protected void gvCollection_DataBound(object sender, EventArgs e)
{
lblPage.Text = string.Format("You are viewing page {0} of {1}", gvCollection.PageIndex + 1, gvCollection.PageCount);
ddlPageList.Items.Clear();
for (int i = 0; i < gvCollection.PageCount; i++)
{
ListItem pageListItem = new ListItem(string.Concat(i + 1), i.ToString());
ddlPageList.Items.Add(pageListItem);
if (gvCollection.Rows.Count > 0)
{
lblSearchRecords.Text = "Results found " + gvCollection.Rows.Count.ToString() + "Records";
}
if (i == gvCollection.PageIndex)
{
pageListItem.Selected = true;
}
}
}
public string HighlightText(string InputTxt)
{
string Search_Str = TxtSearch.Text;
Regex RegExp = new Regex(Search_Str.Replace(" ", "|").Trim(), RegexOptions.IgnoreCase);
return RegExp.Replace(InputTxt, new MatchEvaluator(ReplaceKeyWords));
}
public static string ReplaceKeyWords(Match m)
{
return ("<span class=highlight>" + m.Value + "</span>");
}
protected void gvCollection_PreRender(object sender, EventArgs e)
{
GridView gv = (GridView)sender;
GridViewRow gvr = (GridViewRow)gv.TopPagerRow;
if (gvr != null)
{
gvr.Visible = true;
}
}
protected void gvCollection_RowCommand(object sender, GridViewCommandEventArgs e)
{
}
protected void gvCollection_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void CmdSearch_Click(object sender, EventArgs e)
{
SearchString = TxtSearch.Text;
lblSearchRecords.Visible = true;
if (TxtSearch.Text == "")
{
lblSearchRecords.Text = "Enter Keyword to search by ";
lblSearchRecords.Visible = true;
}
else
{
lblSearchRecords.Text = "Results found " + gvCollection.Rows.Count.ToString() + "Records";
lblSearchRecords.Visible = true;
}
}
protected void CmdClear_Click(object sender, EventArgs e)
{
lblSearchRecords.Visible = false;
TxtSearch.Text = "";
SearchString = "";
gvCollection.DataBind();
}
protected void ddlPageList_SelectedIndexChanged(object sender, EventArgs e)
{
gvCollection.PageIndex = Convert.ToInt32(ddlPageList.SelectedValue);
}
Now i want to select Sex and Payment Type Radio button Based on gridview selected row.
Anyone help me please...........Its urgent..
Thanks in advance..................
Reply
Answers (
0
)
add column in database using C# code
how to include the calendar image in toolbox in vb.net