Doctor.CS
INSERT 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 AMS.BO;
using AMS.BLL;
public partial class adddoctor : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
GetSpecilizations();
}
}
private void GetSpecilizations()
{
DoctorsBLL objCPBLL = new DoctorsBLL();
DataSet ds = objCPBLL.GetSpecilizations();
ddlSpecializationId.DataSource = ds;
ddlSpecializationId.DataBind();
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
DoctorsBLL objCPBLL = new DoctorsBLL();
UsersBLL objUserBLL = new UsersBLL();
DoctorsBO objDoctorBO = new DoctorsBO();
UsersBO objUserBO = new UsersBO();
int doctorid = -1;
int userid = AddUser();
if (userid != 0)
{
doctorid = AddDoctor(userid);
}
if (doctorid == -1)
{
objUserBO.Type = "Delete";
objUserBLL.UsersOperations(objUserBO);
string alert = ">script language=javascript>alert('Error Occured Doctor Details..');>/script>";
Page.ClientScript.RegisterStartupScript(typeof(Page), "Alert", alert);
}
else
{
string alert = ">script language=javascript>alert('Doctor Successfully Inserted');>/script>";
Response.Write(alert);
//Page.ClientScript.RegisterStartupScript(typeof(Page), "Alert", alert);
Response.Redirect("/AMSWeb/doctors.aspx");
}
}
private int AddUser()
{
UsersBLL objBLL = new UsersBLL();
UsersBO objBO = new UsersBO();
objBO.UserName = txtUserName.Text;
objBO.Password = txtPassword.Text;
objBO.Role = 1;
objBO.Email = txtEmail.Text;
if (chkStatus.Checked)
{
objBO.Status = 1;
}
else
{
objBO.Status = 0;
}
objBO.EnteredDate = Convert.ToString(DateTime.Now);
objBO.Type = "Insert";
objBO = objBLL.UsersOperations(objBO);
if (objBO.NewUserId != 0)
{
return objBO.NewUserId;
}
else
return 0;
}
private int AddDoctor(int userid)
{
DoctorsBLL objBLL = new DoctorsBLL();
DoctorsBO objBO = new DoctorsBO();
objBO.UserId = userid;
objBO.FirstName = txtFirstName.Text;
objBO.LastName = txtLastName.Text;
objBO.MiddleName = txtMiddleName.Text;
objBO.SSN = txtSSN.Text;
objBO.DOB = txtDOB.Text;
objBO.Gender = rdolstGender.SelectedItem.Text;
objBO.Age = Convert.ToInt32(txtAge.Text);
objBO.Address = txtAddress.Text;
objBO.City = txtCity.Text;
objBO.State = txtState.Text;
objBO.ZipCode = txtZipCode.Text;
objBO.Email = txtEmail.Text;
objBO.HomePhone = txtHomePhone.Text;
objBO.WorkPhone = txtWorkPhone.Text;
objBO.Mobile = txtMobile.Text;
objBO.Fax = txtFax.Text;
objBO.SpecilizationId = Convert.ToInt32(ddlSpecializationId.SelectedItem.Value);
objBO.RegistrationNumber = txtRegistrationNo.Text;
objBO.LicenceNumber = txtLicenceNo.Text;
objBO.Type = "Insert";
objBO = objBLL.DoctorOperations(objBO);
if (objBO.DoctorId == 1)
return 1;
else
return -1;
}
}
UPDATEusing 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 AMS.BO;
using AMS.BLL;
public partial class ClaimantAdministrator : System.Web.UI.Page
{
int ClaimantAdminID
{
get
{
int claimantAdminID = 0;
if (Request.QueryString["cid"] != null && Request.QueryString["cid"].Length > 0)
{
claimantAdminID = Convert.ToInt32(Request.QueryString["cid"]);
Session["claimantID"] = claimantAdminID;
}
else if (Session["claimantID"] != null)
claimantAdminID = Convert.ToInt32(Session["cid"]);
return claimantAdminID;
}
}
protected void Page_Load(object sender, EventArgs e)
{
btnSubmit.Attributes.Add("onclick", "return validate();");
if (!Page.IsPostBack)
{
GetUSStates();
if (ClaimantAdminID != 0)
DisplayCalimantAdministrator();
}
}
private void DisplayCalimantAdministrator()
{
ClaimantAdminInformationBLL objCABLL = new ClaimantAdminInformationBLL();
ClaimantAdminInformationBO objCABO = new ClaimantAdminInformationBO();
objCABO.Type = "SelectByClaimantAdminID";
objCABO.ClaimantAdminID = ClaimantAdminID;
DataSet ds = new DataSet();
objCABLL.ClaimantAdminOperations(objCABO);
ds = objCABO.GetUSStates;
if (ds.Tables[0].Rows.Count > 0)
{
DataTable dt = ds.Tables[0];
ViewState["ClaimantAdminID"] = ds.Tables[0].Rows[0]["ClaimantAdminID"].ToString();
txtClaimantAdminName.Text = ds.Tables[0].Rows[0]["ClaimantAdminName"].ToString();
txtClaimantAdminAddress.Text = ds.Tables[0].Rows[0]["Address"].ToString();
txtClaimantAdminCity.Text = ds.Tables[0].Rows[0]["City"].ToString();
ddlState.Text = ds.Tables[0].Rows[0]["State"].ToString();
txtClaimantAdminPhone.Text = ds.Tables[0].Rows[0]["PhoneNo"].ToString();
txtClaimantAdminZipCode.Text = ds.Tables[0].Rows[0]["ZipCode"].ToString();
txtClaimantAdminFax.Text = ds.Tables[0].Rows[0]["Fax"].ToString();
txtClaimantAdminEmail.Text = ds.Tables[0].Rows[0]["Email"].ToString();
txtCPName.Text = ds.Tables[0].Rows[0]["ContactPersonName"].ToString();
txtCPSSN.Text = ds.Tables[0].Rows[0]["ContactPersonSSN"].ToString();
txtCPTitle.Text = ds.Tables[0].Rows[0]["ContactPersonTitle"].ToString();
txtCPPhone.Text = ds.Tables[0].Rows[0]["ContactPersonPhoneNo"].ToString();
txtCPMobile.Text = ds.Tables[0].Rows[0]["ContactPersonMobileNo"].ToString();
txtCPEmail.Text = ds.Tables[0].Rows[0]["ContactPersonEmail"].ToString();
}
}
private void GetUSStates()
{
ClaimantAdminInformationBLL objBLL = new ClaimantAdminInformationBLL();
ClaimantAdminInformationBO objBO = new ClaimantAdminInformationBO();
DataSet ds = new DataSet();
ds = objBLL.GetUSStates();
ddlState.DataSource = ds;
ddlState.DataTextField = "USStateName";
ddlState.DataValueField = "USStateCd";
ddlState.DataBind();
ddlState.Items.FindByText("California").Selected = true;
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
ClaimantAdminInformationBLL objCABLL = new ClaimantAdminInformationBLL();
ClaimantAdminInformationBO objCABO = new ClaimantAdminInformationBO();
objCABO.ClaimantAdminName = txtClaimantAdminName.Text;
objCABO.Address = txtClaimantAdminAddress.Text;
objCABO.City = txtClaimantAdminCity.Text;
objCABO.State = ddlState.SelectedItem.Value;
objCABO.ZipCode = txtClaimantAdminZipCode.Text;
objCABO.PhoneNo = txtClaimantAdminPhone.Text;
objCABO.Fax = txtClaimantAdminFax.Text;
objCABO.Email = txtClaimantAdminEmail.Text;
objCABO.ContactPersonName = txtCPName.Text;
objCABO.ContactPersonTitle = txtCPTitle.Text;
objCABO.ContactPersonSSN = txtCPSSN.Text;
objCABO.ContactPersonPhoneNo = txtCPPhone.Text;
objCABO.ContactPersonMobileNo = txtCPMobile.Text;
objCABO.ContactPersonEmail = txtCPEmail.Text;
if (ViewState["ClaimantAdminID"] == null)
objCABO.Type = "Insert";
else
{
objCABO.Type = "Update";
objCABO.ClaimantAdminID = Convert.ToInt32(ViewState["ClaimantAdminID"]);
}
objCABLL.ClaimantAdminOperations(objCABO);
Response.Redirect("ClaimantAdministrator.aspx?stat=comp");
//if (objCABO.ClaimantAdminID == 0)
//{
// string str = "";
// Page.ClientScript.RegisterStartupScript(typeof(Page), "success", str);
//}
//else
//{
// string str = "";
// Page.ClientScript.RegisterStartupScript(typeof(Page), "success", str);
//}
}
}