Exemplo n.º 1
0
        public Doctor InsertDoctor(Doctor doctor, AuthTable authUser, string connString)
        {
            string errorMessage = string.Empty;
            if (IsValidDoctorData(doctor, authUser, out errorMessage))
            {
                SqlParameter pUsername = new SqlParameter("@Username", SqlDbType.NVarChar, 50);
                SqlParameter pDocFullName = new SqlParameter("@DocName", SqlDbType.NVarChar, 100);
                SqlParameter pDocEmailId = new SqlParameter("@DocEmailId", SqlDbType.NVarChar, 100);
                SqlParameter pDocGender = new SqlParameter("@DocGender", SqlDbType.Bit);
                SqlParameter pDocDOB = new SqlParameter("@DocDateOfBirth", SqlDbType.SmallDateTime);
                SqlParameter pDocLicNo = new SqlParameter("@DocLicenceNo", SqlDbType.Int);
                SqlParameter pDocAreaOfInterest = new SqlParameter("@DocAreaOfInterest", SqlDbType.NVarChar, 100);

                SqlParameter pUsernameAuth = new SqlParameter("@Username", SqlDbType.NVarChar, 50);
                SqlParameter pPassword = new SqlParameter("@Password", SqlDbType.NVarChar, 50);
                SqlParameter pRole = new SqlParameter("@Role", SqlDbType.Int);

                pUsername.Value = doctor.Username;
                pDocFullName.Value = doctor.DocName;
                pDocEmailId.Value = doctor.DocEmailId;
                pDocGender.Value = doctor.DocGender;
                pDocDOB.Value = doctor.DocDateOfBirth;
                pDocLicNo.Value = doctor.DocLicenseNo;
                pDocAreaOfInterest.Value = doctor.DocAreaOfInterest;

                pUsernameAuth.Value = doctor.Username;
                pPassword.Value = authUser.Password;
                pRole.Value = authUser.Role;

                SqlCommand cmdSQL = new SqlCommand();
                cmdSQL.CommandType = CommandType.StoredProcedure;
                cmdSQL.CommandText = "usp_InsertAuthTable";
                cmdSQL.Parameters.Add(pUsernameAuth);
                cmdSQL.Parameters.Add(pPassword);
                cmdSQL.Parameters.Add(pRole);

                DataLayer dataLayerObj = new DataLayer();
                bool isUsernamePresent = IsUsernamePresent(authUser, connString);
                if (!isUsernamePresent)
                {
                    cmdSQL = dataLayerObj.Insert(cmdSQL, connString);
                }
                else
                {
                    errorMessage = "Username already Present." + "<br/>" + errorMessage;
                }

                cmdSQL = new SqlCommand();
                cmdSQL.CommandType = CommandType.StoredProcedure;
                cmdSQL.CommandText = "usp_InsertDoctor";
                cmdSQL.Parameters.Add(pUsername);
                cmdSQL.Parameters.Add(pDocFullName);
                cmdSQL.Parameters.Add(pDocEmailId);
                cmdSQL.Parameters.Add(pDocGender);
                cmdSQL.Parameters.Add(pDocDOB);
                cmdSQL.Parameters.Add(pDocLicNo);
                cmdSQL.Parameters.Add(pDocAreaOfInterest);

                if (!isUsernamePresent)
                {
                    cmdSQL = dataLayerObj.Insert(cmdSQL, connString);
                }
                else
                {
                    throw new Exception(errorMessage);
                }
            }
            else
            {
                throw new Exception(errorMessage);
            }
            return doctor;
        }
Exemplo n.º 2
0
 private bool IsValidDoctorData(Doctor doctor, AuthTable authUser, out string message)
 {
     bool isValidDoctor = true;
     string errorMessage = string.Empty;
     if (string.IsNullOrEmpty(doctor.Username.Trim()))
     {
         isValidDoctor = false;
         errorMessage += "Please enter Username." + "<br />";
     }
     else if (doctor.Username.Length > 50)
     {
         isValidDoctor = false;
         errorMessage += "Username can be upto 50 characters" + "<br />";
     }
     if (string.IsNullOrEmpty(doctor.DocName.Trim()))
     {
         isValidDoctor = false;
         errorMessage += "Please enter valid Full Name" + "<br />";
     }
     else if(doctor.DocName.Length>100)
     {
         isValidDoctor = false;
         errorMessage += "Full name can be upto 100 characters." + "<br />";
     }
     DateTime date;
     bool isValidDate = DateTime.TryParse(doctor.DocDateOfBirth.ToString(), out date);
     if (!isValidDate)
     {
         isValidDoctor = false;
         errorMessage += "Please enter valid Date of Birth." + "<br />";
     }
     else if (date.CompareTo(DateTime.Now) >= 0)
     {
         isValidDoctor = false;
         errorMessage += "Please enter valid Date of Birth." + "<br />";
     }
     string emailRegex = @"^(?("")("".+?""@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-zA-Z])@))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$";
     if (!Regex.IsMatch(doctor.DocEmailId, emailRegex))
     {
         isValidDoctor = false;
         errorMessage += "Please enter valid email-id ([email protected])" + "<br />";
     }
     if (doctor.DocLicenseNo<1)
     {
         isValidDoctor = false;
         errorMessage += "Please enter valid licence number." + "<br />";
     }
     if (string.IsNullOrEmpty(authUser.Password.Trim()))
     {
         isValidDoctor = false;
         errorMessage += "Please enter valid Password." + "<br />";
     }
     message = errorMessage;
     return isValidDoctor;
 }
Exemplo n.º 3
0
 public DataSet getWorkList(bool isAttendedTo, Doctor doc, string connectionString)
 {
     SqlParameter paramIsAttendedTo = new SqlParameter("@IsAttendedTo", SqlDbType.Bit);
     SqlParameter paramUserName = new SqlParameter("@UserName", SqlDbType.VarChar);
     paramUserName.Value = doc.Username;
     paramIsAttendedTo.Value = isAttendedTo;
     SqlCommand cmd = new SqlCommand();
     cmd.CommandType = CommandType.StoredProcedure;
     cmd.CommandText = "usp_GetQueryByIsAttended";
     cmd.Parameters.Add(paramIsAttendedTo);
     cmd.Parameters.Add(paramUserName);
     DataSet ds = new DataSet();
     DataLayer dataLayerObj = new DataLayer();
     ds = dataLayerObj.GetQuery(cmd, connectionString);
     return ds;
 }