Blood Donar Project with Source Code


  • Blood Donar Project is a user friendly application which is used to maintain blood bank details and blood donar infomation along with they blood donation status.
  • Only authenticated user's can add status and blood bank information.
  • By using this application we can find list of blood bank information based on state and city.
  • By using this application we can find list of blood donar details based on Blood Group.



Download Project with Source Code :


Business Object :


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BloodDonarObject
{
   public class BusinessObject
    {
       //Common Objects
        public string SPQuery { get; set; }
        public string State { get; set; }
        public string City { get; set; }
        public string EmailID { get; set; }
        public string Status { get; set; }
        public string ErrorMessage { get; set; }

       // Blood Donar Object
        public string DonarId { get; set; }
        public string DonarUsernamer { get; set; }
        public string DonarPassword { get; set; }
        public string DonarFullName { get; set; }
        public string DonarDateOfBirth { get; set; }
        public string DonarGender { get; set; }
        public string DonarState { get; set; }
        public string DonarCity { get; set; }
        public string DonarEmailID { get; set; }
        public string DonarPhone { get; set; }
        public string DonarBloodGroup { get; set; }

       // Status Object
        public string StatusPostID { get; set; }
        public string StatusPostMessage { get; set; }
        public string StatusPostTiming { get; set; }
        public string NooftimeStatusedited { get; set; }

       // Blood Bank Object
        public string BloodBankID { get; set; }
        public string BloodBankName { get; set; }
        public string BloodBankAddress { get; set; }
        public string BloodBankLandmark { get; set; }
        public string BloodBankPhone1 { get; set; }
        public string BloodBankPhone2 { get; set; }
        public string BloodBankEmailID { get; set; }


    }
}


Database Logic :


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using BloodDonarObject;

namespace BloodDonarDataBaseLogic
{
   public class DatabaseLogic
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbCon"].ToString());
        string query;

        #region Insert Blood Donar Details
        public void InsertBloodDonarDB(BloodDonarObject.BusinessObject boObjDB)
        {
            try
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("proc_insertBloodDonarDetails", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@donarid", boObjDB.DonarId.ToString());
                cmd.Parameters.AddWithValue("@donarusername", boObjDB.DonarUsernamer.ToString());
                cmd.Parameters.AddWithValue("@donarpassword", boObjDB.DonarPassword.ToString());
                cmd.Parameters.AddWithValue("@donarfullname", boObjDB.DonarFullName.ToString());
                cmd.Parameters.AddWithValue("@donardateofbirth", boObjDB.DonarDateOfBirth.ToString());
                cmd.Parameters.AddWithValue("@donargender", boObjDB.DonarGender.ToString());
                cmd.Parameters.AddWithValue("@donarstate",boObjDB.DonarState.ToString());
                cmd.Parameters.AddWithValue("@donarcity", boObjDB.DonarCity.ToString());
                cmd.Parameters.AddWithValue("@donaremailaddress", boObjDB.DonarEmailID.ToString());
                cmd.Parameters.AddWithValue("@donarphonenumber", boObjDB.DonarPhone.ToString());
                cmd.Parameters.AddWithValue("@donarBloodGroup", boObjDB.DonarBloodGroup);
                cmd.Parameters.AddWithValue("@donarstatus", boObjDB.Status.ToString());
                cmd.ExecuteNonQuery();
                con.Close();
            }
            catch(Exception ex)
            {
                boObjDB.ErrorMessage = ex.Message;
            }
            finally
            {
                con.Close();
            }
        }
        #endregion

        #region Insert Status Data
        public void InsertStatusData(BloodDonarObject.BusinessObject ISDObjDB)
        {
            try
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("proc_InsertStatusData", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@donarid", ISDObjDB.DonarId);
                cmd.Parameters.AddWithValue("@statusid", ISDObjDB.StatusPostID);
                cmd.Parameters.AddWithValue("@statusmessage", ISDObjDB.StatusPostMessage);
                cmd.Parameters.AddWithValue("@poststatustime", ISDObjDB.StatusPostTiming);
                cmd.Parameters.AddWithValue("@nooftimestatusedited", ISDObjDB.NooftimeStatusedited);
                cmd.ExecuteNonQuery();
                con.Close();
            }
            catch (Exception ex)
            {
                ISDObjDB.ErrorMessage = ex.Message;
            }
            finally
            {
                con.Close();
            }
        }

        #endregion

        #region Insert Blood Bank Details
        public void InsertBloodBankData(BloodDonarObject.BusinessObject bbObject)
        {
            try
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("proc_InsertBloodBankDetails", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@bbid", bbObject.BloodBankID);
                cmd.Parameters.AddWithValue("@bbname", bbObject.BloodBankName);
                cmd.Parameters.AddWithValue("@bbaddress", bbObject.BloodBankAddress);
                cmd.Parameters.AddWithValue("@bblandmark", bbObject.BloodBankLandmark);
                cmd.Parameters.AddWithValue("@bbphone1", bbObject.BloodBankPhone1);
                cmd.Parameters.AddWithValue("@bbphone2", bbObject.BloodBankPhone2);
                cmd.Parameters.AddWithValue("@bbemail", bbObject.EmailID);
                cmd.Parameters.AddWithValue("@bbstate", bbObject.State);
                cmd.Parameters.AddWithValue("@bbcity", bbObject.City);
                cmd.Parameters.AddWithValue("@userid", bbObject.DonarId);
                cmd.Parameters.AddWithValue("@bbstatus", bbObject.Status);
                cmd.ExecuteNonQuery();
                con.Close();
            }


            catch (Exception ex)
            {
                bbObject.ErrorMessage = ex.Message;
            }
            finally
            {
                con.Close();
            }
        }
        #endregion

        #region Display User Status Based on DonarID
        public DataSet GetStatusPost(BusinessObject sObject)
        {
            try
            {
                DataSet dsstatus = new DataSet();
                SqlCommand cmd = new SqlCommand("proc_getAllUserStatus", con);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@donarid", sObject.DonarId);
                da.Fill(dsstatus);
                return dsstatus;
            }
            catch(Exception ex)
            {
                throw ex;
            }
        }
        #endregion

        #region Blood Donar Login
        public int VerifyBloodDonar(BusinessObject boObj)
        {
            try
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("Select * from donardetails where donarusername='" + boObj.DonarUsernamer + "' and donarpassword='" + boObj.DonarPassword + "' and status='active'", con);

                //SqlCommand cmd = new SqlCommand("proc_getDonarDetails", con);
                //cmd.CommandType = CommandType.StoredProcedure;
                //cmd.Parameters.AddWithValue("@dusername", boObj.DonarUsernamer.ToString());
                //cmd.Parameters.AddWithValue("@donarpassword", boObj.DonarPassword.ToString());
                int i = Convert.ToInt32(cmd.ExecuteScalar());
                if (i > 0)
                {
                    con.Close();
                }
                return i;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
            }
        }
        #endregion

        #region Auto Generate ID For All 
        public string GenerateID(BusinessObject boObject)
        {
            try
            {
                con.Open();
                SqlCommand cmd = new SqlCommand(boObject.SPQuery, con);
                cmd.CommandType = CommandType.StoredProcedure;
                string ID = cmd.ExecuteScalar().ToString();
                return ID;
            }
            catch(Exception ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
            }

        }
        #endregion

        #region Get Donar Details for Dashboard
        public DataSet GetBloodDonarDetails(BusinessObject boObj)
        {
            try
            {
                DataSet ds = new DataSet();
                SqlCommand cmd = new SqlCommand("proc_getsingledonardetails", con);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@donarusername", boObj.DonarUsernamer);
                da.Fill(ds);
                return ds;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
            }
        }
        #endregion

        #region Get ALL Blood Donar Details
        public DataSet GetAllBloodDonarDetails()
        {
            try
            {
                DataSet ds = new DataSet();
                SqlCommand cmd = new SqlCommand("proc_getALLDonarDetails", con);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                cmd.CommandType = CommandType.StoredProcedure;
                da.Fill(ds);
                return ds;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
            }
        }
        #endregion

        #region Filter Blood Donar Details
        public DataSet GetBloodDonarStateCityData(BusinessObject scObject)
        {
            try
            {
                DataSet ds = new DataSet();
                SqlCommand cmd = new SqlCommand("proc_FilterBloodDonarDetails", con);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@state", scObject.State);
                cmd.Parameters.AddWithValue("@city", scObject.City);
                cmd.Parameters.AddWithValue("@bloodgroup", scObject.DonarBloodGroup);
                //cmd.Parameters.AddWithValue("@status", scObject.Status);
                da.Fill(ds);
                return ds;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion

        #region Get All Blood Bank Data
        public DataSet GetALLBloodBankData()
        {
            try
            {
                DataSet ds = new DataSet();
                SqlCommand cmd = new SqlCommand("proc_getAllBloodBankData", con);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                cmd.CommandType = CommandType.StoredProcedure;
                da.Fill(ds);
                return ds;
            }
            catch(Exception ex)
            {
                throw ex;
            }
        }
        #endregion

        #region Get Single Blood Bank Details
        public DataSet GetSingleBloodBankData(BusinessObject sBBObjec)
        {
            DataSet ds = new DataSet();
            SqlCommand cmd = new SqlCommand("proc_singlebloodbankdetails", con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@bbid", sBBObjec.BloodBankID);
            da.Fill(ds);
            return ds;
        }
        #endregion

        #region Filter Blood Bank Details Tthrough State and City
        public DataSet GetBloodBankStateCityData(BusinessObject scObj)
        {
            try
            {
                DataSet ds = new DataSet();
                SqlCommand cmd = new SqlCommand("proc_getBloodbank_StateCity", con);
                SqlDataAdapter da=new SqlDataAdapter(cmd);
                cmd.CommandType=CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@bbstate",scObj.State);
                cmd.Parameters.AddWithValue("@bbcity",scObj.City);
                da.Fill(ds);
                return ds;
            }
            catch(Exception ex)
            {
                throw ex;
            }
        }
        #endregion
    }
}



Business Logic :


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using BloodDonarObject;
using BloodDonarDataBaseLogic;

namespace BloodDonarBusinessLogic
{
    public class BusinessLogic
    {
        BloodDonarDataBaseLogic.DatabaseLogic boDBLogic = new DatabaseLogic();

        #region Insert Blood Donar Details

        public void InsertBloodDonarBL(BloodDonarObject.BusinessObject boObj)
        {
            try
            {
                boDBLogic.InsertBloodDonarDB(boObj);
            }
            catch
            {
                throw;
            }
        }

        #endregion

        #region Insert Post Status Data
        public void InsertPostStatusData(BloodDonarObject.BusinessObject statusObj)
        {
            try
            {
                boDBLogic.InsertStatusData(statusObj);
            }
            catch
            {
                throw;
            }
        }
        #endregion

        #region Insert Blood Bank Details
        public void InsertBBDetails(BloodDonarObject.BusinessObject bbObj)
        {
            try
            {
                boDBLogic.InsertBloodBankData(bbObj);
            }
            catch
            {
                throw;
            }
        }
        #endregion

        #region Get Status Post
        public DataSet DisplayStatusPost(BusinessObject sObject)
        {
            DataSet statuspostDS = new DataSet();
            statuspostDS = boDBLogic.GetStatusPost(sObject);
            return statuspostDS;
        }
        #endregion

        #region Verify Blood Donar Login
        public int VerifyBloodDonarUser(BusinessObject boObj)
        {
            try
            {
                int i = boDBLogic.VerifyBloodDonar(boObj);
                return i;
            }
            catch
            {
                throw;
            }
        }
        #endregion

        #region Auto Generate ID For ALL
        public string AutoGenerateID(BusinessObject boObject)
        {
            try
            {
                return boDBLogic.GenerateID(boObject);
            }
            catch
            {
                throw;
            }
        }

        #endregion

        #region Get Single Donar Details through Username
        public DataSet GetSingleDonarDetails(BusinessObject boObj)
        {
            DataSet ds = new DataSet();
            ds = boDBLogic.GetBloodDonarDetails(boObj);
            return ds;
        }
        #endregion

        #region Get ALL Blood Donar Details 
        public DataSet GetAllBloodDonarData()
        {
            DataSet ds = new DataSet();
            ds = boDBLogic.GetAllBloodDonarDetails();
            return ds;
        }
        #endregion

        #region Get ALL Blood Bank Data
        public DataSet GetALLBloodBankDetails()
        {
            DataSet dsallbb = new DataSet();
            dsallbb = boDBLogic.GetALLBloodBankData();
            return dsallbb;
        }
        #endregion

        #region Get Single Blood Bank Details
        public DataSet GetSingleBBDetails(BusinessObject Obj)
        {
            DataSet dssbb = new DataSet();
            dssbb = boDBLogic.GetSingleBloodBankData(Obj);
            return dssbb;
        }
        #endregion

        #region Filter Blood Bank Details Tthrough State and City
        public DataSet FilterBloodDonarStateCityData(BusinessObject scObj)
        {
            DataSet ds = new DataSet();
            ds = boDBLogic.GetBloodDonarStateCityData(scObj);
            return ds;
        }
        #endregion

        #region Filter Blood Bank Details Tthrough State and City
        public DataSet FilterBloodBankStateCityData(BusinessObject scObject)
        {
            DataSet ds = new DataSet();
            ds = boDBLogic.GetBloodBankStateCityData(scObject);
            return ds;
        }
        #endregion

    }
}



Stored Procedure :

Blood Donar Database Table :

blood donar database table

Insert Blood Donar Stored Procedure Query :


USE [BloodDonar]
GO
/****** Object:  StoredProcedure [dbo].[proc_insertBloodDonarDetails]    Script Date: 03/08/2016 20:50:47 ******/
Create procedure [dbo].[proc_insertBloodDonarDetails](
@donarid varchar(20),
@donarusername varchar(30),
@donarpassword varchar(30),
@donarfullname varchar(50),
@donardateofbirth varchar(30),
@donargender varchar(20),
@donarstate varchar(25),
@donarcity varchar(25),
@donaremailaddress varchar(50),
@donarphonenumber varchar(30),
@donarBloodGroup varchar(30),
@donarstatus nchar(10))
As begin

Insert into donardetails(donarid, donarusername, donarpassword, donarfullname, donardob, donargender, donarstate, donarcity, donaremailid, donarphone,donarbloodgroup,status) values (@donarid, @donarusername, @donarpassword, @donarfullname, @donardateofbirth, @donargender, @donarstate, @donarcity, @donaremailaddress, @donarphonenumber, @donarBloodGroup, @donarstatus)

End


Get Particular Blood Donar Details Stored Procedure Query :

USE [BloodDonar]
GO
/****** Object:  StoredProcedure [dbo].[proc_getsingledonardetails]    Script Date: 03/08/2016 20:52:32 ******/
Create procedure [dbo].[proc_getsingledonardetails](@donarusername nvarchar(25))
as begin 
select * from donardetails where donarusername=@donarusername and status='active'
end


Verify Blood Donar Stored Procedure Query :

This above stored procedure is used to verify blood donar user is authenticated user or not.

USE [BloodDonar]
GO
/****** Object:  StoredProcedure [dbo].[proc_getDonarDetails]    Script Date: 03/08/2016 20:53:52 ******/

Create Procedure [dbo].[proc_getDonarDetails](@dusername nvarchar(25), @donarpassword nvarchar(25))
as begin
 select * from donardetails where donarusername=@dusername and donarpassword=@donarpassword and status='active'
end

Get All Blood Donar Details Stored Procedure Query :
USE [BloodDonar]
GO
/****** Object:  StoredProcedure [dbo].[proc_getALLDonarDetails]    Script Date: 03/08/2016 20:57:12 ******/
Create Procedure [dbo].[proc_getALLDonarDetails]
as begin
 select * from donardetails where status='active'
end

Update Blood Donar Stored Procedure Query :
USE [BloodDonar]
GO
/****** Object:  StoredProcedure [dbo].[proc_UpdateDonarDetails]    Script Date: 03/08/2016 21:01:56 ******/
Create Procedure [dbo].[proc_UpdateDonarDetails](@did nvarchar(12),
@dusername nvarchar(25),
@dpassword nvarchar(25),
@dfullname nvarchar(25),
@ddob nvarchar(20),
@dgender nchar(2),
@demailid nvarchar(30),
@dphone nvarchar(15),
@dbloodgroup nchar(5))
as begin
 update donardetails set donarusername=@dusername, donarpassword=@dpassword, donarfullname=@dfullname, donardob=@ddob, donargender=@dgender, donaremailid=@demailid, donarphone=@dphone, donarbloodgroup=@dbloodgroup where donarid=@did
end

Delete Blood Donar Stored Procedure Query :
USE [BloodDonar]
GO
/****** Object:  StoredProcedure [dbo].[proc_DeleteDonarDetails]    Script Date: 03/08/2016 21:00:51 ******/
Create Procedure [dbo].[proc_DeleteDonarDetails](@did nvarchar(12))
as begin
 Delete donardetails where donarid=@did
end

Filter Blood Donar Details Stored Procedure Query :
USE [BloodDonar]
GO
/****** Object:  StoredProcedure [dbo].[proc_FilterBloodDonarDetails]    Script Date: 03/08/2016 21:03:09 ******/
Create procedure [dbo].[proc_FilterBloodDonarDetails](
@state varchar(25),
@city varchar(25),
@bloodgroup nchar(3))
as begin
 select * from donardetails where donarstate=@state and donarcity=@city and donarbloodgroup=@bloodgroup
end

Blood Bank Database Table :

Blood Bank Database Table

Insert Blood Bank Stored Procedure Query :
USE [BloodDonar]
GO
/****** Object:  StoredProcedure [dbo].[proc_InsertBloodBankDetails]    Script Date: 03/08/2016 21:23:22 ******/
Create procedure [dbo].[proc_InsertBloodBankDetails](
@bbid varchar(10),
@bbname varchar(160),
@bbaddress varchar(250),
@bblandmark varchar(150),
@bbphone1 varchar(15),
@bbphone2 varchar(15),
@bbemail varchar(30),
@bbstate varchar(15),
@bbcity varchar(15),
@userid varchar(12),
@bbstatus nchar(10)
)
as begin 
 Insert into bloodbankdetails(bbid, bbname, bbaddress, bblandmark, bbphone1, bbphone2, bbemail, bbstate, bbcity, userid, bbstatus) values(@bbid, @bbname, @bbaddress,@bblandmark, @bbphone1, @bbphone2, @bbemail, @bbstate, @bbcity, @userid, @bbstatus)
end

Get Particular Blood Bank Details Stored Procedure Query :
USE [BloodDonar]
GO
/****** Object:  StoredProcedure [dbo].[proc_singlebloodbankdetails]    Script Date: 03/08/2016 21:24:39 ******/
Create procedure [dbo].[proc_singlebloodbankdetails](@bbid varchar(10))
as begin
 select * from bloodbankdetails where bbid=@bbid
end

Get All Blood Bank Details Stored Procedure Query :
USE [BloodDonar]
GO
/****** Object:  StoredProcedure [dbo].[proc_getAllBloodBankData]    Script Date: 03/08/2016 21:26:47 ******/
Create procedure [dbo].[proc_getAllBloodBankData]
as begin
 select * from bloodbankdetails where bbstatus='active'
end

Filter Blood Bank Details Through State, City Stored Procedure Query :
USE [BloodDonar]
GO
/****** Object:  StoredProcedure [dbo].[proc_getBloodbank_StateCity]    Script Date: 03/08/2016 21:27:30 ******/
Create procedure [dbo].[proc_getBloodbank_StateCity](@bbstate varchar(25),
@bbcity varchar(25))
as begin
 select * from bloodbankdetails where bbstate=@bbstate and bbcity=@bbcity
end

Post Status Database Table :

Post Status Database Table

Insert PostStatus Stored Procedure Query :
USE [BloodDonar]
GO
/****** Object:  StoredProcedure [dbo].[proc_InsertStatusData]    Script Date: 03/08/2016 21:39:57 ******/
Create procedure [dbo].[proc_InsertStatusData](
@donarid nvarchar(12),
@statusid nvarchar(10),
@statusmessage nvarchar(160),
@poststatustime date,
@nooftimestatusedited nchar(2))
as begin 
 Insert into PostStatus(donarid, statuspostid, statusmessage, statuspostedtime, nooftimepostedited) values(@donarid, @statusid, @statusmessage, @poststatustime, @nooftimestatusedited)
end


Get All PostStatus Stored Procedure Query :
USE [BloodDonar]
GO
/****** Object:  StoredProcedure [dbo].[proc_getAllUserStatus]    Script Date: 03/08/2016 21:40:20 ******/
Create procedure [dbo].[proc_getAllUserStatus](@donarid nvarchar(12))
as begin
 select * from PostStatus where donarid=@donarid
end

No. Of PostStatus Stored Procedure Query :
USE [BloodDonar]
GO
/****** Object:  StoredProcedure [dbo].[proc_NoOfStatusPosted]    Script Date: 03/08/2016 21:40:52 ******/
Create procedure [dbo].[proc_NoOfStatusPosted]
as begin
 select count(*) from PostStatus
end
0 Komentar untuk "Blood Donar Project with Source Code"

Back To Top