Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MrCupcake's Changes When Adding New Doctor #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions Code/DBProject/Admin/DoctorRegistrationForm.aspx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,20 @@ protected void DoctorRegister(object sender, EventArgs e)
int dept = Convert.ToInt32(Department.SelectedValue);
string gender = Request.Form["Gender"].ToString();

objmyDAL.AddDoctor(Name.Text, Email.Text, Password.Text, BirthDate.Text, dept, Phone.Text, gender[0], Address.Text, exp, salary, chargesPerVisit, spec.Text, Qualification.Text);
int result;
result = objmyDAL.AddDoctor(Name.Text, Email.Text, Password.Text, BirthDate.Text, dept, Phone.Text, gender[0], Address.Text, exp, salary, chargesPerVisit, spec.Text, Qualification.Text);
Response.BufferOutput = true;
Msg.Visible = true;
Msg.Text = "doctor Added Succesfully";
if (result == 0)
{
Msg.ForeColor = System.Drawing.Color.Red;
Msg.Text = "doctor not Inserted";
}
else
{
Msg.ForeColor = System.Drawing.Color.Green;
Msg.Text = "doctor Added Succesfully";
}
flushInformation();


Expand Down
30 changes: 25 additions & 5 deletions Code/DBProject/DAL/myDAL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,23 @@ @status OUTPUT
SqlCommand cmd = new SqlCommand("CheckDoctorEmail", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@Email", SqlDbType.VarChar, 30).Value = Email;
cmd.Parameters.Add("@status", SqlDbType.Int).Direction = ParameterDirection.Output;
//cmd.Parameters.Add("@status", SqlDbType.Int).Direction = ParameterDirection.Output;
cmd.Parameters.Add("@status", SqlDbType.Int).Value = 0;

cmd.ExecuteNonQuery();

status = (int)cmd.Parameters["@status"].Value;

int psk = 0;
try
{
psk = cmd.ExecuteNonQuery();
}
catch(SqlException ex)
{

}

//status = (int)cmd.Parameters["@status"].Value;
status = psk;
con.Close();

return status;
Expand All @@ -195,7 +207,7 @@ @status OUTPUT


/*THIS FUNCTION WILL ADD THE DOCTOR TO THE DATA BASE */
public void AddDoctor(string Name, string Email, string Password, string BirthDate, int dept, string Phone, char gender, string Address, int exp, int salary, int Charges_per_visit, string spec, string qual)
public int AddDoctor(string Name, string Email, string Password, string BirthDate, int dept, string Phone, char gender, string Address, int exp, int salary, int Charges_per_visit, string spec, string qual)
{

SqlConnection con = new SqlConnection(connString);
Expand Down Expand Up @@ -235,7 +247,15 @@ public void AddDoctor(string Name, string Email, string Password, string BirthDa
cmd.Parameters.Add("@spec", SqlDbType.VarChar, 30).Value = spec;
cmd.Parameters.Add("@qual", SqlDbType.VarChar, 30).Value = qual;

cmd.ExecuteNonQuery();
try
{
cmd.ExecuteNonQuery();
return 1;
}
catch(Exception ex)
{
return 0;
}
con.Close();


Expand Down
19 changes: 12 additions & 7 deletions Database Files/Admin.sql
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,29 @@ select * from OtherStaff
GO
CREATE procedure CheckDoctorEmail
@Email varchar(30),
@status int output
@status int
AS
BEGIN
SET @status = 0

IF EXISTS( select * from LoginTable where Email = @Email )
BEGIN

SET @status = 1

SET @status = 1
END

ELSE
BEGIN
SET @status = 0
END

END

SELECT @status

--EXECUTION---
DECLARE @r int
EXEC CheckDoctorEmail '[email protected]' , @r output
select @r
--DECLARE @r int
--EXEC CheckDoctorEmail '[email protected]' , @r output
--select @r



Expand Down