naga jyothi

naga jyothi

  • NA
  • 62
  • 110.7k

In asp.net i have enter the data in first page after to navigate second page then back to first page in that page previous entered data is clear

Nov 10 2012 8:24 AM
// add medical details
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");
    }
}

//Medicak search wizard



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 MedicinesSearchWizard : System.Web.UI.Page
{
    CDatabase cd = new CDatabase();
    MySqlConnection con;
 
    protected void Page_Load(object sender, EventArgs e)
    {
        Loadgridview();
    }
    protected void txtSearchFor_TextChanged(object sender, EventArgs e)
    {
        try
        {

            if (ddlCriteria.Text == "Medicine ID")
            {
                string str = "select * from medicinemaintainance where medicineid='" + txtSearchFor.Text + "'";
                DataTable dt = cd.executeSelectQueryNonParameter(str);
                gdvMedicinesSearchWizard.DataSource = dt;
                gdvMedicinesSearchWizard.DataBind();
            }
            else if (ddlCriteria.Text == "Medicine Name")
            {

                string str = "select * from medicinemaintainance where medicinename='" + txtSearchFor.Text + "'";
                DataTable dt = cd.executeSelectQueryNonParameter(str);
                gdvMedicinesSearchWizard.DataSource = dt;
                gdvMedicinesSearchWizard.DataBind();
            }
            else if (ddlCriteria.Text == "Dosage From")
            {
                string str = "select * from medicinemaintainance where dosageform='" + txtSearchFor.Text + "'";
                DataTable dt = cd.executeSelectQueryNonParameter(str);
                gdvMedicinesSearchWizard.DataSource = dt;
                gdvMedicinesSearchWizard.DataBind();
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language=\"javaScript\">" + ex.Message + "<" + "/script>");
        }
    }
    public void Loadgridview()
    {
        try
        {

            MySqlCommand cmd = new MySqlCommand();
            MySqlDataAdapter dataAdapterAccount = new MySqlDataAdapter("SELECT medicineid,medicinename,dosageform,unitprice,unitinstock,reorderlevel,additionalnotes from medicinemaintainance", con);
            DataSet datasetAccount = new DataSet();
            DataTable TablAccount = datasetAccount.Tables["medicinemaintainance"];
            dataAdapterAccount.Fill(datasetAccount);
            gdvMedicinesSearchWizard.DataSource = datasetAccount;
            gdvMedicinesSearchWizard.DataBind();
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language=\"javaScript\">" + ex.Message + "<" + "/script>");
        }

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

    }
}