Exemple #1
0
        public List <CenteralLab> SelectAllWelfare()
        {
            List <CenteralLab> allcenteralLabs = new List <CenteralLab>();


            // 1.make new connection

            SqlConnection sqlConnection = new SqlConnection("Data Source=.;Initial Catalog = DigiService;Integrated Security = true");


            //make a command
            SqlCommand sqlCommand = sqlConnection.CreateCommand();

            sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;
            sqlCommand.CommandText = "CenteralLab_SelectAllWelfare";



            CenteralLab TmpCenterLab = null;

            try
            {
                sqlConnection.Open();

                //3.Read data
                SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                while (sqlDataReader.Read())
                {
                    TmpCenterLab    = new CenteralLab();
                    TmpCenterLab.id = sqlDataReader.GetInt32(0);
                    if (sqlDataReader.IsDBNull(1) == false)
                    {
                        TmpCenterLab.title = sqlDataReader.GetString(1);
                    }
                    if (sqlDataReader.IsDBNull(2) == false)
                    {
                        TmpCenterLab.DepartmentId = sqlDataReader.GetInt32(2);
                    }
                    if (sqlDataReader.IsDBNull(3) == false)
                    {
                        TmpCenterLab.IsActived = sqlDataReader.GetString(3);
                    }
                    allcenteralLabs.Add(TmpCenterLab);
                }
                sqlConnection.Close();
            }
            catch
            {
                sqlConnection.Close();
                return(null);
            }



            return(allcenteralLabs);
        }
Exemple #2
0
        public CenteralLab Load(int id)
        {
            // 1.make new connection
            SqlConnection sqlConnection = new SqlConnection("Data Source=DESKTOP-14HI1CV\\SSSQL;Initial Catalog = DigiService;Integrated Security = true");


            //make a command
            SqlCommand sqlCommand = sqlConnection.CreateCommand();

            sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;
            //sqlCommand.CommandText = "SELECT id , title , IsActived , DepartmentId from Area ";
            sqlCommand.CommandText = "CenteralLabLoad";

            CenteralLab TmpCenterLab = null;

            try
            {
                sqlConnection.Open();

                //3.Read data
                SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                if (sqlDataReader.Read())
                {
                    TmpCenterLab    = new CenteralLab();
                    TmpCenterLab.id = sqlDataReader.GetInt32(0);
                    if (sqlDataReader.IsDBNull(1) == false)
                    {
                        TmpCenterLab.title = sqlDataReader.GetString(1);
                    }
                    if (sqlDataReader.IsDBNull(2) == false)
                    {
                        TmpCenterLab.DepartmentId = sqlDataReader.GetInt32(2);
                    }
                    if (sqlDataReader.IsDBNull(3) == false)
                    {
                        TmpCenterLab.IsActived = sqlDataReader.GetString(3);
                    }
                }
                sqlConnection.Close();
            }
            catch
            {
                sqlConnection.Close();
                return(null);
            }

            return(TmpCenterLab);
        }
Exemple #3
0
        protected void btn1_Click(object sender, EventArgs e)

        {
            CenteralLabManager centeralLabManager = new CenteralLabManager();

            CenteralLab centeralLab = centeralLabManager.Load(int.Parse(TextBoxLab.Text));

            if (centeralLab != null)

            {
                label1.Text = centeralLab.IsActived;
            }

            else

            {
                label1.Text = "salam";
            }
        }