问题描述
DROP PROCEDURE IF EXISTS hms.Select_Parameter1;
CREATE PROCEDURE hms.`Select_Parameter1`(_Branch_Id int,
_Tenant_Id int,
_disease_Id int,_Patient_Id int)
BEGIN
IF EXISTS
(SELECT b.Target_Value
FROM patient_progress_tracking_header b
WHERE b.DiseaseId = _disease_Id)
THEN
SELECT a.ParameterName,
a.Target_Value,
b.Measurement_Frequency,
date_format(c.Last_Date,"%y/%d/%m") as 'Last_Date',
c.Result,
date_format(c.Next_Due_Date,"%y/%d/%m") as 'Next_Due_Date',
date_format(c.Current_Test_Date,"%y/%d/%m") as 'Current_Test_Date',
c.Test_Result,
a.ParameterId
FROM patient_progress_tracking_header b
RIGHT JOIN Disease_parameter a
ON b.DiseaseId=a.DiseaseId
INNER JOIN patient_progress_tracking_details c
ON b.DiseaseId = c.DiseaseId
WHERE a.Branch_Id = _Branch_Id
AND a.Tenant_Id = _Tenant_Id
AND a.DiseaseId = _disease_Id
AND a.Patient_Id=_Patient_Id;
ELSE
Insert Into patient_progress_tracking_header(Branch_Id,Tenant_Id,Patient_Id,DiseaseId)values(_Branch_Id,_Tenant_Id,_Patient_Id,_disease_Id);
Insert Into patient_progress_tracking_details(DiseaseId,Patient_Id,Branch_Id,Tenant_Id)values(_disease_Id,_Patient_Id,_Branch_Id,_Tenant_Id);
SELECT a.ParameterName,
a.Target_Value,
b.Measurement_Frequency,
date_format(c.Last_Date,"%y/%d/%m") as 'Last_Date',
c.Result,
date_format(c.Next_Due_Date,"%y/%d/%m") as 'Next_Due_Date',
date_format(c.Current_Test_Date,"%y/%d/%m") as 'Current_Test_Date',
c.Test_Result,
a.ParameterId
FROM patient_progress_tracking_header b
RIGHT JOIN Disease_parameter a
ON b.DiseaseId =a.DiseaseId
INNER JOIN patient_progress_tracking_details c
ON b.DiseaseId = c.DiseaseId
WHERE a.Branch_Id = _Branch_Id
AND a.Tenant_Id = _Tenant_Id
AND a.DiseaseId = _disease_Id
AND a.Patient_Id=_Patient_Id;
END IF;
END;
CS file ....
protected void BindCarePlan()
{
MySqlConnection strConnection = null;
MySqlCommand strCommand = null;
try
{
strConnection = new MySqlConnection();
strConnection.ConnectionString = StrConn;
strConnection.Open();
strCommand = new MySqlCommand();
strCommand.CommandType = CommandType.StoredProcedure;
strCommand.CommandText = "Select_Parameter1";
strCommand.Connection = strConnection;
strCommand.Parameters.AddWithValue("_Tenant_Id", 1);
strCommand.Parameters.AddWithValue("_Branch_Id", 1);
strCommand.Parameters.AddWithValue("_Patient_Id", 1);
strCommand.Parameters.AddWithValue("_disease_Id", ddlselectdisease.SelectedValue);
// strCommand.Parameters.AddWithValue("_ParameterId", 1);
MySqlDataAdapter da = new MySqlDataAdapter(strCommand);
DataSet ds = new DataSet();
da.Fill(ds);
grdcareplan.DataSource = ds;
grdcareplan.DataBind();
}
catch (Exception ex)
{
obj.InfoEntry(DateTime.Now + " " + " BindCarePlan" + " " + "HomeHealthCare.aspx" + " " + ex.Message, "");
obj.InfoEntry(DateTime.Now + " " + ex.StackTrace, "");
Session["strerrormsg"] = DateTime.Now + " " + " BindCarePlan" + " " + "HomeHealthCare.aspx" + " " + ex.Message;
Session["strerrortrace"] = DateTime.Now + " " + ex.StackTrace;
Response.Redirect("ErrorPage.aspx");
}
finally
{
strCommand.Dispose();
strConnection.Close();
}
}
ASPX file
<table style="width:954px; margin-removed20px">
<tr>
<td class="leftimgboxtd">
<asp:Image ID="Image3" CssClass="leftimgboxstyle" ImageUrl="~/images/left_1.jpg"
runat="server" />
</td>
<td class="midimgboxstyle">
<table>
<tr >
<td class="popuplbltdwithpadding">
<asp:Label ID="lblPatientname" runat="server" CssClass="style2" Text="Patient Name:"></asp:Label>
</td>
<td class="popuplbltdwithpadding">
<asp:Label ID="lblname" runat="server" CssClass="LblDetailstyle" Text="Label"></asp:Label>
</td>
<td class="popuplbltdwithpadding" style="padding-removed100px">
<asp:Label ID="lblpatientregno" runat="server" CssClass="style2" Text="Reg No."></asp:Label>
</td>
<td class="popuplbltdwithpadding">
<asp:Label ID="lblregno" runat="server" CssClass="LblDetailstyle" Text="Label"></asp:Label>
</td>
<td class="popuplbltdwithpadding" style="padding-removed50px">
<asp:Label ID="Label1" runat="server" Text="Chief Complaint" CssClass="style2"></asp:Label>
</td>
<td style="vertical-align:bottom;padding-removed50px" >
<asp:DropDownList
ID="ddlselectdisease" runat="server" Height="25px" Width="209px"
CssClass="DropDownCSS" AutoPostBack="True"
onselectedindexchanged="ddlselectdisease_SelectedIndexChanged"
DataTextField="DiseaseName" DataValueField="DiseaseId" >
<asp:ListItem></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
</td>
<td class="rightimgboxtd">
<asp:Image ID="Image4" CssClass="rightimgboxstyle" ImageUrl="~/images/right_1.jpg"
runat="server" />
</td>
</tr>
</table>
</td>
</tr>
</table>
<table class="allmasterpagewidth">
<tr>
<td style="height: 386px; width: 950px;" align="center"
valign="top" width="640px">
<asp:GridView ID="grdcareplan" runat="server" CellPadding="5" CssClass="CustomGrid" ShowFooter="True"
AutoGenerateColumns="False" GridLines="Horizontal" AllowPaging="True" DataKeyNames="ParameterId"
Width="950px" onselectedindexchanged="grdcareplan_SelectedIndexChanged1"
onpageindexchanging="grdcareplan_PageIndexChanging" Height="16px"
style="margin-right: 0px" onrowediting="grdcareplan_RowEditing" onrowcancelingedit="grdcareplan_RowCancelingEdit"
onrowupdating="grdcareplan_RowUpdating"
onrowdeleting="grdcareplan_RowDeleting"
EmptyDataText="No Record found for this Item">
<Columns>
<asp:CommandField EditText="<img src='~/images/HMS Buttons/edit_icon.png'/>" ShowEditButton="true" UpdateText="<img src='~/images/HMS Buttons/Upload.png'/>"/>
<asp:TemplateField>
<ItemStyle CssClass="w" />
<ItemTemplate>
<asp:ImageButton ID="Imgbtnsave" runat="server"
ImageUrl="~/images/HMS Buttons/LaunchIcon.png" CssClass="icon"
onclick="Imgbtnsave_Click"/>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ParameterName" HeaderText="Scheduled Items"
ReadOnly="True" />
<asp:TemplateField HeaderText="Target Value">
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("Target_Value") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txttargetvalue" runat="server"
Text='<%# Bind("Target_Value") %>' CssClass="textboxInGrid"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<%--<asp:BoundField DataField="UOM" HeaderText="UOM" ReadOnly="True" />--%>
<asp:TemplateField HeaderText="Last dt">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Last_Date") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("Last_Date") %>'></asp:Label>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Result">
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("Result") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="Label7" runat="server" Text='<%# Bind("Result") %>'></asp:Label>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Test dt">
<ItemTemplate>
<asp:Label ID="Label9" runat="server" Text='<%# Bind("Current_Test_Date") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txttestdate" runat="server" Text='<%# Bind("Current_Test_Date") %>' CssClass="textboxInGrid"></asp:TextBox>
<asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txttestdate" Format="yy/dd/MM">
</asp:CalendarExtender>
</EditItemTemplate>
</asp:TemplateField>
<%-- <asp:BoundField HeaderText="Test Result" />--%>
<asp:TemplateField HeaderText="Test Result">
<ItemTemplate>
<asp:Label ID="Label8" runat="server" Text='<%# Bind("Test_Result") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txttestresult" runat="server" Text='<%# Bind("Test_Result") %>' CssClass="textboxInGrid"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Measurement Frequency">
<ItemTemplate>
<asp:Label ID="Label2" runat="server"
Text='<%# Bind("Measurement_Frequency") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlMeasurementFrequency" runat="server" AutoPostBack="true"
onselectedindexchanged="ddlMeasurementFrequency_SelectedIndexChanged">
<asp:ListItem>Select Frequency</asp:ListItem>
<asp:ListItem Value="1">Daily</asp:ListItem>
<asp:ListItem Value="2">Weekly</asp:ListItem>
<asp:ListItem Value="3">Fortnightly</asp:ListItem>
<asp:ListItem Value="4">Monthly</asp:ListItem>
<asp:ListItem Value="5">Quarterly</asp:ListItem>
<asp:ListItem Value="6"> Half Yearly</asp:ListItem>
<asp:ListItem Value="7">Yearly</asp:ListItem>
<asp:ListItem Value="8">Others</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Next Due dt">
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("Next_Due_Date") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtnextduedate" runat="server" Text='<%# Bind("Next_Due_Date") %>' CssClass="textboxInGrid"></asp:TextBox>
<asp:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="txtnextduedate" Format="yy/dd/MM">
</asp:CalendarExtender>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle CssClass="GridFooter" />
<HeaderStyle CssClass="grdheaderstyle"></HeaderStyle>
<RowStyle CssClass="grdrowstyle" />
</asp:GridView>
</td>
In else Part when I am Inserting Value and after that I am selecting ,Two values Of diseaseId get Inserted Into both table that is 0 and 1 for only one ParameterName,...
I want to Insert Only one record for one parameterName..what Should I do?and Also i want the target value get inserted into patient_progress_tracking_header table in else part..what should i do..
In else Part when I am Inserting Value and after that I am selecting ,Two values Of diseaseId get Inserted Into both table that is 0 and 1 for only one ParameterName,...
I want to Insert Only one record for one parameterName..what Should I do?and Also i want the target value get inserted into patient_progress_tracking_header table in else part..what should i do..
推荐答案
这篇关于在else Part中插入值并选择值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!