naga jyothi

naga jyothi

  • NA
  • 62
  • 110.7k

please rectify my problem i have to create two navigation buttons in frmAdd medical treatment detai...

Nov 10 2012 6:26 AM
//frmAddMedicalTreatments.aspx
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 MySql.Data.MySqlClient;

public partial class frmAddMedicalTreatments : System.Web.UI.Page
{
    CDatabase con = new CDatabase();
    protected void Page_Load(object sender, EventArgs e)
    {
        LoadGrid();
        if (!Page.IsPostBack)
        {
            Apply();
            EditMedicalDetails();
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string getMedicaldetails = "select * from medicaltreatmentdetails where InpatientId='" + txtPatientId.Text + "'";
        MySqlDataReader dr = con.SqlReaderQuery(getMedicaldetails);
        if (dr.Read())
        {
            string updatemedicaldetails = "update  medicaltreatmentdetails set MedicineId='" + txtMedicineId.Text + "',quantity='" + txtQuantity.Text + "',total='" + txtTotal.Text + "' where Inpatientid='" + txtPatientId.Text + "' ";
            if (CDatabase.ExecuteSQL(updatemedicaldetails))
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language=\"javaScript\">" + "alert('Record Successfully Update');" + "<" + "/script>");

            }


        }
        else
        {
            string getdepartmentdetails = "insert into medicaltreatmentdetails(Inpatient,MedicineId,quantity,total)values('"+txtPatientId.Text +"','" + txtMedicineId.Text  + "','" + txtQuantity.Text  + "','" + txtTotal.Text  + "')";
            if (CDatabase.ExecuteSQL(getdepartmentdetails))
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language=\"javaScript\">" + "alert('Record Successfully Update');" + "<" + "/script>");

            }

        }
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        dgvMedicalDetails.PageIndex = e.NewPageIndex; 
    }
    private void LoadGrid()
    {
        string str = "select * from medicaltreatmentdetails";
        DataTable departmenttable = con.executeSelectQueryNonParameter(str);
        dgvMedicalDetails.DataSource = departmenttable;
        dgvMedicalDetails.DataBind();


    }
    public void Apply()
    {
        string inpatientid = Request.QueryString["inpatientid"];
        string inpatientfirdtname = Request.QueryString["inpatientfirstname"];
        string inpatientdecondname = Request.QueryString["inpatientsurname"];

        txtPatientId.Text = inpatientid;
        txtFirstName.Text = inpatientfirdtname;
        txtSurname.Text = inpatientdecondname;
    }
    public void EditMedicalDetails()
    {
        string MID = Request.QueryString["medicineid"];
        string MName = Request.QueryString["medicinename"];
        string UPrice = Request.QueryString["unitprice"];

        txtMedicineId.Text = MID;
        txtMedicinename.Text = MName;
        txtUnitPrice.Text = UPrice;
        //txtDateofissue.Text  = DateTime.Now.Date;

    }
    protected void btnInpatientsearchwizard_Click(object sender, EventArgs e)
    {
        Response.Redirect("frmInpatientSearchWizard.aspx");
    }
    protected void btnMedicinesSearchwizard_Click(object sender, EventArgs e)
    {
        Response.Redirect("MedicinesSearchWizard.aspx");
    }
}




// frmInpatientSearchWizard.aspx

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;
using MySql.Data.MySqlClient;

public partial class frmInpatientSearchWizard : System.Web.UI.Page
{
    CDatabase cd = new CDatabase();
    MySqlConnection con;
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void txtSearchFor_TextChanged(object sender, EventArgs e)
    {
        try
        {

            if (ddlCriteria.Text == "Patient ID")
            {
                string str = "select * from inpatientmaintenance where inpatientid='" + txtSearchFor.Text + "'";
                DataTable dt = cd.executeSelectQueryNonParameter(str);
                gdvInpatientSearchWizard.DataSource = dt;
                gdvInpatientSearchWizard.DataBind();
            }
            else if (ddlCriteria.Text == "First Name")
            {

                string str = "select * from inpatientmaintenance where inpatientfirstname='" + txtSearchFor.Text + "'";
                DataTable dt = cd.executeSelectQueryNonParameter(str);
                gdvInpatientSearchWizard.DataSource = dt;
                gdvInpatientSearchWizard.DataBind();
            }
            else if (ddlCriteria.Text == "Surname")
            {
                string str = "select * from inpatientmaintenance where inpatientsurname='" + txtSearchFor.Text + "'";
                DataTable dt = cd.executeSelectQueryNonParameter(str);
                gdvInpatientSearchWizard.DataSource = dt;
                gdvInpatientSearchWizard.DataBind();
            }
            else if (ddlCriteria.Text == "Account Type")
            {
                string str = "select * from inpatientmaintenance where Inpatientaccounttype='" + txtSearchFor.Text + "'";
                DataTable dt = cd.executeSelectQueryNonParameter(str);
                gdvInpatientSearchWizard.DataSource = dt;
                gdvInpatientSearchWizard.DataBind();
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language=\"javaScript\">" + ex.Message + "<" + "/script>");
        }

    }
    protected void btnApply_Click(object sender, EventArgs e)
    {

    }
    protected void gdvInpatientSearchWizard_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
}


Answers (1)