类型'doctorsignup'已经定义了一个名为'Page_Load'的成员,它具有相同的参数类型 [英] Type 'doctorsignup' already defines a member called 'Page_Load' with the same parameter types

查看:81
本文介绍了类型'doctorsignup'已经定义了一个名为'Page_Load'的成员,它具有相同的参数类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

protected void Page_Load(object sender, EventArgs e)
   {

      optxt.Text = dt;
   }





我正在尝试编译这个医院管理软件,我坚持跟随错误。我谷歌很多,但解决方案对我不起作用。任何帮助将不胜感激。




outpatient.aspx.cs上的
错误和代码是





I am trying to compile this hospital management software and i stuck at following error. I google a lot but the solution does not work for me. Any help Will BE appreciated.


error at outpatient.aspx.cs and code is

public partial class doctorsignup: System.Web.UI.Page
{
    //SqlConnection cn = new SqlConnection("server=IPOG-A95E1056D3;user id=sa;password=sqlserver;database=Hospitalmanagement");
    string dt = DateTime.Now.ToShortDateString();
    protected void Page_Load(object sender, EventArgs e)
    {

       optxt.Text = dt;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        cn.Open();
        SqlCommand cmd = new SqlCommand();
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "sp_hospital_outpatient";
        cmd.Connection = cn;

        SqlParameter p = new SqlParameter("@patientname",SqlDbType.VarChar,20);
        p.Value = pntxt.Text;
        cmd.Parameters.Add(p);

        SqlParameter p1 = new SqlParameter("@gender", SqlDbType.VarChar, 20);
        p1.Value = gddl.Text;
        cmd.Parameters.Add(p1);

        SqlParameter p2 = new SqlParameter("@age", SqlDbType.Int);
        p2.Value = agetxt.Text;
        cmd.Parameters.Add(p2);

        SqlParameter p3 = new SqlParameter("@address", SqlDbType.VarChar, 20);
        p3.Value = addtxt.Text;
        cmd.Parameters.Add(p3);

        SqlParameter p4 = new SqlParameter("@assigndoctor", SqlDbType.VarChar, 20);
        p4.Value = doctorddl.Text;
        cmd.Parameters.Add(p4);

        SqlParameter p5 = new SqlParameter("@phoneres", SqlDbType.BigInt);
        p5.Value = restxt.Text;
        cmd.Parameters.Add(p5);

        SqlParameter p6 = new SqlParameter("@phonemob", SqlDbType.BigInt);
        p6.Value = mobtxt.Text;
        cmd.Parameters.Add(p6);

        SqlParameter p7 = new SqlParameter("@opdate", SqlDbType.DateTime);
        p7.Value = optxt.Text;
        cmd.Parameters.Add(p7);

        SqlParameter p8 = new SqlParameter("@department", SqlDbType.VarChar,20);
        p8.Value = depddl.Text;
        cmd.Parameters.Add(p8);

        cmd.ExecuteNonQuery();
        cn.Close();

        Response.Redirect("outpatient.aspx");
    }
    protected void doctorddl_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
}









在doctorsignup.aspx.cs的代码





Code at doctorsignup.aspx.cs

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class doctorlogin : System.Web.UI.Page
{
    SqlConnection cn = new SqlConnection("server=IPOG-A95E1056D3;user id=sa;password=sqlserver;database=Hospitalmanagement");
    SqlDataReader dr;
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        cn.Open();
        string qry;
        qry = "select * from hospital_doctorsignup where loginid='"+lidtxt.Text+"' and password='"+pwdtxt.Text+"'";
        SqlCommand cmd = new SqlCommand(qry, cn);
        dr = cmd.ExecuteReader();
        if (dr.Read())
        {
            Response.Redirect("doctorsden.aspx");
        }
        else
        {
            pwdlb.Text = "Enter valid UserName/Password";
        }
    }
}







错误是






And the Error is

Error	1	Type 'doctorsignup' already defines a member called 'Page_Load' with the same parameter types 







有些谷歌说它是由主页面代码所以我的主页面代码是






Some google say it cause by main page code so my main page code is

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class home : System.Web.UI.Page
{
   protected void Page_Load(object sender, EventArgs e)
    {

    }
}

推荐答案

为什么你的类名不匹配页面名?无论如何,部分类是将多个物理文件粘贴在一起时。更改是您多次定义您的physicianignup类,并且这些文件中有多个具有Page_Load的定义。在整个代码中搜索class doctorsignup以查找定义的所有位置,并查看是否有多次Page_Load定义。删除其他Page_Load方法,使其仅定义一次。
Why don't your class names match the page names? Regardless, partial classes are when you paste multiple physical files together. Changes are you are defining your doctorsignup class multiple times and more than one of those files has a definition for Page_Load. Search your entire code for "class doctorsignup" to find everywhere it is defined, and see if you have Page_Load defined more than once. Remove additional Page_Load methods so that it is only defined once.


outpatient.aspx.cs 中定义的类名是 doctorsignup

doctorsignup.aspx.cs 中定义的类名是 doctorsignup



您有两个文件定义同一类的部分。这两个文件都有 Page_Load 方法。



更改的类名outpatient.aspx .cs 以不同的方式。我会建议门诊,除非它与你项目中的另一个类冲突。
The class name defined in outpatient.aspx.cs is doctorsignup.
The class name defined in doctorsignup.aspx.cs is doctorsignup.

You have two files defining parts of the same class. Both files have a Page_Load method.

Change the class name for outpatient.aspx.cs to something different. I would suggest outpatient, unless that conflicts with another class in your project.


doctorsignup.aspx.cs的附加代码





Additional code for doctorsignup.aspx.cs


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class doctorsignup: System.Web.UI.Page
{
    SqlConnection cn = new SqlConnection("server=IPOG-A95E1056D3;user id=sa;password=sqlserver;database=Hospitalmanagement");
  protected void Page_Load(object sender, EventArgs e)
    {
         
    } 
    protected void subbtn_Click(object sender, EventArgs e)
    {
        cn.Open();
        SqlCommand cmd = new SqlCommand();
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "sp_hospital_doctorsignup";
        cmd.Connection = cn;


        SqlParameter p = new SqlParameter("@name",SqlDbType.VarChar,20);
        p.Value = nametxt.Text;
        cmd.Parameters.Add(p);

        SqlParameter p1 = new SqlParameter("@loginid",SqlDbType.VarChar,20);
        p1.Value = lidtxt.Text;
        cmd.Parameters.Add(p1);

        SqlParameter p2 = new SqlParameter("@password",SqlDbType.VarChar,20);
        p2.Value = pwdtxt.Text;
        cmd.Parameters.Add(p2);

        SqlParameter p3 = new SqlParameter("@department",SqlDbType.VarChar,20);
        p3.Value = depddl.Text;
        cmd.Parameters.Add(p3);

        SqlParameter p4 = new SqlParameter("@specialization",SqlDbType.VarChar,20);
        p4.Value = speddl.Text;
        cmd.Parameters.Add(p4);

        SqlParameter p5 = new SqlParameter("@phonenumber",SqlDbType.BigInt);
        p5.Value = phtxt.Text;
        cmd.Parameters.Add(p5);

        SqlParameter p6 = new SqlParameter("@address",SqlDbType.VarChar,20);
        p6.Value = addtxt.Text;
        cmd.Parameters.Add(p6);

        SqlParameter p7 = new SqlParameter("@email",SqlDbType.VarChar,20);
        p7.Value = emtxt.Text;
        cmd.Parameters.Add(p7);

        cmd.ExecuteNonQuery();
        cn.Close();
        Response.Redirect("doctorlogin.aspx");

    }
    protected void Resbtn_Click(object sender, EventArgs e)
    {
        Response.Redirect("doctorsignup.aspx");
    }
    protected void canbtn_Click(object sender, EventArgs e)
    {
        Response.Redirect("doctorlogin.aspx");
    }
}


这篇关于类型'doctorsignup'已经定义了一个名为'Page_Load'的成员,它具有相同的参数类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆