예제 #1
0
파일: ServiceAdo.cs 프로젝트: vfonte91/SOAP
        public void CreateAdministrationSet(AdministrationSet adminSet)
        {
            using (SqlConnection conn = new SqlConnection(connString))
            {
                string sql = @"INSERT INTO dbo.Administration_Set_To_Patient (
                            PatientId, MiniDripFlag, MaxiDripFlag
                            ) VALUES (
                            @PatientId, @MiniDripFlag, @MaxiDripFlag
                            )";

                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.Add("@PatientId", SqlDbType.Int).Value = adminSet.PatientId;
                if (adminSet.MiniDripFlag == -1)
                    cmd.Parameters.Add("@MiniDripFlag", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@MiniDripFlag", SqlDbType.Int).Value = adminSet.MiniDripFlag;

                if (adminSet.MaxiDripFlag == -1)
                    cmd.Parameters.Add("@MaxiDripFlag", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@MaxiDripFlag", SqlDbType.Int).Value = adminSet.MaxiDripFlag;

                try
                {
                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    throw e;
                }
                finally
                {
                    conn.Close();
                }
            }
        }
예제 #2
0
파일: ServiceAdo.cs 프로젝트: vfonte91/SOAP
        public int UpdateAdministrationSet(AdministrationSet adminSet)
        {
            int returnNum = 0;
            using (SqlConnection conn = new SqlConnection(connString))
            {
                string sql = @"UPDATE dbo.Administration_Set_To_Patient SET
                            MiniDripFlag = @MiniDripFlag, MaxiDripFlag = @MaxiDripFlag
                            WHERE
                            PatientId = @PatientId";

                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.Add("@PatientId", SqlDbType.Int).Value = adminSet.PatientId;
                if (adminSet.MiniDripFlag == -1)
                    cmd.Parameters.Add("@MiniDripFlag", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@MiniDripFlag", SqlDbType.Int).Value = adminSet.MiniDripFlag;

                if (adminSet.MaxiDripFlag == -1)
                    cmd.Parameters.Add("@MaxiDripFlag", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@MaxiDripFlag", SqlDbType.Int).Value = adminSet.MaxiDripFlag;
                try
                {
                    conn.Open();
                    returnNum = cmd.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    throw e;
                }
                finally
                {
                    conn.Close();
                }
            }
            return returnNum;
        }